diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt --- 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,20 @@ ${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) + get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY IMPORTED_LOCATION_RELEASE) + get_filename_component(zlib_library ${zlib_library} NAME_WE) + STRING(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" zlib_library ${zlib_library}) + STRING(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library}) + 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