llvm.org GIT mirror llvm / fdd7755
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270723 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Bieneman 4 years ago
2 changed file(s) with 21 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
488488
489489 if(CMAKE_VERSION VERSION_LESS 2.8.12)
490490 # Link libs w/o keywords, assuming PUBLIC.
491 target_link_libraries(${name}
491 set(library_type)
492 elseif(ARG_STATIC)
493 set(library_type INTERFACE)
494 elseif(APPLE)
495 set(library_type PUBLIC)
496 else()
497 # We can use PRIVATE since SO knows its dependent libs.
498 set(library_type PRIVATE)
499 endif()
500 target_link_libraries(${name} ${library_type}
492501 ${ARG_LINK_LIBS}
493502 ${lib_deps}
494503 ${llvm_libs}
495504 )
496 elseif(ARG_STATIC)
497 target_link_libraries(${name} INTERFACE
498 ${ARG_LINK_LIBS}
499 ${lib_deps}
500 ${llvm_libs}
501 )
502 else()
503 # We can use PRIVATE since SO knows its dependent libs.
504 target_link_libraries(${name} PRIVATE
505 ${ARG_LINK_LIBS}
506 ${lib_deps}
507 ${llvm_libs}
508 )
509 endif()
510505
511506 if(LLVM_COMMON_DEPENDS)
512507 add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
3636 endif()
3737
3838 add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
39
40 if(APPLE)
41 set(library_type PUBLIC)
42 else()
43 # We can use PRIVATE since SO knows its dependent libs.
44 set(library_type PRIVATE)
45 endif()
46
47 get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
48
49 target_link_libraries(LLVM ${library_type} ${system_libs})
3950
4051 list(REMOVE_DUPLICATES LIB_NAMES)
4152 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf"