[libcxx-commits] [PATCH] D132298: [libcxxabi][cmake] Allow building without libcxx again

John Ericson via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 20 08:09:12 PDT 2022


Ericson2314 created this revision.
Ericson2314 added reviewers: phosek, ldionne.
Herald added a subscriber: mgorny.
Herald added a project: All.
Ericson2314 requested review of this revision.
Herald added a project: libc++abi.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++abi.

This allows `-DLLVM_ENABLE_RUNTIMES=libcxxabi` to work.

This functionality was removed in D125561 <https://reviews.llvm.org/D125561> (among other such removals) as
dead code, because it was only available as part of the standalone build
before.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132298

Files:
  libcxxabi/CMakeLists.txt
  libcxxabi/test/CMakeLists.txt


Index: libcxxabi/test/CMakeLists.txt
===================================================================
--- libcxxabi/test/CMakeLists.txt
+++ libcxxabi/test/CMakeLists.txt
@@ -61,9 +61,13 @@
   list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
 endif()
 
-list(APPEND LIBCXXABI_TEST_DEPS cxx)
-if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
-  list(APPEND LIBCXXABI_TEST_DEPS unwind)
+if(libcxx IN_LIST LLVM_ENABLE_RUNTIMES)
+  list(APPEND LIBCXXABI_TEST_DEPS cxx)
+endif()
+if(libunwind IN_LIST LLVM_ENABLE_RUNTIMES)
+  if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
+    list(APPEND LIBCXXABI_TEST_DEPS unwind)
+  endif()
 endif()
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
Index: libcxxabi/CMakeLists.txt
===================================================================
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -131,10 +131,21 @@
   message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
 endif()
 
-# TODO: Remove this, which shouldn't be necessary since we know we're being built
-#       side-by-side with libc++.
 set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH
     "Specify path to libc++ includes.")
+if (NOT libcxx IN_LIST LLVM_ENABLE_RUNTIMES)
+  if (NOT IS_DIRECTORY ${LIBCXXABI_LIBCXX_INCLUDES})
+    message(FATAL_ERROR
+      "LIBCXXABI_LIBCXX_INCLUDES=${LIBCXXABI_LIBCXX_INCLUDES} is not a valid directory. "
+      "Please provide the path to where the libc++ headers have been installed.")
+  endif()
+  add_library(cxx-headers INTERFACE)
+  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
+    target_compile_options(cxx-headers INTERFACE /I "${LIBCXXABI_LIBCXX_INCLUDES}")
+  else()
+    target_compile_options(cxx-headers INTERFACE -I "${LIBCXXABI_LIBCXX_INCLUDES}")
+  endif()
+endif()
 
 set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF)
 if (WIN32)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132298.454216.patch
Type: text/x-patch
Size: 1927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220820/aa64d8a8/attachment.bin>


More information about the libcxx-commits mailing list