[PATCH] D74176: [CMake] Link against ZLIB::ZLIB
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 21 22:18:45 PST 2020
phosek updated this revision to Diff 246058.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74176/new/
https://reviews.llvm.org/D74176
Files:
llvm/lib/Support/CMakeLists.txt
Index: llvm/lib/Support/CMakeLists.txt
===================================================================
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -1,5 +1,5 @@
if(LLVM_ENABLE_ZLIB)
- set(system_libs ${ZLIB_LIBRARY})
+ set(imported_libs ZLIB::ZLIB)
endif()
if( MSVC OR MINGW )
@@ -186,10 +186,29 @@
${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
${Backtrace_INCLUDE_DIRS}
- LINK_LIBS ${system_libs} ${delayload_flags} ${Z3_LINK_FILES}
+ LINK_LIBS ${system_libs} ${imported_libs} ${delayload_flags} ${Z3_LINK_FILES}
)
-set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
+set(llvm_system_libs ${system_libs})
+
+if(LLVM_ENABLE_ZLIB)
+ string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
+ get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type})
+ if(NOT zlib_library)
+ get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
+ endif()
+ get_filename_component(zlib_library ${zlib_library} NAME)
+ if(zlib_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+ STRING(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+ STRING(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
+ elseif(zlib_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$")
+ STRING(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+ STRING(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
+ endif()
+ set(llvm_system_libs ${llvm_system_libs} "${zlib_library}")
+endif()
+
+set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${llvm_system_libs}")
if(LLVM_WITH_Z3)
target_include_directories(LLVMSupport SYSTEM
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74176.246058.patch
Type: text/x-patch
Size: 1834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200222/d353645d/attachment.bin>
More information about the llvm-commits
mailing list