1 cmake_minimum_required(VERSION 3.26)
3 project(libc++-modules LANGUAGES CXX)
5 # Enable CMake's module support
6 if(CMAKE_VERSION VERSION_LESS "3.27.0")
7 set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
9 set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7")
11 set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
13 # Default to C++ extensions being off. Libc++'s modules support have trouble
14 # with extensions right now.
15 set(CMAKE_CXX_EXTENSIONS OFF)
17 # Propagates the CMake options to the modules.
19 # This uses the std module hard-coded since the std.compat module does not
20 # depend on these flags.
21 macro(compile_define_if_not condition def)
23 target_compile_definitions(std PRIVATE ${def})
26 macro(compile_define_if condition def)
28 target_compile_definitions(std PRIVATE ${def})
32 if(NOT @LIBCXX_ENABLE_THREADS@ OR NOT @LIBCXXABI_ENABLE_THREADS@ OR NOT @LIBCXX_ENABLE_MONOTONIC_CLOCK@)
33 message(FATAL_ERROR "Modules without thread support is not yet implemented.")
35 if(NOT @LIBCXX_ENABLE_FILESYSTEM@)
36 message(FATAL_ERROR "Modules without filesystem support is not yet implemented.")
38 if(NOT @LIBCXX_ENABLE_RANDOM_DEVICE@)
39 message(FATAL_ERROR "Modules without randome device support is not yet implemented.")
41 if(NOT @LIBCXX_ENABLE_UNICODE@)
42 message(FATAL_ERROR "Modules without Unicode support is not yet implemented.")
44 if(NOT @LIBCXX_ENABLE_EXCEPTIONS@ OR NOT @LIBCXXABI_ENABLE_EXCEPTIONS@)
45 message(FATAL_ERROR "Modules without exception support is not yet implemented.")
50 PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES
51 @LIBCXX_SOURCES_MODULE_STD@
54 target_compile_definitions(std PRIVATE _LIBCPP_ENABLE_EXPERIMENTAL)
55 target_include_directories(std SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIR@)
57 target_compile_options(std
60 -Wno-reserved-module-identifier
61 -Wno-reserved-user-defined-literal
62 @LIBCXX_COMPILE_FLAGS@
64 set_target_properties(std