[libc++][CMake] Link against libSystem on Apple platforms

Instead of manually linking against libm/librt/libpthread, we should be
linking against libSystem on Apple platforms, and only that. libm and
libpthread are symlinks to libSystem anyway.

llvm-svn: 359808
This commit is contained in:
Louis Dionne 2019-05-02 17:43:48 +00:00
parent 291a0b89fa
commit 223ed705d0
2 changed files with 11 additions and 0 deletions

View File

@ -80,8 +80,15 @@ if(WIN32 AND NOT MINGW)
set(LIBCXX_HAS_PTHREAD_LIB NO)
set(LIBCXX_HAS_M_LIB NO)
set(LIBCXX_HAS_RT_LIB NO)
set(LIBCXX_HAS_SYSTEM_LIB NO)
elseif(APPLE)
check_library_exists(System write "" LIBCXX_HAS_SYSTEM_LIB)
set(LIBCXX_HAS_PTHREAD_LIB NO)
set(LIBCXX_HAS_M_LIB NO)
set(LIBCXX_HAS_RT_LIB NO)
else()
check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
set(LIBCXX_HAS_SYSTEM_LIB NO)
endif()

View File

@ -140,6 +140,10 @@ function(cxx_link_system_libraries target)
target_add_compile_flags_if_supported(${target} PRIVATE "/Zl")
target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib")
if (LIBCXX_HAS_SYSTEM_LIB)
target_link_libraries(${target} PUBLIC System)
endif()
if (LIBCXX_HAS_PTHREAD_LIB)
target_link_libraries(${target} PUBLIC pthread)
endif()