[llvm] [llvm-config] Make llvm-config --system-libs obey LLVM_USE_STATIC_ZSTD. (PR #93754)
Kyle Huey via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 09:01:06 PDT 2024
https://github.com/khuey updated https://github.com/llvm/llvm-project/pull/93754
>From 7d5d7c54fcd5f6c7a980a6fc247335632637a68b Mon Sep 17 00:00:00 2001
From: Kyle Huey <khuey at kylehuey.com>
Date: Wed, 29 May 2024 16:33:55 -0700
Subject: [PATCH] [llvm-config] Make llvm-config --system-libs obey
LLVM_USE_STATIC_ZSTD.
LLVM's build system does the right thing but LLVM_SYSTEM_LIBS ends up
containing the shared library. Emit the static library instead when
appropriate.
With LLVM_USE_STATIC_ZSTD, before:
khuey at zhadum:~/dev/llvm-project/build$ ./bin/llvm-config --system-libs
-lrt -ldl -lm -lz -lzstd -lxml2
after:
khuey at zhadum:~/dev/llvm-project/build$ ./bin/llvm-config --system-libs
-lrt -ldl -lm -lz /usr/local/lib/libzstd.a -lxml2
---
llvm/lib/Support/CMakeLists.txt | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 0c69ac99f5bc6..c87785994fec7 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -323,8 +323,12 @@ if(LLVM_ENABLE_ZSTD)
if(NOT zstd_library)
get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION)
endif()
- get_library_name(${zstd_library} zstd_library)
- set(llvm_system_libs ${llvm_system_libs} "${zstd_library}")
+ if (zstd_target STREQUAL zstd::libzstd_shared)
+ get_library_name(${zstd_library} zstd_library)
+ set(llvm_system_libs ${llvm_system_libs} "${zstd_library}")
+ else()
+ set(llvm_system_libs ${llvm_system_libs} "${zstd_STATIC_LIBRARY}")
+ endif()
endif()
set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${llvm_system_libs}")
More information about the llvm-commits
mailing list