diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2024-02-15 03:42:09 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2024-02-15 04:01:25 (GMT) |
commit | e24eecfc33ba5678bed2bbc24cf85bdea0a98de8 (patch) | |
tree | 6e1ff23c92817224999e80f6dbdd38e5a7257e27 /Tests/RunCMake/CXXModules/examples | |
parent | 60a8736378bbef58688c8a3dbfb2d0bce6aa1b6b (diff) | |
download | CMake-e24eecfc33ba5678bed2bbc24cf85bdea0a98de8.zip CMake-e24eecfc33ba5678bed2bbc24cf85bdea0a98de8.tar.gz CMake-e24eecfc33ba5678bed2bbc24cf85bdea0a98de8.tar.bz2 |
Tests/CXXModules: add a test to ensure that `restat` works for collation
Also update the `modules-json-file` test to account for the fact that
`CXXModules.json` is not updated for timestamp-only rebuild triggers.
See: #25511
Diffstat (limited to 'Tests/RunCMake/CXXModules/examples')
6 files changed, 56 insertions, 2 deletions
diff --git a/Tests/RunCMake/CXXModules/examples/depchain-collation-restat-rebuild-check.cmake b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat-rebuild-check.cmake new file mode 100644 index 0000000..46c1d29 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat-rebuild-check.cmake @@ -0,0 +1,12 @@ +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(dep_collation_restat "CMakeFiles/depchain_collation_restat.dir/Debug/main.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") + set(collation_restat "CMakeFiles/depchain_with_collation_restat.dir/Debug/CXXModules.json") +else () + set(dep_collation_restat "CMakeFiles/depchain_collation_restat.dir/main.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") + set(collation_restat "CMakeFiles/depchain_with_collation_restat.dir/CXXModules.json") +endif () + +if (NOT "${RunCMake_TEST_BINARY_DIR}/${collation_restat}" IS_NEWER_THAN "${RunCMake_TEST_BINARY_DIR}/${dep_collation_restat}") + list(APPEND RunCMake_TEST_FAILED + "Object '${dep_collation_restat}' should not have recompiled if '${collation_restat}' did not change content.") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/CMakeLists.txt new file mode 100644 index 0000000..54df83a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.28) +project(cxx_modules_depchain_collation_restat CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(depchain_with_collation_restat) +target_sources(depchain_with_collation_restat + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(depchain_with_collation_restat PUBLIC cxx_std_20) + +add_executable(depchain_collation_restat) +target_sources(depchain_collation_restat + PRIVATE + main.cxx) +target_link_libraries(depchain_collation_restat + PRIVATE + depchain_with_collation_restat) +add_test(NAME depchain_collation_restat COMMAND depchain_collation_restat) diff --git a/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/importable.cxx b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/importable.cxx new file mode 100644 index 0000000..607680a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/importable.cxx @@ -0,0 +1,6 @@ +export module importable; + +export int from_import() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/main.cxx b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/main.cxx new file mode 100644 index 0000000..feb38d2 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/main.cxx @@ -0,0 +1,6 @@ +import importable; + +int main(int argc, char* argv[]) +{ + return from_import(); +} diff --git a/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/pre-rebuild.cmake b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/pre-rebuild.cmake new file mode 100644 index 0000000..e1ff979 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-collation-restat/pre-rebuild.cmake @@ -0,0 +1,7 @@ +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(collation_restat "CMakeFiles/depchain_with_collation_restat.dir/Debug/CXXModules.json") +else () + set(collation_restat "CMakeFiles/depchain_with_collation_restat.dir/CXXModules.json") +endif () + +file(TOUCH_NOCREATE "${RunCMake_TEST_BINARY_DIR}/${collation_restat}") diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake index 452f446..94e833a 100644 --- a/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake +++ b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake @@ -1,8 +1,8 @@ if (RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(dep_modules_json_path "CMakeFiles/depchain_modules_json_file.dir/Debug/CXXModules.json") + set(dep_modules_json_path "CMakeFiles/depchain_modules_json_file.dir/Debug/CXX.dd") set(modules_json_path "CMakeFiles/depchain_with_modules_json_file.dir/Debug/CXXModules.json") else () - set(dep_modules_json_path "CMakeFiles/depchain_modules_json_file.dir/CXXModules.json") + set(dep_modules_json_path "CMakeFiles/depchain_modules_json_file.dir/CXX.dd") set(modules_json_path "CMakeFiles/depchain_with_modules_json_file.dir/CXXModules.json") endif () |