mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 10:07:41 +08:00
[CMake] Use correct visibility for linked libraries in CMake
When linking library dependencies, we shouldn't need to export linked libraries to dependents. We should be explicit about this in target_link_libraries, otherwise other targets that depend on these such as sanitizers get repeated (and possibly even conflicting) dependencies. Differential Revision: https://reviews.llvm.org/D57456 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@352688 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -137,6 +137,7 @@ function(add_benchmark_test name source_file)
|
|||||||
add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file})
|
add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file})
|
||||||
add_dependencies(${libcxx_target} cxx cxx-headers google-benchmark-libcxx)
|
add_dependencies(${libcxx_target} cxx cxx-headers google-benchmark-libcxx)
|
||||||
add_dependencies(cxx-benchmarks ${libcxx_target})
|
add_dependencies(cxx-benchmarks ${libcxx_target})
|
||||||
|
target_link_libraries(${libcxx_target} ${LIBCXX_LIBRARIES})
|
||||||
if (LIBCXX_ENABLE_SHARED)
|
if (LIBCXX_ENABLE_SHARED)
|
||||||
target_link_libraries(${libcxx_target} cxx_shared)
|
target_link_libraries(${libcxx_target} cxx_shared)
|
||||||
else()
|
else()
|
||||||
|
@@ -241,7 +241,7 @@ if (LIBCXX_ENABLE_SHARED)
|
|||||||
if(COMMAND llvm_setup_rpath)
|
if(COMMAND llvm_setup_rpath)
|
||||||
llvm_setup_rpath(cxx_shared)
|
llvm_setup_rpath(cxx_shared)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES})
|
target_link_libraries(cxx_shared PRIVATE ${LIBCXX_LIBRARIES})
|
||||||
set_target_properties(cxx_shared
|
set_target_properties(cxx_shared
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
||||||
@@ -265,7 +265,7 @@ endif()
|
|||||||
# Build the static library.
|
# Build the static library.
|
||||||
if (LIBCXX_ENABLE_STATIC)
|
if (LIBCXX_ENABLE_STATIC)
|
||||||
add_library(cxx_static STATIC ${cxx_static_sources})
|
add_library(cxx_static STATIC ${cxx_static_sources})
|
||||||
target_link_libraries(cxx_static ${LIBCXX_LIBRARIES})
|
target_link_libraries(cxx_static PRIVATE ${LIBCXX_LIBRARIES})
|
||||||
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
|
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
|
||||||
set_target_properties(cxx_static
|
set_target_properties(cxx_static
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
@@ -461,3 +461,8 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR
|
|||||||
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
||||||
add_custom_target(install-libcxx DEPENDS install-cxx)
|
add_custom_target(install-libcxx DEPENDS install-cxx)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# TODO: This is needed by cxx-benchmarks but this variable isn't
|
||||||
|
# available outside of the scope of this file so we need to export
|
||||||
|
# it. This is not necessarily the cleanest solution.
|
||||||
|
set(LIBCXX_LIBRARIES ${LIBCXX_LIBRARIES} PARENT_SCOPE)
|
||||||
|
Reference in New Issue
Block a user