[libc-commits] [clang] [libc] [libcxx] [libc][libcxx] Support for building libc++ against LLVM libc (PR #99287)

Louis Dionne via libc-commits libc-commits at lists.llvm.org
Thu Jul 18 05:54:31 PDT 2024


================
@@ -0,0 +1,34 @@
+#===============================================================================
+# Define targets for linking against the selected C library
+#
+# After including this file, the following targets are defined:
+# - libcxx-libc-headers: An interface target that allows getting access to the
+#                        headers of the selected C library.
+# - libcxx-libc-shared: A target representing the selected shared C library.
+# - libcxx-libm-shared: A target representing the selected shared C math library.
+# - libcxx-libc-static: A target representing the selected static C library.
+# - libcxx-libm-static: A target representing the selected static C math library.
+#===============================================================================
+
+# Link against a system-provided libc
+if (LIBCXX_LIBC STREQUAL "system")
+  add_library(libcxx-libc-headers INTERFACE)
+
+  add_library(libcxx-libc-static INTERFACE)
+  add_library(libcxx-libm-static INTERFACE)
+
+  add_library(libcxx-libc-shared INTERFACE)
+  add_library(libcxx-libm-shared INTERFACE)
+
+# Link against the in-tree LLVM libc
+elseif (LIBCXX_LIBC STREQUAL "llvm-libc")
+  add_library(libcxx-libc-headers INTERFACE)
+  target_link_libraries(libcxx-libc-headers INTERFACE libc-headers)
----------------
ldionne wrote:

This presumes that llvm-libc has been included before in the CMake tree, so that these targets are defined. I assume you know for a fact that this is the case?

https://github.com/llvm/llvm-project/pull/99287


More information about the libc-commits mailing list