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 set(LIBCXX_MODULE_STD_INCLUDE_SOURCES)
141 foreach(file ${LIBCXX_MODULE_STD_SOURCES})
143 LIBCXX_MODULE_STD_INCLUDE_SOURCES
144 "${LIBCXX_MODULE_STD_INCLUDE_SOURCES}#include \"${file}\"\n"
150 "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
154 set(LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES)
155 foreach(file ${LIBCXX_MODULE_STD_COMPAT_SOURCES})
157 LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES
158 "${LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES}#include \"${file}\"\n"
164 "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm"
169 list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm")
170 list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm")
171 foreach(file ${LIBCXX_MODULE_STD_SOURCES} ${LIBCXX_MODULE_STD_COMPAT_SOURCES})
172 set(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
173 set(dst "${LIBCXX_GENERATED_MODULE_DIR}/${file}")
174 add_custom_command(OUTPUT ${dst}
176 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
177 COMMENT "Copying CXX module ${file}")
178 list(APPEND _all_modules "${dst}")
181 add_custom_target(generate-cxx-modules
186 # Configure the modules manifest.
187 # Use the relative path between the installation and the module in the json
188 # file. This allows moving the entire installation to a different location.
189 file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
190 ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
191 ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
194 "${LIBCXX_LIBRARY_DIR}/libc++.modules.json"
198 # Dummy library to make modules an installation component.
199 add_library(cxx-modules INTERFACE)
200 add_dependencies(cxx-modules generate-cxx-modules)
202 if (LIBCXX_INSTALL_MODULES)
203 foreach(file ${LIBCXX_MODULE_STD_SOURCES} ${LIBCXX_MODULE_STD_COMPAT_SOURCES})
204 get_filename_component(dir ${file} DIRECTORY)
205 install(FILES ${file}
206 DESTINATION "${LIBCXX_INSTALL_MODULES_DIR}/${dir}"
207 COMPONENT cxx-modules
208 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
212 # Install the generated module files.
214 "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
215 "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm"
216 DESTINATION "${LIBCXX_INSTALL_MODULES_DIR}"
217 COMPONENT cxx-modules
218 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
221 # Install the module manifest.
223 "${LIBCXX_LIBRARY_DIR}/libc++.modules.json"
224 DESTINATION "${LIBCXX_INSTALL_LIBRARY_DIR}"
225 COMPONENT cxx-modules
226 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
229 if (NOT CMAKE_CONFIGURATION_TYPES)
230 add_custom_target(install-cxx-modules
232 COMMAND "${CMAKE_COMMAND}"
233 -DCMAKE_INSTALL_COMPONENT=cxx-modules
234 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
235 # Stripping is a no-op for modules
236 add_custom_target(install-cxx-modules-stripped DEPENDS install-cxx-modules)