[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
Mon Apr 15 18:01:50 PDT 2019


phosek updated this revision to Diff 195281.

Repository:
  rCXX libc++

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

https://reviews.llvm.org/D57872

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


Index: libcxx/lib/CMakeLists.txt
===================================================================
--- libcxx/lib/CMakeLists.txt
+++ libcxx/lib/CMakeLists.txt
@@ -92,12 +92,21 @@
 
 # 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)
+  if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+    list(APPEND LIBCXX_SHARED_LIBRARIES 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()
-    add_interface_library(unwind)
+    list(APPEND LIBCXX_SHARED_LIBRARIES unwind)
+    list(APPEND LIBCXX_INTERFACE_LIBRARIES unwind) # For the linker script
+  endif()
+  if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+    list(APPEND LIBCXX_STATIC_LIBRARIES unwind_shared)
+  elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+    # libunwind is already included in libc++abi
+  else()
+    list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind)
   endif()
 endif()
 
@@ -159,7 +168,7 @@
   if(COMMAND llvm_setup_rpath)
     llvm_setup_rpath(cxx_shared)
   endif()
-  target_link_libraries(cxx_shared PRIVATE ${LIBCXX_LIBRARIES})
+  target_link_libraries(cxx_shared PRIVATE ${LIBCXX_SHARED_LIBRARIES} ${LIBCXX_LIBRARIES})
   set_target_properties(cxx_shared
     PROPERTIES
       COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
@@ -250,7 +259,7 @@
 # Build the static library.
 if (LIBCXX_ENABLE_STATIC)
   add_library(cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
-  target_link_libraries(cxx_static PRIVATE ${LIBCXX_LIBRARIES})
+  target_link_libraries(cxx_static PRIVATE ${LIBCXX_STATIC_LIBRARIES} ${LIBCXX_LIBRARIES})
   set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
   set_target_properties(cxx_static
     PROPERTIES
Index: libcxx/cmake/Modules/HandleLibcxxFlags.cmake
===================================================================
--- libcxx/cmake/Modules/HandleLibcxxFlags.cmake
+++ libcxx/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.195281.patch
Type: text/x-patch
Size: 2938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190416/6ac5c832/attachment.bin>


More information about the libcxx-commits mailing list