summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2020-02-06 15:24:07 -0800
committerHans Wennborg <hans@chromium.org>2020-03-02 10:59:50 +0100
commit917119e95aa1e4ce99395f93f2eb696613c556ff (patch)
tree0901bc8b95a1e264a8569f0f1f8abb6ffab3c03b /llvm/lib
parent499b1699621eb0aed9bec7017c1db60ccad30ae4 (diff)
downloadbcm5719-llvm-917119e95aa1e4ce99395f93f2eb696613c556ff.tar.gz
bcm5719-llvm-917119e95aa1e4ce99395f93f2eb696613c556ff.zip
[CMake] Link against ZLIB::ZLIB
This is the imported target that find_package(ZLIB) defines. Differential Revision: https://reviews.llvm.org/D74176 (cherry picked from commit 2181bf40d87165ff4c208b46b135be823eef5c55)
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/CMakeLists.txt25
1 files changed, 22 insertions, 3 deletions
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 26332d4f539..e23f7989e77 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/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 @@ add_llvm_component_library(LLVMSupport
${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
OpenPOWER on IntegriCloud