[CMake][libcxx] Do not rely on the existence of c++abi or unwind targets

There is no guaranteed order in which CMake files for individual
runtimes are invoked and therefore we cannot rely on existence of
targets defined in other runtimes. Use the new HAVE_<name> options
instead in those cases.

Differential Revision: https://reviews.llvm.org/D28391

llvm-svn: 291632
This commit is contained in:
Petr Hosek 2017-01-11 00:56:10 +00:00
parent e7709560ea
commit 777de22120
2 changed files with 6 additions and 4 deletions

View File

@ -119,8 +119,7 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
NO_DEFAULT_PATH
)
if (NOT DEFINED LIBCXX_STANDALONE_BUILD AND
IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
if (IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_INTREE 1)

View File

@ -229,7 +229,8 @@ if (LIBCXX_ENABLE_STATIC)
if (LIBCXX_CXX_ABI_LIBRARY_PATH)
set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
endif()
if (TARGET ${LIBCXX_CXX_ABI_LIBRARY})
if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
(${LIBCXX_CXX_ABI_LIBRARY} STREQUAL "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:${LIBCXX_CXX_ABI_LIBRARY}>")
else()
set(MERGE_ARCHIVES_ABI_TARGET
@ -300,7 +301,9 @@ if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
set(LIBCXX_INTERFACE_LIBRARY_NAMES)
foreach(lib ${LIBCXX_INTERFACE_LIBRARIES})
# FIXME: Handle cxxabi_static and unwind_static.
if (TARGET ${lib})
if (TARGET ${lib} OR
(${lib} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI) OR
(${lib} MATCHES "unwind(_static|_shared)?" AND HAVE_LIBUNWIND))
list(APPEND LIBCXX_INTERFACE_LIBRARY_NAMES "$<TARGET_PROPERTY:${lib},OUTPUT_NAME>")
else()
list(APPEND LIBCXX_INTERFACE_LIBRARY_NAMES "${lib}")