[llvm] c0b4f24 - tweak zstd behavior in cmake and llvm config for better testing
Cole Kissane via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 1 07:49:52 PDT 2022
Author: Cole Kissane
Date: 2022-09-01T07:49:43-07:00
New Revision: c0b4f248df79f184adba856f13a950a53c881f3f
URL: https://github.com/llvm/llvm-project/commit/c0b4f248df79f184adba856f13a950a53c881f3f
DIFF: https://github.com/llvm/llvm-project/commit/c0b4f248df79f184adba856f13a950a53c881f3f.diff
LOG: tweak zstd behavior in cmake and llvm config for better testing
add LLVM_PREFER_STATIC_ZSTD (default TRUE) cmake config flag
(compression test seems to fail for shared zstd on windows, note that zstd multithread is by default disabled in the static build so it may be a hidden variable)
propagate variable zstd_DIR in LLVMConfig.cmake.in
fix llvm-config CMakeLists.txt behavior for absolute libs windows
get zstd lib name
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D132870
Added:
Modified:
llvm/CMakeLists.txt
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/lib/Support/CMakeLists.txt
llvm/tools/llvm-config/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 8e96c46f58254..8be03bedad82a 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -486,6 +486,8 @@ set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression i
set(LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
+set(LLVM_PREFER_STATIC_ZSTD TRUE CACHE BOOL "Use static version of zstd if available. Can be TRUE, FALSE")
+
set(LLVM_ENABLE_CURL "OFF" CACHE STRING "Use libcurl for the HTTP client if available. Can be ON, OFF, or FORCE_ON")
set(LLVM_ENABLE_HTTPLIB "OFF" CACHE STRING "Use cpp-httplib HTTP server library if available. Can be ON, OFF, or FORCE_ON")
diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in
index fbf28d36bedf4..f1362fa032c2b 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -75,7 +75,6 @@ endif()
set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@)
if(LLVM_ENABLE_ZSTD)
- set(zstd_ROOT @zstd_ROOT@)
find_package(zstd)
endif()
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 6af92dfe86101..636235081688a 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -22,11 +22,29 @@ if (HAS_WERROR_GLOBAL_CTORS)
endif()
if(LLVM_ENABLE_ZLIB)
- set(imported_libs ZLIB::ZLIB)
+ list(APPEND imported_libs ZLIB::ZLIB)
+endif()
+
+set(zstd_target none)
+
+if(LLVM_ENABLE_ZSTD)
+ if(LLVM_PREFER_STATIC_ZSTD)
+ if(TARGET zstd::libzstd_static)
+ set(zstd_target zstd::libzstd_static)
+ else()
+ set(zstd_target zstd::libzstd_shared)
+ endif()
+ else()
+ if(TARGET zstd::libzstd_shared)
+ set(zstd_target zstd::libzstd_shared)
+ else()
+ set(zstd_target zstd::libzstd_static)
+ endif()
+ endif()
endif()
if(LLVM_ENABLE_ZSTD)
- list(APPEND imported_libs zstd::libzstd_shared)
+ list(APPEND imported_libs ${zstd_target})
endif()
if( MSVC OR MINGW )
@@ -301,11 +319,12 @@ if(LLVM_ENABLE_ZSTD)
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
- get_property(zstd_library TARGET zstd::libzstd_shared PROPERTY LOCATION_${build_type})
+ get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION_${build_type})
endif()
if(NOT zstd_library)
- get_property(zstd_library TARGET zstd::libzstd_shared PROPERTY LOCATION)
+ 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}")
endif()
diff --git a/llvm/tools/llvm-config/CMakeLists.txt b/llvm/tools/llvm-config/CMakeLists.txt
index aa5aa20257f9f..6faee031ad6a1 100644
--- a/llvm/tools/llvm-config/CMakeLists.txt
+++ b/llvm/tools/llvm-config/CMakeLists.txt
@@ -17,9 +17,14 @@ add_llvm_tool(llvm-config
# Compute the substitution values for various items.
get_property(SUPPORT_SYSTEM_LIBS TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
get_property(WINDOWSMANIFEST_SYSTEM_LIBS TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS)
+
foreach(l ${SUPPORT_SYSTEM_LIBS} ${WINDOWSMANIFEST_SYSTEM_LIBS})
if(MSVC)
- set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}.lib")
+ if(IS_ABSOLUTE ${l})
+ set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}")
+ else()
+ set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}.lib")
+ endif()
else()
if (l MATCHES "^-")
# If it's an option, pass it without changes.
@@ -34,6 +39,7 @@ foreach(l ${SUPPORT_SYSTEM_LIBS} ${WINDOWSMANIFEST_SYSTEM_LIBS})
endif()
endif()
endforeach()
+
string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}")
# Fetch target specific compile options, e.g. RTTI option
More information about the llvm-commits
mailing list