1 if (CMAKE_VERSION VERSION_LESS 3.26)
2 message(WARNING "The libc++ modules won't be available because the CMake version is too old. Update to CMake 3.26 or later.")
6 # The headers of Table 24: C++ library headers [tab:headers.cpp]
7 # and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c]
8 set(LIBCXX_MODULE_STD_SOURCES
31 std/condition_variable.inc
58 std/hazard_pointer.inc
59 std/initializer_list.inc
73 std/memory_resource.inc
87 std/scoped_allocator.inc
91 std/source_location.inc
106 std/text_encoding.inc
112 std/unordered_map.inc
113 std/unordered_set.inc
121 # TODO MODULES the CMakeLists.txt in the install directory is only temporary
122 # When that is removed the configured file can use the substitution
123 # LIBCXX_GENERATED_INCLUDE_TARGET_DIR avoiding this set.
124 # Also clean up the parts needed to generate the install version.
125 # - LIBCXX_GENERATED_INCLUDE_DIR contains the libc++ headers
126 # - LIBCXX_GENERATED_INCLUDE_TARGET_DIR contains the libc++ site config
127 if ("${LIBCXX_GENERATED_INCLUDE_DIR}" STREQUAL "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
128 # This typically happens when the target is not installed.
129 set(LIBCXX_CONFIGURED_INCLUDE_DIRS "${LIBCXX_GENERATED_INCLUDE_DIR}")
131 # It's important that the arch directory be included first so that its header files
132 # which interpose on the default include dir be included instead of the default ones.
133 set(LIBCXX_CONFIGURED_INCLUDE_DIRS
134 "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR};${LIBCXX_GENERATED_INCLUDE_DIR}"
139 "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt"
143 set(LIBCXX_MODULE_STD_INCLUDE_SOURCES)
144 foreach(file ${LIBCXX_MODULE_STD_SOURCES})
146 LIBCXX_MODULE_STD_INCLUDE_SOURCES
147 "${LIBCXX_MODULE_STD_INCLUDE_SOURCES}#include \"${file}\"\n"
153 "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
158 list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt")
159 list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm")
160 foreach(file ${LIBCXX_MODULE_STD_SOURCES})
161 set(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
162 set(dst "${LIBCXX_GENERATED_MODULE_DIR}/${file}")
163 add_custom_command(OUTPUT ${dst}
165 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
166 COMMENT "Copying CXX module ${file}")
167 list(APPEND _all_modules "${dst}")
170 add_custom_target(generate-cxx-modules