1 # The headers of Table 24: C++ library headers [tab:headers.cpp]
2 # and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c]
3 set(LIBCXX_MODULE_STD_SOURCES
26 std/condition_variable.inc
53 std/hazard_pointer.inc
54 std/initializer_list.inc
68 std/memory_resource.inc
82 std/scoped_allocator.inc
86 std/source_location.inc
101 std/text_encoding.inc
107 std/unordered_map.inc
108 std/unordered_set.inc
116 set(LIBCXX_MODULE_STD_COMPAT_SOURCES
117 std.compat/cassert.inc
118 std.compat/cctype.inc
119 std.compat/cerrno.inc
121 std.compat/cfloat.inc
122 std.compat/cinttypes.inc
123 std.compat/climits.inc
124 std.compat/clocale.inc
126 std.compat/csetjmp.inc
127 std.compat/csignal.inc
128 std.compat/cstdarg.inc
129 std.compat/cstddef.inc
130 std.compat/cstdint.inc
131 std.compat/cstdio.inc
132 std.compat/cstdlib.inc
133 std.compat/cstring.inc
135 std.compat/cuchar.inc
136 std.compat/cwchar.inc
137 std.compat/cwctype.inc
140 # TODO MODULES the CMakeLists.txt in the build directory is only temporary.
141 # This allows using as available in the build directory. Once build systems
142 # have proper support for the installed files this will be removed.
143 if ("${LIBCXX_GENERATED_INCLUDE_DIR}" STREQUAL "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
144 # This typically happens when the target is not installed.
145 set(LIBCXX_CONFIGURED_INCLUDE_DIRS "${LIBCXX_GENERATED_INCLUDE_DIR}")
147 # It's important that the arch directory be included first so that its header files
148 # which interpose on the default include dir be included instead of the default ones.
149 set(LIBCXX_CONFIGURED_INCLUDE_DIRS
150 "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR};${LIBCXX_GENERATED_INCLUDE_DIR}"
155 "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt"
159 set(LIBCXX_MODULE_STD_INCLUDE_SOURCES)
160 foreach(file ${LIBCXX_MODULE_STD_SOURCES})
162 LIBCXX_MODULE_STD_INCLUDE_SOURCES
163 "${LIBCXX_MODULE_STD_INCLUDE_SOURCES}#include \"${file}\"\n"
169 "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
173 set(LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES)
174 foreach(file ${LIBCXX_MODULE_STD_COMPAT_SOURCES})
176 LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES
177 "${LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES}#include \"${file}\"\n"
183 "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm"
188 list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt")
189 list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm")
190 list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm")
191 foreach(file ${LIBCXX_MODULE_STD_SOURCES} ${LIBCXX_MODULE_STD_COMPAT_SOURCES})
192 set(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
193 set(dst "${LIBCXX_GENERATED_MODULE_DIR}/${file}")
194 add_custom_command(OUTPUT ${dst}
196 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
197 COMMENT "Copying CXX module ${file}")
198 list(APPEND _all_modules "${dst}")
201 add_custom_target(generate-cxx-modules
206 # Configure the modules manifest.
207 # Use the relative path between the installation and the module in the json
208 # file. This allows moving the entire installation to a different location.
209 if("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
210 set(BASE_DIRECTORY "/")
212 set(BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX})
214 cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
215 BASE_DIRECTORY ${BASE_DIRECTORY}
216 OUTPUT_VARIABLE ABS_LIBRARY_DIR)
217 cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
218 BASE_DIRECTORY ${BASE_DIRECTORY}
219 OUTPUT_VARIABLE ABS_MODULES_DIR)
220 file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
225 "${LIBCXX_LIBRARY_DIR}/libc++.modules.json"
229 # Dummy library to make modules an installation component.
230 add_library(cxx-modules INTERFACE)
231 add_dependencies(cxx-modules generate-cxx-modules)
233 if (LIBCXX_INSTALL_MODULES)
234 foreach(file ${LIBCXX_MODULE_STD_SOURCES} ${LIBCXX_MODULE_STD_COMPAT_SOURCES})
235 get_filename_component(dir ${file} DIRECTORY)
236 install(FILES ${file}
237 DESTINATION "${LIBCXX_INSTALL_MODULES_DIR}/${dir}"
238 COMPONENT cxx-modules
239 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
243 # Install the generated module files.
245 "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
246 "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm"
247 DESTINATION "${LIBCXX_INSTALL_MODULES_DIR}"
248 COMPONENT cxx-modules
249 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
252 # Install the module manifest.
254 "${LIBCXX_LIBRARY_DIR}/libc++.modules.json"
255 DESTINATION "${LIBCXX_INSTALL_LIBRARY_DIR}"
256 COMPONENT cxx-modules
257 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
260 if (NOT CMAKE_CONFIGURATION_TYPES)
261 add_custom_target(install-cxx-modules
263 COMMAND "${CMAKE_COMMAND}"
264 -DCMAKE_INSTALL_COMPONENT=cxx-modules
265 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
266 # Stripping is a no-op for modules
267 add_custom_target(install-cxx-modules-stripped DEPENDS install-cxx-modules)