[llvm] r270723 - [CMake] LINK_LIBS need to be public for Darwin dylib targets

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 10:08:44 PDT 2016


Author: cbieneman
Date: Wed May 25 12:08:43 2016
New Revision: 270723

URL: http://llvm.org/viewvc/llvm-project?rev=270723&view=rev
Log:
[CMake] LINK_LIBS need to be public for Darwin dylib targets

This should actually address PR27855. This results in adding references to the system libs inside generated dylibs so that they get correctly pulled in when linking against the dylib.

Modified:
    llvm/trunk/cmake/modules/AddLLVM.cmake
    llvm/trunk/tools/llvm-shlib/CMakeLists.txt

Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=270723&r1=270722&r2=270723&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Wed May 25 12:08:43 2016
@@ -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})

Modified: llvm/trunk/tools/llvm-shlib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-shlib/CMakeLists.txt?rev=270723&r1=270722&r2=270723&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-shlib/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-shlib/CMakeLists.txt Wed May 25 12:08:43 2016
@@ -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.




More information about the llvm-commits mailing list