diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index 06d26673e96..573d8725106 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -489,25 +489,20 @@ function(llvm_add_library name) if(CMAKE_VERSION VERSION_LESS 2.8.12) # Link libs w/o keywords, assuming PUBLIC. - target_link_libraries(${name} - ${ARG_LINK_LIBS} - ${lib_deps} - ${llvm_libs} - ) + set(library_type) elseif(ARG_STATIC) - target_link_libraries(${name} INTERFACE - ${ARG_LINK_LIBS} - ${lib_deps} - ${llvm_libs} - ) + set(library_type INTERFACE) + elseif(APPLE) + set(library_type PUBLIC) else() # We can use PRIVATE since SO knows its dependent libs. - target_link_libraries(${name} PRIVATE + set(library_type PRIVATE) + endif() + target_link_libraries(${name} ${library_type} ${ARG_LINK_LIBS} ${lib_deps} ${llvm_libs} ) - endif() if(LLVM_COMMON_DEPENDS) add_dependencies(${name} ${LLVM_COMMON_DEPENDS}) diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt index 3fe672d679a..69a4e43c336 100644 --- a/tools/llvm-shlib/CMakeLists.txt +++ b/tools/llvm-shlib/CMakeLists.txt @@ -38,6 +38,17 @@ endif() add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES}) +if(APPLE) + set(library_type PUBLIC) +else() + # We can use PRIVATE since SO knows its dependent libs. + set(library_type PRIVATE) +endif() + +get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS) + +target_link_libraries(LLVM ${library_type} ${system_libs}) + list(REMOVE_DUPLICATES LIB_NAMES) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf" # GNU ld doesn't resolve symbols in the version script.