Tests/CXXModules; add tests for CXX_MODULE_STD behavior

This commit is contained in:
Ben Boeckel
2024-04-11 10:19:44 -04:00
parent b17e6a52f9
commit 16bf12d1e8
7 changed files with 53 additions and 0 deletions
+6
View File
@@ -15,11 +15,17 @@ if (CMAKE_CXX_FLAGS MATCHES "-std=")
set(forced_cxx_standard 1)
endif ()
set(have_cxx23_import_std 0)
if (TARGET "__CMAKE::CXX23")
set(have_cxx23_import_std 1)
endif ()
# Forward information about the C++ compile features.
string(APPEND info "\
set(CMAKE_CXX_COMPILE_FEATURES \"${CMAKE_CXX_COMPILE_FEATURES}\")
set(CMAKE_MAKE_PROGRAM \"${CMAKE_MAKE_PROGRAM}\")
set(forced_cxx_standard \"${forced_cxx_standard}\")
set(have_cxx23_import_std \"${have_cxx23_import_std}\")
set(CMAKE_CXX_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\")
set(CMAKE_CXX_OUTPUT_EXTENSION \"${CMAKE_CXX_OUTPUT_EXTENSION}\")
set(CXXModules_default_build_type \"${CMAKE_BUILD_TYPE}\")
@@ -0,0 +1,11 @@
enable_language(CXX)
set(CMAKE_CXX_SCANDEP_SOURCE "echo")
set(CMAKE_CXX_MODULE_STD 0)
add_library(nocxx23target)
target_sources(nocxx23target
PRIVATE
FILE_SET fs TYPE CXX_MODULES FILES
sources/module.cxx)
target_compile_features(nocxx23target PRIVATE cxx_std_23)
@@ -0,0 +1 @@
1
@@ -0,0 +1,4 @@
CMake Error in CMakeLists.txt:
The "CXX_MODULE_STD" property on the target "nocxx23target" requires that
the "__CMAKE::CXX23" target exist, but it was not provided by the
toolchain.
@@ -0,0 +1,11 @@
enable_language(CXX)
set(CMAKE_CXX_SCANDEP_SOURCE "echo")
set(CMAKE_CXX_MODULE_STD 1)
add_library(nocxx23target)
target_sources(nocxx23target
PRIVATE
FILE_SET fs TYPE CXX_MODULES FILES
sources/module.cxx)
target_compile_features(nocxx23target PRIVATE cxx_std_23)
@@ -0,0 +1,13 @@
enable_language(CXX)
set(CMAKE_CXX_SCANDEP_SOURCE "echo")
# TODO(cxxmodules): Add instances of this test which test the policy
# of the property's unset behavior.
# set(CMAKE_CXX_MODULE_STD …)
add_library(nocxx23target)
target_sources(nocxx23target
PRIVATE
FILE_SET fs TYPE CXX_MODULES FILES
sources/module.cxx)
target_compile_features(nocxx23target PRIVATE cxx_std_23)
@@ -90,6 +90,13 @@ if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
run_cmake(CXXImportStdInvalidGenex)
endif ()
if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND
NOT have_cxx23_import_std)
run_cmake(NoCXX23TargetUnset)
run_cmake(NoCXX23TargetNotRequired)
run_cmake(NoCXX23TargetRequired)
endif ()
run_cmake(InstallBMI)
run_cmake(InstallBMIGenericArgs)
run_cmake(InstallBMIIgnore)