[libcxx-commits] [PATCH] D57872: [CMake] Split linked libraries for shared and static libc++

Petr Hosek via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 17 14:39:38 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX358614: [CMake] Split linked libraries for shared and static libc++ (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57872?vs=195492&id=195630#toc

Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57872/new/

https://reviews.llvm.org/D57872

Files:
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -90,17 +90,6 @@
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 add_library_flags_if(MINGW "${MINGW_LIBRARIES}")
 
-# Add the unwinder library.
-if (LIBCXXABI_USE_LLVM_UNWINDER)
-  if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
-    add_interface_library(unwind_shared)
-  elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
-    add_interface_library(unwind_static)
-  else()
-    add_interface_library(unwind)
-  endif()
-endif()
-
 # Setup flags.
 add_link_flags_if_supported(-nodefaultlibs)
 
@@ -171,6 +160,19 @@
   )
   cxx_set_common_defines(cxx_shared)
 
+  # Link against LLVM libunwind
+  if (LIBCXXABI_USE_LLVM_UNWINDER)
+    if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+      target_link_libraries(cxx_shared PRIVATE unwind_shared)
+      list(APPEND LIBCXX_INTERFACE_LIBRARIES unwind_shared) # For the linker script
+    elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+      # libunwind is already included in libc++abi
+    else()
+      target_link_libraries(cxx_shared PRIVATE unwind)
+      list(APPEND LIBCXX_INTERFACE_LIBRARIES unwind) # For the linker script
+    endif()
+  endif()
+
   # Link against libc++abi
   if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
     if (APPLE)
Index: cmake/Modules/HandleLibcxxFlags.cmake
===================================================================
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -216,14 +216,6 @@
   endif()
 endmacro()
 
-# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
-macro(add_interface_library)
-  foreach(lib ${ARGN})
-    list(APPEND LIBCXX_LIBRARIES ${lib})
-    list(APPEND LIBCXX_INTERFACE_LIBRARIES ${lib})
-  endforeach()
-endmacro()
-
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57872.195630.patch
Type: text/x-patch
Size: 2196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190417/0be27750/attachment.bin>


More information about the libcxx-commits mailing list