[libcxx-commits] [libcxx] [libc++][C++20 modules] Fixes CMake include paths. (PR #65079)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 4 08:35:04 PDT 2023


https://github.com/mordante updated https://github.com/llvm/llvm-project/pull/65079:

>From c7dead085d216d9b981c3110d0831ef1f2c114fe Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Sat, 26 Aug 2023 12:02:25 +0200
Subject: [PATCH] [libc++][C++20 modules] Fixes CMake include paths.

When the modules are used in a bootstrap build the paths
${LIBCXX_GENERATED_INCLUDE_DIR} and ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}
have a different value and both are needed to build modules.

This issue has been reported on Slack.
---
 libcxx/modules/CMakeLists.txt    | 11 ++++++++++-
 libcxx/modules/CMakeLists.txt.in |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 572ee2d3fe2bdd..338769d64fd40e 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -122,7 +122,16 @@ set(LIBCXX_MODULE_STD_SOURCES
 # When that is removed the configured file can use the substitution
 # LIBCXX_GENERATED_INCLUDE_TARGET_DIR avoiding this set.
 # Also clean up the parts needed to generate the install version.
-set(LIBCXX_CONFIGURED_INCLUDE_DIR ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
+# - LIBCXX_GENERATED_INCLUDE_DIR contains the libc++ headers
+# - LIBCXX_GENERATED_INCLUDE_TARGET_DIR contains the libc++ site config
+if ("${LIBCXX_GENERATED_INCLUDE_DIR}" STREQUAL "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
+  # This typically happens when the target is not installed.
+  set(LIBCXX_CONFIGURED_INCLUDE_DIRS "${LIBCXX_GENERATED_INCLUDE_DIR}")
+else()
+  set(LIBCXX_CONFIGURED_INCLUDE_DIRS
+    "${LIBCXX_GENERATED_INCLUDE_DIR};${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}"
+  )
+endif()
 configure_file(
   "CMakeLists.txt.in"
   "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt"
diff --git a/libcxx/modules/CMakeLists.txt.in b/libcxx/modules/CMakeLists.txt.in
index 1e4b3f9e0d6780..53b0d7f5f8df50 100644
--- a/libcxx/modules/CMakeLists.txt.in
+++ b/libcxx/modules/CMakeLists.txt.in
@@ -40,7 +40,7 @@ target_sources(std
 )
 
 target_compile_definitions(std PRIVATE _LIBCPP_ENABLE_EXPERIMENTAL)
-target_include_directories(std SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIR@)
+target_include_directories(std SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
 
 target_compile_options(std
   PUBLIC



More information about the libcxx-commits mailing list