2024-02-13 20:04:34 +01:00
|
|
|
cmake_minimum_required(VERSION 3.26)
|
|
|
|
|
|
|
|
project(libc++-modules LANGUAGES CXX)
|
|
|
|
|
|
|
|
# Enable CMake's module support
|
|
|
|
if(CMAKE_VERSION VERSION_LESS "3.28.0")
|
|
|
|
if(CMAKE_VERSION VERSION_LESS "3.27.0")
|
|
|
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
|
|
|
|
else()
|
|
|
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
|
|
|
|
else()
|
|
|
|
cmake_policy(VERSION 3.28)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Default to C++ extensions being off. Libc++'s modules support have trouble
|
|
|
|
# with extensions right now.
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
# Propagates the CMake options to the modules.
|
|
|
|
#
|
|
|
|
# This uses the std module hard-coded since the std.compat module does not
|
|
|
|
# depend on these flags.
|
|
|
|
macro(compile_define_if_not condition def)
|
|
|
|
if (NOT ${condition})
|
|
|
|
target_compile_definitions(std PRIVATE ${def})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
macro(compile_define_if condition def)
|
|
|
|
if (${condition})
|
|
|
|
target_compile_definitions(std PRIVATE ${def})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
### STD
|
|
|
|
|
|
|
|
add_library(std)
|
|
|
|
target_sources(std
|
|
|
|
PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES
|
|
|
|
std.cppm
|
|
|
|
)
|
|
|
|
|
2024-06-25 22:57:53 +08:00
|
|
|
target_include_directories(std SYSTEM PUBLIC @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
|
2024-02-13 20:04:34 +01:00
|
|
|
|
|
|
|
if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)
|
|
|
|
target_compile_options(std PUBLIC -fno-exceptions)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_compile_options(std
|
|
|
|
PUBLIC
|
|
|
|
-nostdinc++
|
2024-03-15 08:23:07 -04:00
|
|
|
@LIBCXX_COMPILE_FLAGS@
|
|
|
|
)
|
|
|
|
target_compile_options(std
|
|
|
|
PRIVATE
|
2024-02-13 20:04:34 +01:00
|
|
|
-Wno-reserved-module-identifier
|
|
|
|
-Wno-reserved-user-defined-literal
|
|
|
|
)
|
2024-03-15 08:23:07 -04:00
|
|
|
target_link_options(std PUBLIC -nostdlib++ -Wl,-rpath,@LIBCXX_LIBRARY_DIR@ -L@LIBCXX_LIBRARY_DIR@)
|
|
|
|
target_link_libraries(std c++)
|
2024-02-13 20:04:34 +01:00
|
|
|
set_target_properties(std
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME "c++std"
|
|
|
|
)
|
|
|
|
|
|
|
|
### STD.COMPAT
|
|
|
|
|
|
|
|
add_library(std.compat)
|
|
|
|
target_sources(std.compat
|
|
|
|
PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES
|
|
|
|
std.compat.cppm
|
|
|
|
)
|
|
|
|
|
2024-03-15 08:23:07 -04:00
|
|
|
target_include_directories(std.compat SYSTEM PUBLIC @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
|
2024-02-13 20:04:34 +01:00
|
|
|
|
|
|
|
if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)
|
|
|
|
target_compile_options(std.compat PUBLIC -fno-exceptions)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_compile_options(std.compat
|
|
|
|
PUBLIC
|
|
|
|
-nostdinc++
|
2024-03-15 08:23:07 -04:00
|
|
|
@LIBCXX_COMPILE_FLAGS@
|
|
|
|
)
|
|
|
|
target_compile_options(std.compat
|
|
|
|
PRIVATE
|
2024-02-13 20:04:34 +01:00
|
|
|
-Wno-reserved-module-identifier
|
|
|
|
-Wno-reserved-user-defined-literal
|
|
|
|
)
|
|
|
|
set_target_properties(std.compat
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME "c++std.compat"
|
|
|
|
)
|
|
|
|
add_dependencies(std.compat std)
|
2024-03-15 08:23:07 -04:00
|
|
|
target_link_libraries(std.compat PUBLIC std c++)
|