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})
34 PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES
38 target_include_directories(std SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
40 if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)
41 target_compile_options(std PUBLIC -fno-exceptions)
44 target_compile_options(std
47 -Wno-reserved-module-identifier
48 -Wno-reserved-user-defined-literal
49 @LIBCXX_COMPILE_FLAGS@
51 set_target_properties(std