From 3568730f18d72e45c2f2a1bc12e42ee3166d3fcb Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Fri, 17 Nov 2017 22:49:39 +0000 Subject: [CMake][libcxxabi] Support merging objects when statically linking unwinder When using LLVM unwinder and static unwinder option is set, merge libunwind and libc++abi objects into a single archive. libc++ already supports merging libc++abi.a and libc++.a into a single archive; with this change, it is possible to also include libunwind.a in the same archive which is useful when doing static link and using libc++ as a default C++ library and compiler-rt as a default runtime library. Differential Revision: https://reviews.llvm.org/D39949 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@318563 91177308-0d34-0410-b5e6-96231b3b80d8 --- src/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index adcc412..23e8c88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -151,7 +151,13 @@ endif() # Build the static library. if (LIBCXXABI_ENABLE_STATIC) - add_library(cxxabi_static STATIC $) + set(cxxabi_static_sources $) + if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER) + if (TARGET unwind_static OR HAVE_LIBUNWIND) + list(APPEND cxxabi_static_sources $) + endif() + endif() + add_library(cxxabi_static STATIC ${cxxabi_static_sources}) target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES}) set_target_properties(cxxabi_static PROPERTIES -- cgit v1.2.3