summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2024-02-16 13:41:39 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2024-02-16 16:09:54 (GMT)
commit150d7dbd683c05fb6266b2eb4622381d0d1bf5ea (patch)
tree9b873b9ce0879edef70c76d4e9e731d9ca89cd13
parente48e5e5506e9d55e3ea634c9cbe9051a35046b2a (diff)
downloadCMake-150d7dbd683c05fb6266b2eb4622381d0d1bf5ea.zip
CMake-150d7dbd683c05fb6266b2eb4622381d0d1bf5ea.tar.gz
CMake-150d7dbd683c05fb6266b2eb4622381d0d1bf5ea.tar.bz2
Tests/CXXModules: support building a project with `Ninja`
This allows testing mixed generator setups.
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index 533a99a..4997c15 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -180,7 +180,13 @@ endfunction ()
# - `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)
@@ -306,3 +312,26 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
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)