mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-07 04:02:23 +03:00
Tests/CXXModules: split out compilation tests
The test is getting fairly large and timing out more and more often. Split out actual compilation tests.
This commit is contained in:
1 parent
2d988b7ec8
commit
9a8700296c
366 files changed
+633
-330
No files matched your search
@@ -34,6 +34,7 @@ if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "_valgrind")
|
||||
"^RunCMake.Autogen_Qt6_1$"
|
||||
"^RunCMake.GoogleTest$"
|
||||
"^RunCMake.CXXModules$"
|
||||
"^RunCMake.CXXModulesCompile$"
|
||||
"^RunCMake.CommandLine$"
|
||||
|
||||
# Too spurious under Valgrind.
|
||||
|
||||
@@ -833,11 +833,14 @@ set_property(TEST RunCMake.DependencyGraph APPEND PROPERTY LABELS "Fortran")
|
||||
|
||||
# Add C++ Module tests.
|
||||
add_RunCMake_test(CXXModules
|
||||
-DCMake_TEST_CXX_STDLIB_MODULES_JSON=${CMake_TEST_CXX_STDLIB_MODULES_JSON}
|
||||
)
|
||||
add_RunCMake_test(CXXModulesCompile
|
||||
-DCMake_TEST_MODULE_COMPILATION=${CMake_TEST_MODULE_COMPILATION}
|
||||
-DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES}
|
||||
-DCMake_TEST_CXX_STDLIB_MODULES_JSON=${CMake_TEST_CXX_STDLIB_MODULES_JSON}
|
||||
)
|
||||
set_property(TEST RunCMake.CXXModules APPEND
|
||||
set_property(TEST RunCMake.CXXModules RunCMake.CXXModulesCompile APPEND
|
||||
PROPERTY LABELS "CXXModules")
|
||||
|
||||
# ctresalloc links against CMakeLib and CTestLib, which means it can't be built
|
||||
|
||||
@@ -135,330 +135,3 @@ else ()
|
||||
message(FATAL_ERROR
|
||||
"Please add 'DependInfo' tests for the '${RunCMake_GENERATOR}' generator.")
|
||||
endif ()
|
||||
|
||||
# Actual compilation tests.
|
||||
if (NOT CMake_TEST_MODULE_COMPILATION)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
function (run_cxx_module_test directory)
|
||||
set(test_name "${directory}")
|
||||
if (NOT ARGN STREQUAL "")
|
||||
list(POP_FRONT ARGN test_name)
|
||||
endif ()
|
||||
|
||||
set(RunCMake_TEST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/examples/${directory}")
|
||||
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/examples/${test_name}-build")
|
||||
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)
|
||||
else ()
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
|
||||
endif ()
|
||||
if (directory MATCHES "import-std")
|
||||
list(APPEND RunCMake_TEST_OPTIONS
|
||||
${stdlib_custom_json})
|
||||
endif ()
|
||||
|
||||
if (RunCMake_CXXModules_INSTALL)
|
||||
set(prefix "${RunCMake_BINARY_DIR}/examples/${test_name}-install")
|
||||
file(REMOVE_RECURSE "${prefix}")
|
||||
list(APPEND RunCMake_TEST_OPTIONS
|
||||
"-DCMAKE_INSTALL_PREFIX=${prefix}")
|
||||
endif ()
|
||||
|
||||
list(APPEND RunCMake_TEST_OPTIONS
|
||||
"-DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES}"
|
||||
${ARGN})
|
||||
run_cmake("examples/${test_name}")
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
if (RunCMake_CXXModules_TARGET)
|
||||
run_cmake_command("examples/${test_name}-build" "${CMAKE_COMMAND}" --build . --config Debug --target "${RunCMake_CXXModules_TARGET}")
|
||||
else ()
|
||||
run_cmake_command("examples/${test_name}-build" "${CMAKE_COMMAND}" --build . --config Debug)
|
||||
foreach (RunCMake_CXXModules_TARGET IN LISTS RunCMake_CXXModules_TARGETS)
|
||||
set(RunCMake_CXXModules_CONFIG "Debug")
|
||||
set(RunCMake_CXXModules_NAME_SUFFIX "")
|
||||
if (RunCMake_CXXModules_TARGET MATCHES "(.*)@(.*)")
|
||||
set(RunCMake_CXXModules_TARGET "${CMAKE_MATCH_1}")
|
||||
set(RunCMake_CXXModules_CONFIG "${CMAKE_MATCH_2}")
|
||||
set(RunCMake_CXXModules_NAME_SUFFIX "-${RunCMake_CXXModules_CONFIG}")
|
||||
endif ()
|
||||
run_cmake_command("examples/${test_name}-target-${RunCMake_CXXModules_TARGET}${RunCMake_CXXModules_NAME_SUFFIX}" "${CMAKE_COMMAND}" --build . --target "${RunCMake_CXXModules_TARGET}" --config "${RunCMake_CXXModules_CONFIG}")
|
||||
endforeach ()
|
||||
endif ()
|
||||
if (RunCMake_CXXModules_INSTALL)
|
||||
run_cmake_command("examples/${test_name}-install" "${CMAKE_COMMAND}" --build . --target install --config Debug)
|
||||
endif ()
|
||||
if (NOT RunCMake_CXXModules_NO_TEST)
|
||||
run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure)
|
||||
endif ()
|
||||
if (RunCMake_CXXModules_REBUILD)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) # handle 1s resolution
|
||||
include("${RunCMake_TEST_SOURCE_DIR}/pre-rebuild.cmake")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) # handle 1s resolution
|
||||
run_cmake_command("examples/${test_name}-rebuild" "${CMAKE_COMMAND}" --build . --config Debug)
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
function (run_cxx_module_test_target directory target)
|
||||
set(RunCMake_CXXModules_TARGET "${target}")
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test("${directory}" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
function (run_cxx_module_test_rebuild directory)
|
||||
set(RunCMake_CXXModules_INSTALL 0)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
set(RunCMake_CXXModules_REBUILD 1)
|
||||
run_cxx_module_test("${directory}" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
# Module compilation features:
|
||||
# Compiler-based:
|
||||
# - `named`: basic support for named modules is available
|
||||
# - `shared`: shared libraries are supported
|
||||
# - `partitions`: module partitions are supported
|
||||
# - `internal_partitions`: internal module partitions are supported
|
||||
# - `bmionly`: the compiler supports BMI-only builds
|
||||
# - `import_std23`: the compiler supports `import std` for C++23
|
||||
#
|
||||
# Generator-based:
|
||||
# - `compile_commands`: the generator supports `compile_commands.json`
|
||||
# - `collation`: the generator supports module collation features
|
||||
# - `export_bmi`: the generator supports exporting BMIs
|
||||
# - `ninja`: a `ninja` binary is available to perform `Ninja`-only testing
|
||||
# (assumed if the generator matches `Ninja`).
|
||||
string(REPLACE "," ";" CMake_TEST_MODULE_COMPILATION "${CMake_TEST_MODULE_COMPILATION}")
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
list(APPEND CMake_TEST_MODULE_COMPILATION
|
||||
"ninja")
|
||||
endif ()
|
||||
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
set(ninja_cmp0154_target "CMakeFiles/ninja_cmp0154.dir/Debug/unrelated.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
|
||||
else ()
|
||||
set(ninja_cmp0154_target "CMakeFiles/ninja_cmp0154.dir/unrelated.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
|
||||
endif ()
|
||||
run_cxx_module_test_target(ninja-cmp0154 "${ninja_cmp0154_target}")
|
||||
endif ()
|
||||
|
||||
run_cxx_module_test(scan-with-pch)
|
||||
|
||||
# Tests which use named modules.
|
||||
if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(simple)
|
||||
run_cxx_module_test(file-sets-with-dot)
|
||||
run_cxx_module_test(vs-without-flags)
|
||||
run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
|
||||
run_cxx_module_test(unity-build)
|
||||
run_cxx_module_test(object-library)
|
||||
run_cxx_module_test(generated)
|
||||
run_cxx_module_test(deep-chain)
|
||||
run_cxx_module_test(non-trivial-collation-order)
|
||||
run_cxx_module_test(non-trivial-collation-order-randomized)
|
||||
run_cxx_module_test(duplicate)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test(import-from-object)
|
||||
run_cxx_module_test(circular)
|
||||
run_cxx_module_test(try-compile)
|
||||
run_cxx_module_test(try-run)
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
run_cxx_module_test(same-src-name)
|
||||
run_cxx_module_test(scan_properties)
|
||||
run_cxx_module_test(target-objects)
|
||||
|
||||
if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND
|
||||
"import_std23" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(import-std)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test(import-std-no-std-property)
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
run_cxx_module_test(import-std-export-no-std-build)
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
run_cxx_module_test(import-std-export-no-std-install)
|
||||
unset(RunCMake_CXXModules_INSTALL)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(import-std-not-in-export-build)
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-not-in-export-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-not-in-export-build-build")
|
||||
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
run_cxx_module_test(import-std-not-in-export-install)
|
||||
unset(RunCMake_CXXModules_INSTALL)
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-not-in-export-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-not-in-export-install-install")
|
||||
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-export-no-std-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-export-no-std-build-build" -DEXPORT_NO_STD=1)
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-export-no-std-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-export-no-std-install-install" -DEXPORT_NO_STD=1)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Tests which require compile commands support.
|
||||
if ("compile_commands" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-compile-commands)
|
||||
endif ()
|
||||
|
||||
macro (setup_export_build_database_targets)
|
||||
set(RunCMake_CXXModules_TARGETS
|
||||
cmake_build_database-CXX
|
||||
cmake_build_database)
|
||||
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
list(INSERT RunCMake_CXXModules_TARGETS 0
|
||||
cmake_build_database-CXX-Debug
|
||||
cmake_build_database-Debug
|
||||
# Other config targets.
|
||||
cmake_build_database-CXX-Release@Release
|
||||
cmake_build_database-Release@Release)
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Tests which require build database support.
|
||||
if ("build_database" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
setup_export_build_database_targets()
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
|
||||
run_cxx_module_test(export-build-database)
|
||||
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
unset(RunCMake_CXXModules_TARGETS)
|
||||
endif ()
|
||||
|
||||
# Tests which require collation work.
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(duplicate-sources)
|
||||
run_cxx_module_test(public-req-private)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test(req-private-other-target)
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
run_cxx_module_test_rebuild(depchain-modmap)
|
||||
run_cxx_module_test_rebuild(depchain-modules-json-file)
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
run_cxx_module_test_rebuild(depchain-collation-restat)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Tests which use named modules in shared libraries.
|
||||
if ("shared" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(library library-shared -DBUILD_SHARED_LIBS=ON)
|
||||
endif ()
|
||||
|
||||
# Tests which use partitions.
|
||||
if ("partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(partitions)
|
||||
endif ()
|
||||
|
||||
# Tests which use internal partitions.
|
||||
if ("internal_partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(internal-partitions)
|
||||
endif ()
|
||||
|
||||
function (run_cxx_module_import_test type name)
|
||||
set(RunCMake_CXXModules_INSTALL 0)
|
||||
|
||||
if ("EXPORT_BUILD_DATABASE" IN_LIST ARGN)
|
||||
list(REMOVE_ITEM ARGN EXPORT_BUILD_DATABASE)
|
||||
list(APPEND ARGN -DCMAKE_EXPORT_BUILD_DATABASE=1)
|
||||
endif ()
|
||||
|
||||
run_cxx_module_test(import-modules "import-modules-${name}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${name}-${type}" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
# Tests which install BMIs
|
||||
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-interface-no-properties-build)
|
||||
run_cxx_module_test(export-interface-build)
|
||||
run_cxx_module_test(export-include-directories-build)
|
||||
run_cxx_module_test(export-include-directories-old-cmake-build)
|
||||
run_cxx_module_test(export-usage-build)
|
||||
run_cxx_module_test(export-bmi-and-interface-build)
|
||||
run_cxx_module_test(export-command-sepdir-build)
|
||||
run_cxx_module_test(export-transitive-targets-build)
|
||||
run_cxx_module_test(export-transitive-modules1-build)
|
||||
run_cxx_module_test(export-transitive-modules-build export-transitive-modules-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-transitive-modules1-build-build" )
|
||||
run_cxx_module_test(export-with-headers-build)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
|
||||
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_import_test(build export-interface-build)
|
||||
run_cxx_module_import_test(build export-interface-no-properties-build -DNO_PROPERTIES=1)
|
||||
run_cxx_module_import_test(build export-include-directories-build -DINCLUDE_PROPERTIES=1)
|
||||
run_cxx_module_import_test(build export-bmi-and-interface-build -DWITH_BMIS=1)
|
||||
run_cxx_module_import_test(build export-command-sepdir-build -DEXPORT_COMMAND_SEPDIR=1)
|
||||
run_cxx_module_import_test(build export-transitive-targets-build -DTRANSITIVE_TARGETS=1)
|
||||
run_cxx_module_import_test(build export-transitive-modules-build -DTRANSITIVE_MODULES=1)
|
||||
run_cxx_module_import_test(build export-with-headers-build -DWITH_HEADERS=1)
|
||||
|
||||
if ("build_database" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
setup_export_build_database_targets()
|
||||
|
||||
run_cxx_module_import_test(build export-build-database -DBUILD_DATABASE=1 EXPORT_BUILD_DATABASE)
|
||||
|
||||
unset(RunCMake_CXXModules_TARGETS)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# All of the following tests perform installation.
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
|
||||
# Tests which install BMIs
|
||||
if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(install-bmi)
|
||||
run_cxx_module_test(install-bmi-and-interfaces)
|
||||
|
||||
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-interface-no-properties-install)
|
||||
run_cxx_module_test(export-interface-install)
|
||||
run_cxx_module_test(export-include-directories-install)
|
||||
run_cxx_module_test(export-include-directories-old-cmake-install)
|
||||
run_cxx_module_test(export-usage-install)
|
||||
run_cxx_module_test(export-bmi-and-interface-install)
|
||||
run_cxx_module_test(export-command-sepdir-install)
|
||||
run_cxx_module_test(export-transitive-targets-install)
|
||||
run_cxx_module_test(export-transitive-modules1-install)
|
||||
run_cxx_module_test(export-transitive-modules-install export-transitive-modules-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-transitive-modules1-install-install" )
|
||||
run_cxx_module_test(export-with-headers-install)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
|
||||
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_import_test(install export-interface-install)
|
||||
run_cxx_module_import_test(install export-interface-no-properties-install -DNO_PROPERTIES=1)
|
||||
run_cxx_module_import_test(install export-include-directories-install -DINCLUDE_PROPERTIES=1)
|
||||
run_cxx_module_import_test(install export-bmi-and-interface-install -DWITH_BMIS=1)
|
||||
run_cxx_module_import_test(install export-command-sepdir-install -DEXPORT_COMMAND_SEPDIR=1)
|
||||
run_cxx_module_import_test(install export-transitive-targets-install -DTRANSITIVE_TARGETS=1)
|
||||
run_cxx_module_import_test(install export-transitive-modules-install -DTRANSITIVE_MODULES=1)
|
||||
run_cxx_module_import_test(install export-with-headers-install -DWITH_HEADERS=1)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# All remaining tests require a working `Ninja` generator to set up a test case
|
||||
# for the current generator.
|
||||
if (NOT "ninja" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
return ()
|
||||
endif ()
|
||||
# All remaining tests require `bmionly` in order to consume from the `ninja`
|
||||
# build.
|
||||
if (NOT "bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
function (run_cxx_module_test_ninja directory)
|
||||
set(RunCMake_GENERATOR "Ninja")
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
# `Ninja` is not a multi-config generator.
|
||||
set(RunCMake_GENERATOR_IS_MULTI_CONFIG 0)
|
||||
run_cxx_module_test("${directory}" "${directory}-ninja" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
# Installation happens within `run_cxx_module_test_ninja`.
|
||||
set(RunCMake_CXXModules_INSTALL 0)
|
||||
|
||||
set(test_set modules-from-ninja)
|
||||
run_cxx_module_test_ninja("export-${test_set}")
|
||||
run_cxx_module_test(import-modules "import-${test_set}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-${test_set}-ninja-install" -DFROM_NINJA=1)
|
||||
@@ -1 +0,0 @@
|
||||
CMake Error: Public C\+\+ module source `.*/Tests/RunCMake/CXXModules/examples/public-req-private/pub\.cxx` requires the `priv` C\+\+ module which is provided by a private source
|
||||
@@ -0,0 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
@@ -0,0 +1,23 @@
|
||||
enable_language(CXX)
|
||||
|
||||
set(info "")
|
||||
|
||||
# See `Modules/Compiler/MSVC-CXX.cmake` for this. If there is explicitly no
|
||||
# default, the feature list is populated to be everything.
|
||||
if (DEFINED CMAKE_CXX_STANDARD_DEFAULT AND
|
||||
CMAKE_CXX_STANDARD_DEFAULT STREQUAL "")
|
||||
set(CMAKE_CXX_COMPILE_FEATURES "")
|
||||
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(CMAKE_CXX_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\")
|
||||
set(CMAKE_CXX_OUTPUT_EXTENSION \"${CMAKE_CXX_OUTPUT_EXTENSION}\")
|
||||
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION \"${CMAKE_CXX20_STANDARD_COMPILE_OPTION}\")
|
||||
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT \"${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}\")
|
||||
set(CMAKE_CXX_MODULE_MAP_FORMAT \"${CMAKE_CXX_MODULE_MAP_FORMAT}\")
|
||||
")
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}")
|
||||
@@ -0,0 +1,372 @@
|
||||
include(RunCMake)
|
||||
|
||||
set(stdlib_custom_json)
|
||||
if (CMake_TEST_CXX_STDLIB_MODULES_JSON)
|
||||
list(APPEND stdlib_custom_json
|
||||
-DCMAKE_CXX_STDLIB_MODULES_JSON=${CMake_TEST_CXX_STDLIB_MODULES_JSON})
|
||||
endif ()
|
||||
|
||||
run_cmake(Inspect ${stdlib_custom_json})
|
||||
include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake")
|
||||
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_MAKE_PROGRAM}" --version
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE ninja_version
|
||||
ERROR_VARIABLE err
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if (res)
|
||||
message(WARNING
|
||||
"Failed to determine `ninja` version: ${err}")
|
||||
set(ninja_version "0")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set(generator_supports_cxx_modules 0)
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja" AND
|
||||
ninja_version VERSION_GREATER_EQUAL "1.11" AND
|
||||
"cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
|
||||
set(generator_supports_cxx_modules 1)
|
||||
endif ()
|
||||
|
||||
if (RunCMake_GENERATOR MATCHES "Visual Studio" AND
|
||||
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.34")
|
||||
set(generator_supports_cxx_modules 1)
|
||||
endif ()
|
||||
|
||||
# Test behavior when the generator does not support C++20 modules.
|
||||
if (NOT generator_supports_cxx_modules)
|
||||
# Bail; the remaining tests require the generator to successfully generate
|
||||
# with C++20 modules in the source list.
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
# This performs actual compilation tests; avoid it when not requested.
|
||||
if (NOT CMake_TEST_MODULE_COMPILATION)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
# Module compilation features:
|
||||
# Compiler-based:
|
||||
# - `named`: basic support for named modules is available
|
||||
# - `shared`: shared libraries are supported
|
||||
# - `partitions`: module partitions are supported
|
||||
# - `internal_partitions`: internal module partitions are supported
|
||||
# - `bmionly`: the compiler supports BMI-only builds
|
||||
# - `import_std23`: the compiler supports `import std` for C++23
|
||||
#
|
||||
# Generator-based:
|
||||
# - `compile_commands`: the generator supports `compile_commands.json`
|
||||
# - `collation`: the generator supports module collation features
|
||||
# - `export_bmi`: the generator supports exporting BMIs
|
||||
# - `ninja`: a `ninja` binary is available to perform `Ninja`-only testing
|
||||
# (assumed if the generator matches `Ninja`).
|
||||
string(REPLACE "," ";" CMake_TEST_MODULE_COMPILATION "${CMake_TEST_MODULE_COMPILATION}")
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
list(APPEND CMake_TEST_MODULE_COMPILATION
|
||||
"ninja")
|
||||
endif ()
|
||||
|
||||
function (run_cxx_module_test directory)
|
||||
set(test_name "${directory}")
|
||||
if (NOT ARGN STREQUAL "")
|
||||
list(POP_FRONT ARGN test_name)
|
||||
endif ()
|
||||
|
||||
set(RunCMake_TEST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/examples/${directory}")
|
||||
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/examples/${test_name}-build")
|
||||
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)
|
||||
else ()
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
|
||||
endif ()
|
||||
if (directory MATCHES "import-std")
|
||||
list(APPEND RunCMake_TEST_OPTIONS
|
||||
${stdlib_custom_json})
|
||||
endif ()
|
||||
|
||||
if (RunCMake_CXXModules_INSTALL)
|
||||
set(prefix "${RunCMake_BINARY_DIR}/examples/${test_name}-install")
|
||||
file(REMOVE_RECURSE "${prefix}")
|
||||
list(APPEND RunCMake_TEST_OPTIONS
|
||||
"-DCMAKE_INSTALL_PREFIX=${prefix}")
|
||||
endif ()
|
||||
|
||||
list(APPEND RunCMake_TEST_OPTIONS
|
||||
"-DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES}"
|
||||
${ARGN})
|
||||
run_cmake("examples/${test_name}")
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
if (RunCMake_CXXModules_TARGET)
|
||||
run_cmake_command("examples/${test_name}-build" "${CMAKE_COMMAND}" --build . --config Debug --target "${RunCMake_CXXModules_TARGET}")
|
||||
else ()
|
||||
run_cmake_command("examples/${test_name}-build" "${CMAKE_COMMAND}" --build . --config Debug)
|
||||
foreach (RunCMake_CXXModules_TARGET IN LISTS RunCMake_CXXModules_TARGETS)
|
||||
set(RunCMake_CXXModules_CONFIG "Debug")
|
||||
set(RunCMake_CXXModules_NAME_SUFFIX "")
|
||||
if (RunCMake_CXXModules_TARGET MATCHES "(.*)@(.*)")
|
||||
set(RunCMake_CXXModules_TARGET "${CMAKE_MATCH_1}")
|
||||
set(RunCMake_CXXModules_CONFIG "${CMAKE_MATCH_2}")
|
||||
set(RunCMake_CXXModules_NAME_SUFFIX "-${RunCMake_CXXModules_CONFIG}")
|
||||
endif ()
|
||||
run_cmake_command("examples/${test_name}-target-${RunCMake_CXXModules_TARGET}${RunCMake_CXXModules_NAME_SUFFIX}" "${CMAKE_COMMAND}" --build . --target "${RunCMake_CXXModules_TARGET}" --config "${RunCMake_CXXModules_CONFIG}")
|
||||
endforeach ()
|
||||
endif ()
|
||||
if (RunCMake_CXXModules_INSTALL)
|
||||
run_cmake_command("examples/${test_name}-install" "${CMAKE_COMMAND}" --build . --target install --config Debug)
|
||||
endif ()
|
||||
if (NOT RunCMake_CXXModules_NO_TEST)
|
||||
run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure)
|
||||
endif ()
|
||||
if (RunCMake_CXXModules_REBUILD)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) # handle 1s resolution
|
||||
include("${RunCMake_TEST_SOURCE_DIR}/pre-rebuild.cmake")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) # handle 1s resolution
|
||||
run_cmake_command("examples/${test_name}-rebuild" "${CMAKE_COMMAND}" --build . --config Debug)
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
function (run_cxx_module_test_target directory target)
|
||||
set(RunCMake_CXXModules_TARGET "${target}")
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test("${directory}" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
function (run_cxx_module_test_rebuild directory)
|
||||
set(RunCMake_CXXModules_INSTALL 0)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
set(RunCMake_CXXModules_REBUILD 1)
|
||||
run_cxx_module_test("${directory}" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
set(ninja_cmp0154_target "CMakeFiles/ninja_cmp0154.dir/Debug/unrelated.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
|
||||
else ()
|
||||
set(ninja_cmp0154_target "CMakeFiles/ninja_cmp0154.dir/unrelated.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
|
||||
endif ()
|
||||
run_cxx_module_test_target(ninja-cmp0154 "${ninja_cmp0154_target}")
|
||||
endif ()
|
||||
|
||||
run_cxx_module_test(scan-with-pch)
|
||||
|
||||
# Tests which use named modules.
|
||||
if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(simple)
|
||||
run_cxx_module_test(file-sets-with-dot)
|
||||
run_cxx_module_test(vs-without-flags)
|
||||
run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
|
||||
run_cxx_module_test(unity-build)
|
||||
run_cxx_module_test(object-library)
|
||||
run_cxx_module_test(generated)
|
||||
run_cxx_module_test(deep-chain)
|
||||
run_cxx_module_test(non-trivial-collation-order)
|
||||
run_cxx_module_test(non-trivial-collation-order-randomized)
|
||||
run_cxx_module_test(duplicate)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test(import-from-object)
|
||||
run_cxx_module_test(circular)
|
||||
run_cxx_module_test(try-compile)
|
||||
run_cxx_module_test(try-run)
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
run_cxx_module_test(same-src-name)
|
||||
run_cxx_module_test(scan_properties)
|
||||
run_cxx_module_test(target-objects)
|
||||
|
||||
if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND
|
||||
"import_std23" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(import-std)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test(import-std-no-std-property)
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
run_cxx_module_test(import-std-export-no-std-build)
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
run_cxx_module_test(import-std-export-no-std-install)
|
||||
unset(RunCMake_CXXModules_INSTALL)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(import-std-not-in-export-build)
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-not-in-export-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-not-in-export-build-build")
|
||||
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
run_cxx_module_test(import-std-not-in-export-install)
|
||||
unset(RunCMake_CXXModules_INSTALL)
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-not-in-export-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-not-in-export-install-install")
|
||||
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-export-no-std-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-export-no-std-build-build" -DEXPORT_NO_STD=1)
|
||||
run_cxx_module_test(import-std-transitive import-std-transitive-export-no-std-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/import-std-export-no-std-install-install" -DEXPORT_NO_STD=1)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Tests which require compile commands support.
|
||||
if ("compile_commands" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-compile-commands)
|
||||
endif ()
|
||||
|
||||
macro (setup_export_build_database_targets)
|
||||
set(RunCMake_CXXModules_TARGETS
|
||||
cmake_build_database-CXX
|
||||
cmake_build_database)
|
||||
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
list(INSERT RunCMake_CXXModules_TARGETS 0
|
||||
cmake_build_database-CXX-Debug
|
||||
cmake_build_database-Debug
|
||||
# Other config targets.
|
||||
cmake_build_database-CXX-Release@Release
|
||||
cmake_build_database-Release@Release)
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Tests which require build database support.
|
||||
if ("build_database" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
setup_export_build_database_targets()
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
|
||||
run_cxx_module_test(export-build-database)
|
||||
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
unset(RunCMake_CXXModules_TARGETS)
|
||||
endif ()
|
||||
|
||||
# Tests which require collation work.
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(duplicate-sources)
|
||||
run_cxx_module_test(public-req-private)
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
run_cxx_module_test(req-private-other-target)
|
||||
unset(RunCMake_CXXModules_NO_TEST)
|
||||
run_cxx_module_test_rebuild(depchain-modmap)
|
||||
run_cxx_module_test_rebuild(depchain-modules-json-file)
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
run_cxx_module_test_rebuild(depchain-collation-restat)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Tests which use named modules in shared libraries.
|
||||
if ("shared" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(library library-shared -DBUILD_SHARED_LIBS=ON)
|
||||
endif ()
|
||||
|
||||
# Tests which use partitions.
|
||||
if ("partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(partitions)
|
||||
endif ()
|
||||
|
||||
# Tests which use internal partitions.
|
||||
if ("internal_partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(internal-partitions)
|
||||
endif ()
|
||||
|
||||
function (run_cxx_module_import_test type name)
|
||||
set(RunCMake_CXXModules_INSTALL 0)
|
||||
|
||||
if ("EXPORT_BUILD_DATABASE" IN_LIST ARGN)
|
||||
list(REMOVE_ITEM ARGN EXPORT_BUILD_DATABASE)
|
||||
list(APPEND ARGN -DCMAKE_EXPORT_BUILD_DATABASE=1)
|
||||
endif ()
|
||||
|
||||
run_cxx_module_test(import-modules "import-modules-${name}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${name}-${type}" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
# Tests which install BMIs
|
||||
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-interface-no-properties-build)
|
||||
run_cxx_module_test(export-interface-build)
|
||||
run_cxx_module_test(export-include-directories-build)
|
||||
run_cxx_module_test(export-include-directories-old-cmake-build)
|
||||
run_cxx_module_test(export-usage-build)
|
||||
run_cxx_module_test(export-bmi-and-interface-build)
|
||||
run_cxx_module_test(export-command-sepdir-build)
|
||||
run_cxx_module_test(export-transitive-targets-build)
|
||||
run_cxx_module_test(export-transitive-modules1-build)
|
||||
run_cxx_module_test(export-transitive-modules-build export-transitive-modules-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-transitive-modules1-build-build" )
|
||||
run_cxx_module_test(export-with-headers-build)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
|
||||
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_import_test(build export-interface-build)
|
||||
run_cxx_module_import_test(build export-interface-no-properties-build -DNO_PROPERTIES=1)
|
||||
run_cxx_module_import_test(build export-include-directories-build -DINCLUDE_PROPERTIES=1)
|
||||
run_cxx_module_import_test(build export-bmi-and-interface-build -DWITH_BMIS=1)
|
||||
run_cxx_module_import_test(build export-command-sepdir-build -DEXPORT_COMMAND_SEPDIR=1)
|
||||
run_cxx_module_import_test(build export-transitive-targets-build -DTRANSITIVE_TARGETS=1)
|
||||
run_cxx_module_import_test(build export-transitive-modules-build -DTRANSITIVE_MODULES=1)
|
||||
run_cxx_module_import_test(build export-with-headers-build -DWITH_HEADERS=1)
|
||||
|
||||
if ("build_database" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
setup_export_build_database_targets()
|
||||
|
||||
run_cxx_module_import_test(build export-build-database -DBUILD_DATABASE=1 EXPORT_BUILD_DATABASE)
|
||||
|
||||
unset(RunCMake_CXXModules_TARGETS)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# All of the following tests perform installation.
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
|
||||
# Tests which install BMIs
|
||||
if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(install-bmi)
|
||||
run_cxx_module_test(install-bmi-and-interfaces)
|
||||
|
||||
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-interface-no-properties-install)
|
||||
run_cxx_module_test(export-interface-install)
|
||||
run_cxx_module_test(export-include-directories-install)
|
||||
run_cxx_module_test(export-include-directories-old-cmake-install)
|
||||
run_cxx_module_test(export-usage-install)
|
||||
run_cxx_module_test(export-bmi-and-interface-install)
|
||||
run_cxx_module_test(export-command-sepdir-install)
|
||||
run_cxx_module_test(export-transitive-targets-install)
|
||||
run_cxx_module_test(export-transitive-modules1-install)
|
||||
run_cxx_module_test(export-transitive-modules-install export-transitive-modules-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-transitive-modules1-install-install" )
|
||||
run_cxx_module_test(export-with-headers-install)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
|
||||
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_import_test(install export-interface-install)
|
||||
run_cxx_module_import_test(install export-interface-no-properties-install -DNO_PROPERTIES=1)
|
||||
run_cxx_module_import_test(install export-include-directories-install -DINCLUDE_PROPERTIES=1)
|
||||
run_cxx_module_import_test(install export-bmi-and-interface-install -DWITH_BMIS=1)
|
||||
run_cxx_module_import_test(install export-command-sepdir-install -DEXPORT_COMMAND_SEPDIR=1)
|
||||
run_cxx_module_import_test(install export-transitive-targets-install -DTRANSITIVE_TARGETS=1)
|
||||
run_cxx_module_import_test(install export-transitive-modules-install -DTRANSITIVE_MODULES=1)
|
||||
run_cxx_module_import_test(install export-with-headers-install -DWITH_HEADERS=1)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# All remaining tests require a working `Ninja` generator to set up a test case
|
||||
# for the current generator.
|
||||
if (NOT "ninja" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
return ()
|
||||
endif ()
|
||||
# All remaining tests require `bmionly` in order to consume from the `ninja`
|
||||
# build.
|
||||
if (NOT "bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
function (run_cxx_module_test_ninja directory)
|
||||
set(RunCMake_GENERATOR "Ninja")
|
||||
set(RunCMake_CXXModules_NO_TEST 1)
|
||||
set(RunCMake_CXXModules_INSTALL 1)
|
||||
# `Ninja` is not a multi-config generator.
|
||||
set(RunCMake_GENERATOR_IS_MULTI_CONFIG 0)
|
||||
run_cxx_module_test("${directory}" "${directory}-ninja" ${ARGN})
|
||||
endfunction ()
|
||||
|
||||
# Installation happens within `run_cxx_module_test_ninja`.
|
||||
set(RunCMake_CXXModules_INSTALL 0)
|
||||
|
||||
set(test_set modules-from-ninja)
|
||||
run_cxx_module_test_ninja("export-${test_set}")
|
||||
run_cxx_module_test(import-modules "import-${test_set}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-${test_set}-ninja-install" -DFROM_NINJA=1)
|
||||
@@ -0,0 +1,227 @@
|
||||
function (json_placeholders in out)
|
||||
string(REPLACE "<CONFIG>" "${CXXModules_config}" in "${in}")
|
||||
string(TOLOWER "${CXXModules_config}" config_lower)
|
||||
string(REPLACE "<CONFIG_LOWER>" "${config_lower}" in "${in}")
|
||||
string(REPLACE "<CONFIG_OTHER>" "${CXXModules_config_other}" in "${in}")
|
||||
string(TOLOWER "${CXXModules_config_other}" config_lower)
|
||||
string(REPLACE "<CONFIG_OTHER_LOWER>" "${config_lower}" in "${in}")
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
string(REPLACE "<CONFIG_DIR>" "/${CXXModules_config}" in "${in}")
|
||||
string(REPLACE "<CONFIG_OTHER_DIR>" "/${CXXModules_config_other}" in "${in}")
|
||||
else ()
|
||||
string(REPLACE "<CONFIG_DIR>" "" in "${in}")
|
||||
string(REPLACE "<CONFIG_OTHER_DIR>" "" in "${in}")
|
||||
endif ()
|
||||
if (CMAKE_BUILD_TYPE)
|
||||
string(REPLACE "<CONFIG_FORCE>" "${CXXModules_config}" in "${in}")
|
||||
string(REPLACE "<CONFIG_OTHER_FORCE>" "${CXXModules_config_other}" in "${in}")
|
||||
else ()
|
||||
string(REPLACE "<CONFIG_FORCE>" "noconfig" in "${in}")
|
||||
endif ()
|
||||
string(REPLACE "<SOURCE_DIR>" "${RunCMake_SOURCE_DIR}" in "${in}")
|
||||
string(REPLACE "<BINARY_DIR>" "${RunCMake_TEST_BINARY_DIR}" in "${in}")
|
||||
string(REPLACE "<OBJEXT>" "${CMAKE_CXX_OUTPUT_EXTENSION}" in "${in}")
|
||||
if (CMAKE_CXX_MODULE_MAP_FORMAT STREQUAL "gcc")
|
||||
set(bmiflag "-fmodule-only")
|
||||
set(bmiext "gcm")
|
||||
elseif (CMAKE_CXX_MODULE_MAP_FORMAT STREQUAL "clang")
|
||||
set(bmiflag "--precompile")
|
||||
set(bmiext "pcm")
|
||||
elseif (CMAKE_CXX_MODULE_MAP_FORMAT STREQUAL "msvc")
|
||||
set(bmiflag "-ifcOutput.*")
|
||||
set(bmiext "ifc")
|
||||
endif ()
|
||||
string(REPLACE "<BMI_ONLY_FLAG>" "${bmiflag}" in "${in}")
|
||||
string(REPLACE "<BMIEXT>" ".${bmiext}" in "${in}")
|
||||
set(output_flag "-o")
|
||||
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
set(output_flag "-Fo")
|
||||
endif ()
|
||||
string(REPLACE "<OUTPUT_FLAG>" "${output_flag}" in "${in}")
|
||||
string(REPLACE "<CXX20_OPTION>" "${CMAKE_CXX20_STANDARD_COMPILE_OPTION}" in "${in}")
|
||||
string(REPLACE "<HEX>" "[0-9a-f]+" in "${in}")
|
||||
string(REPLACE "REGEX:" "" in "${in}")
|
||||
string(REPLACE "PATH:" "" in "${in}")
|
||||
set("${out}" "${in}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
function (check_json_value path actual_type expect_type actual_value expect_value)
|
||||
if (NOT actual_type STREQUAL expect_type)
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"Type mismatch at:\n ${path}\nexpected:\n ${expect_type}\nactual:\n ${actual_type}\n")
|
||||
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
if (actual_type STREQUAL NULL)
|
||||
# Nothing to check
|
||||
elseif (actual_type STREQUAL BOOLEAN)
|
||||
if (NOT actual_value STREQUAL expect_value)
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"Boolean mismatch at:\n ${path}\nexpected:\n ${expect_value}\nactual:\n ${actual_value}\n")
|
||||
endif ()
|
||||
elseif (actual_type STREQUAL NUMBER)
|
||||
if (NOT actual_value EQUAL expect_value)
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"Number mismatch at:\n ${path}\nexpected:\n ${expect_value}\nactual:\n ${actual_value}\n")
|
||||
endif ()
|
||||
elseif (actual_type STREQUAL STRING)
|
||||
# Allow some values to be ignored.
|
||||
if (expect_value STREQUAL "<IGNORE>")
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
json_placeholders("${expect_value}" expect_value_expanded)
|
||||
if (expect_value MATCHES "^REGEX:PATH:")
|
||||
string(REPLACE "\\" "/" actual_value_check "${actual_value}")
|
||||
string(REGEX REPLACE "^\"(.*)\"$" "\\1" actual_value_check "${actual_value_check}")
|
||||
if (NOT actual_value_check MATCHES "^${expect_value_expanded}$")
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"String mismatch (path regex) at:\n ${path}\nexpected:\n ^${expect_value_expanded}$\nactual:\n ${actual_value}\n")
|
||||
endif ()
|
||||
elseif (expect_value MATCHES "^REGEX:")
|
||||
if (NOT actual_value MATCHES "^${expect_value_expanded}$")
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"String mismatch (regex) at:\n ${path}\nexpected:\n ^${expect_value_expanded}$\nactual:\n ${actual_value}\n")
|
||||
endif ()
|
||||
elseif (expect_value MATCHES "^PATH:")
|
||||
string(REPLACE "\\" "/" actual_value_check "${actual_value}")
|
||||
string(REGEX REPLACE "^\"(.*)\"$" "\\1" actual_value_check "${actual_value_check}")
|
||||
if (NOT actual_value_check STREQUAL "${expect_value_expanded}")
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"String mismatch (path) at:\n ${path}\nexpected:\n ${expect_value_expanded}\nactual:\n ${actual_value}\n")
|
||||
endif ()
|
||||
elseif (NOT actual_value STREQUAL expect_value_expanded)
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"String mismatch at:\n ${path}\nexpected:\n ${expect_value_expanded}\nactual:\n ${actual_value}\n")
|
||||
endif ()
|
||||
elseif (actual_type STREQUAL ARRAY)
|
||||
check_json_array("${path}" "${actual_value}" "${expect_value}")
|
||||
elseif (actual_type STREQUAL OBJECT)
|
||||
check_json_object("${path}" "${actual_value}" "${expect_value}")
|
||||
endif ()
|
||||
|
||||
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Check that two arrays are the same.
|
||||
function (check_json_array path actual expect)
|
||||
if (item_filter)
|
||||
string(JSON iter_len LENGTH "${actual}")
|
||||
set(idx 0)
|
||||
while (idx LESS iter_len)
|
||||
string(JSON type TYPE "${actual}" "${idx}")
|
||||
string(JSON item GET "${actual}" "${idx}")
|
||||
if (type STREQUAL "STRING" AND
|
||||
item MATCHES "${item_filter}")
|
||||
string(JSON actual REMOVE "${actual}" "${idx}")
|
||||
math(EXPR iter_len "${iter_len} - 1")
|
||||
else ()
|
||||
math(EXPR idx "${idx} + 1")
|
||||
endif ()
|
||||
endwhile ()
|
||||
endif ()
|
||||
|
||||
string(JSON actual_len LENGTH "${actual}")
|
||||
string(JSON expect_len LENGTH "${expect}")
|
||||
|
||||
set(iter_len "${actual_len}")
|
||||
if (actual_len LESS expect_len)
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"Missing array items at:\n ${path}\n")
|
||||
elseif (expect_len LESS actual_len)
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"Extra array items at:\n ${path}\n")
|
||||
set(iter_len "${expect_len}")
|
||||
endif ()
|
||||
|
||||
foreach (idx RANGE "${iter_len}")
|
||||
if (idx EQUAL iter_len)
|
||||
break ()
|
||||
endif ()
|
||||
|
||||
set(new_path "${path}[${idx}]")
|
||||
string(JSON actual_type TYPE "${actual}" "${idx}")
|
||||
string(JSON expect_type TYPE "${expect}" "${idx}")
|
||||
string(JSON actual_value GET "${actual}" "${idx}")
|
||||
string(JSON expect_value GET "${expect}" "${idx}")
|
||||
check_json_value("${new_path}" "${actual_type}" "${expect_type}" "${actual_value}" "${expect_value}")
|
||||
endforeach ()
|
||||
|
||||
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Check that two inner objects are the same.
|
||||
function (check_json_object path actual expect)
|
||||
string(JSON actual_len LENGTH "${actual}")
|
||||
string(JSON expect_len LENGTH "${expect}")
|
||||
|
||||
set(actual_keys "")
|
||||
set(expect_keys "")
|
||||
foreach (idx RANGE "${actual_len}")
|
||||
if (idx EQUAL actual_len)
|
||||
break ()
|
||||
endif ()
|
||||
|
||||
string(JSON actual_key MEMBER "${actual}" "${idx}")
|
||||
list(APPEND actual_keys "${actual_key}")
|
||||
endforeach ()
|
||||
foreach (idx RANGE "${expect_len}")
|
||||
if (idx EQUAL expect_len)
|
||||
break ()
|
||||
endif ()
|
||||
|
||||
string(JSON expect_key MEMBER "${expect}" "${idx}")
|
||||
list(APPEND expect_keys "${expect_key}")
|
||||
endforeach ()
|
||||
|
||||
json_placeholders("${expect_keys}" expect_keys_expanded)
|
||||
|
||||
set(actual_keys_missed "${actual_keys}")
|
||||
set(expect_keys_missed "${expect_keys}")
|
||||
|
||||
set(common_keys "")
|
||||
set(expect_keys_stack "${expect_keys}")
|
||||
while (expect_keys_stack)
|
||||
list(POP_BACK expect_keys_stack expect_key)
|
||||
json_placeholders("${expect_key}" expect_key_expanded)
|
||||
|
||||
if (expect_key_expanded IN_LIST actual_keys_missed AND
|
||||
expect_key IN_LIST expect_keys_missed)
|
||||
list(APPEND common_keys "${expect_key}")
|
||||
endif ()
|
||||
|
||||
list(REMOVE_ITEM actual_keys_missed "${expect_key_expanded}")
|
||||
list(REMOVE_ITEM expect_keys_missed "${expect_key}")
|
||||
endwhile ()
|
||||
|
||||
if (actual_keys_missed)
|
||||
string(REPLACE ";" ", " actual_keys_missed_text "${actual_keys_missed}")
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"Extra unexpected members at:\n ${path}\nactual:\n ${actual_keys_missed_text}\n")
|
||||
endif ()
|
||||
if (expect_keys_missed)
|
||||
string(REPLACE ";" ", " expect_keys_missed_text "${expect_keys_missed}")
|
||||
string(APPEND RunCMake_TEST_FAILED
|
||||
"Missing expected members at\n ${path}\nactual:\n ${expect_keys_missed_text}\n")
|
||||
endif ()
|
||||
|
||||
foreach (key IN LISTS common_keys)
|
||||
json_placeholders("${key}" key_expanded)
|
||||
set(new_path "${path}.${key_expanded}")
|
||||
string(JSON actual_type TYPE "${actual}" "${key_expanded}")
|
||||
string(JSON expect_type TYPE "${expect}" "${key}")
|
||||
string(JSON actual_value GET "${actual}" "${key_expanded}")
|
||||
string(JSON expect_value GET "${expect}" "${key}")
|
||||
check_json_value("${new_path}" "${actual_type}" "${expect_type}" "${actual_value}" "${expect_value}")
|
||||
endforeach ()
|
||||
|
||||
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Check that two JSON objects are the same.
|
||||
function (check_json actual expect)
|
||||
check_json_object("" "${actual}" "${expect}")
|
||||
|
||||
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -2,7 +2,7 @@ CMake Warning \(dev\) in CMakeLists\.txt:
|
||||
Target "duplicate_sources" has source file
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/CXXModules/examples/duplicate-sources/duplicate\.cxx
|
||||
]*/Tests/RunCMake/CXXModulesCompile/examples/duplicate-sources/duplicate\.cxx
|
||||
|
||||
in a "FILE_SET TYPE CXX_MODULES" multiple times\.
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 366 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user