summaryrefslogtreecommitdiff
path: root/libcxxabi/src
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-07-24 07:06:17 +0000
committerPetr Hosek <phosek@chromium.org>2018-07-24 07:06:17 +0000
commit2ed3c703cd7cdc2800980765b42f1b391e6c97c8 (patch)
treee2c2ea7978110a5131b6403efc7f6c63b6d421d3 /libcxxabi/src
parent4035e72114cef32023b2e213e022d0a92cb11ef5 (diff)
Reland "[CMake] Support statically linking dependencies only to shared or static library"
This is a reland of commit r337668.
Diffstat (limited to 'libcxxabi/src')
-rw-r--r--libcxxabi/src/CMakeLists.txt23
1 files changed, 15 insertions, 8 deletions
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 5a929cff170..98278795d70 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -61,12 +61,19 @@ 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 LIBCXXABI_LIBRARIES unwind_shared)
- elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
- list(APPEND LIBCXXABI_LIBRARIES unwind_static)
+ if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+ list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_shared)
+ elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+ list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_static)
else()
- list(APPEND LIBCXXABI_LIBRARIES unwind)
+ list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind)
+ endif()
+ if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+ list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_shared)
+ elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+ # We handle this by directly merging libunwind objects into libc++abi.
+ else()
+ list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind)
endif()
else()
add_library_flags_if(LIBCXXABI_HAS_GCC_S_LIB gcc_s)
@@ -130,7 +137,7 @@ if (LIBCXXABI_ENABLE_SHARED)
if(COMMAND llvm_setup_rpath)
llvm_setup_rpath(cxxabi_shared)
endif()
- target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES})
+ target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES} ${LIBCXXABI_SHARED_LIBRARIES})
set_target_properties(cxxabi_shared
PROPERTIES
CXX_EXTENSIONS
@@ -155,13 +162,13 @@ endif()
# Build the static library.
if (LIBCXXABI_ENABLE_STATIC)
set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_objects>)
- if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER)
+ if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY)
if (TARGET unwind_static OR HAVE_LIBUNWIND)
list(APPEND cxxabi_static_sources $<TARGET_OBJECTS:unwind_objects>)
endif()
endif()
add_library(cxxabi_static STATIC ${cxxabi_static_sources})
- target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES})
+ target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES} ${LIBCXXABI_STATIC_LIBRARIES})
set_target_properties(cxxabi_static
PROPERTIES
CXX_EXTENSIONS