summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartell Malone <martellmalone@gmail.com>2017-06-01 00:09:20 +0000
committerMartell Malone <martellmalone@gmail.com>2017-06-01 00:09:20 +0000
commit380a70a942cdad1ba468f7e0836d48a874837ab2 (patch)
treeeca2740bc890bb4b190e5f92bffa3307c25708c8 /src
parent7512331622d78a262298560330e4a39d69892203 (diff)
[libcxxabi] Rework CMakeLists.txt into modules
Refactor cmake to remove dependence on LLVM's cmake modules. This improves handling of cmake checks when cross compiling and brings libcxxabi in line with libcxx and other project modules. Differential revision: https://reviews.llvm.org/D33635 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@304374 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d844b7f..ac2c3a6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -52,36 +52,33 @@ if (LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
add_definitions(-DHAVE___CXA_THREAD_ATEXIT_IMPL)
endif()
-# Generate library list
-set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})
-
if (LIBCXXABI_ENABLE_THREADS)
- append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread)
+ add_library_flags_if(LIBCXXABI_HAS_PTHREAD_LIB pthread)
endif()
-append_if(libraries LIBCXXABI_HAS_C_LIB c)
+add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
if (LIBCXXABI_USE_LLVM_UNWINDER)
# Prefer using the in-tree version of libunwind, either shared or static. If
# none are found fall back to using -lunwind.
# FIXME: Is it correct to prefer the static version of libunwind?
if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
- list(APPEND libraries unwind_shared)
+ list(APPEND LIBCXXABI_LIBRARIES unwind_shared)
elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
- list(APPEND libraries unwind_static)
+ list(APPEND LIBCXXABI_LIBRARIES unwind_static)
else()
- list(APPEND libraries unwind)
+ list(APPEND LIBCXXABI_LIBRARIES unwind)
endif()
else()
- append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)
+ add_library_flags_if(LIBCXXABI_HAS_GCC_S_LIB gcc_s)
endif()
if (MINGW)
# MINGW_LIBRARIES is defined in config-ix.cmake
- list(APPEND libraries ${MINGW_LIBRARIES})
+ list(APPEND LIBCXXABI_LIBRARIES ${MINGW_LIBRARIES})
endif()
# Setup flags.
-append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FPIC_FLAG -fPIC)
-append_if(LIBCXXABI_LINK_FLAGS LIBCXXABI_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
+add_compile_flags_if_supported(-fPIC)
+add_link_flags_if_supported(-nodefaultlibs)
set(LIBCXXABI_SHARED_LINK_FLAGS)
@@ -101,9 +98,9 @@ if ( APPLE )
endif()
endif()
-string(REPLACE ";" " " LIBCXXABI_COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}")
-string(REPLACE ";" " " LIBCXXABI_LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}")
-string(REPLACE ";" " " LIBCXXABI_SHARED_LINK_FLAGS "${LIBCXXABI_SHARED_LINK_FLAGS}")
+split_list(LIBCXXABI_COMPILE_FLAGS)
+split_list(LIBCXXABI_LINK_FLAGS)
+split_list(LIBCXXABI_SHARED_LINK_FLAGS)
# FIXME: libc++abi.so will not link when modules are enabled because it depends
# on symbols defined in libc++.so which has not yet been built.
@@ -124,7 +121,7 @@ set(LIBCXXABI_TARGETS)
# Build the shared library.
if (LIBCXXABI_ENABLE_SHARED)
add_library(cxxabi_shared SHARED $<TARGET_OBJECTS:cxxabi_objects>)
- target_link_libraries(cxxabi_shared ${libraries})
+ target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES})
set_target_properties(cxxabi_shared
PROPERTIES
LINK_FLAGS "${LIBCXXABI_LINK_FLAGS} ${LIBCXXABI_SHARED_LINK_FLAGS}"
@@ -138,7 +135,7 @@ endif()
# Build the static library.
if (LIBCXXABI_ENABLE_STATIC)
add_library(cxxabi_static STATIC $<TARGET_OBJECTS:cxxabi_objects>)
- target_link_libraries(cxxabi_static ${libraries})
+ target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES})
set_target_properties(cxxabi_static
PROPERTIES
LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}"