summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-01-17 14:39:51 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-01-17 14:40:23 (GMT)
commitcd6f6b2a9f62564127a055cf8160404141fe2259 (patch)
tree5254036f761153408f96ad186bb0fc0c5bb89277
parent796d66438bce2a46235642767d0614c158723738 (diff)
parent4153d8445bf107f2637ceaca63804f4668fb9305 (diff)
downloadCMake-cd6f6b2a9f62564127a055cf8160404141fe2259.zip
CMake-cd6f6b2a9f62564127a055cf8160404141fe2259.tar.gz
CMake-cd6f6b2a9f62564127a055cf8160404141fe2259.tar.bz2
Merge topic 'cmake-ctest-arguments'
4153d8445b Add CMAKE_CTEST_ARGUMENTS variable to pass command-line arguments to ctest Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4168
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/release/dev/cmake-ctest-arguments.rst6
-rw-r--r--Help/variable/CMAKE_CTEST_ARGUMENTS.rst6
-rw-r--r--Source/cmGlobalGenerator.cxx7
-rw-r--r--Tests/RunCMake/CTest/CMakeCTestArguments-test-check.cmake4
-rw-r--r--Tests/RunCMake/CTest/CMakeCTestArguments.cmake2
-rw-r--r--Tests/RunCMake/CTest/RunCMakeTest.cmake13
7 files changed, 39 insertions, 0 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index ae22fdf..a8fbc09 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -369,6 +369,7 @@ Variables that Control the Build
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/variable/CMAKE_CONFIG_POSTFIX
+ /variable/CMAKE_CTEST_ARGUMENTS
/variable/CMAKE_CUDA_SEPARABLE_COMPILATION
/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS
/variable/CMAKE_DEBUG_POSTFIX
diff --git a/Help/release/dev/cmake-ctest-arguments.rst b/Help/release/dev/cmake-ctest-arguments.rst
new file mode 100644
index 0000000..72a264a
--- /dev/null
+++ b/Help/release/dev/cmake-ctest-arguments.rst
@@ -0,0 +1,6 @@
+cmake-ctest-arguments
+---------------------
+
+* A :variable:`CMAKE_CTEST_ARGUMENTS` variable was added to specify a list
+ of command-line arguments passed to CTest when running through the
+ ``test`` (or ``RUN_TESTS``) target of the generated build system.
diff --git a/Help/variable/CMAKE_CTEST_ARGUMENTS.rst b/Help/variable/CMAKE_CTEST_ARGUMENTS.rst
new file mode 100644
index 0000000..0940b46
--- /dev/null
+++ b/Help/variable/CMAKE_CTEST_ARGUMENTS.rst
@@ -0,0 +1,6 @@
+CMAKE_CTEST_ARGUMENTS
+---------------------
+
+Set this to a :ref:`semicolon-separated list <CMake Language Lists>` of
+command-line arguments to pass to :manual:`ctest(1)` when running tests
+through the ``test`` (or ``RUN_TESTS``) target of the generated build system.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index c3ab4b7..b3eb8e4 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2458,6 +2458,13 @@ void cmGlobalGenerator::AddGlobalTarget_Test(
cmCustomCommandLine singleLine;
singleLine.push_back(cmSystemTools::GetCTestCommand());
singleLine.push_back("--force-new-ctest-process");
+ if (auto testArgs = mf->GetDefinition("CMAKE_CTEST_ARGUMENTS")) {
+ std::vector<std::string> args;
+ cmExpandList(testArgs, args);
+ for (auto const& arg : args) {
+ singleLine.push_back(arg);
+ }
+ }
if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') {
singleLine.push_back("-C");
singleLine.push_back(cmakeCfgIntDir);
diff --git a/Tests/RunCMake/CTest/CMakeCTestArguments-test-check.cmake b/Tests/RunCMake/CTest/CMakeCTestArguments-test-check.cmake
new file mode 100644
index 0000000..3e05953
--- /dev/null
+++ b/Tests/RunCMake/CTest/CMakeCTestArguments-test-check.cmake
@@ -0,0 +1,4 @@
+set(log "${RunCMake_TEST_BINARY_DIR}/output-log.txt")
+if(NOT EXISTS "${log}")
+ set(RunCMake_TEST_FAILED "The expected output log file is missing:\n ${log}")
+endif()
diff --git a/Tests/RunCMake/CTest/CMakeCTestArguments.cmake b/Tests/RunCMake/CTest/CMakeCTestArguments.cmake
new file mode 100644
index 0000000..37f2933
--- /dev/null
+++ b/Tests/RunCMake/CTest/CMakeCTestArguments.cmake
@@ -0,0 +1,2 @@
+include(CTest)
+add_test(NAME CMakeCTestArguments COMMAND ${CMAKE_COMMAND} -E echo CMakeCTestArguments)
diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake
index 1392240..761224a 100644
--- a/Tests/RunCMake/CTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake
@@ -5,3 +5,16 @@ run_cmake(BeforeProject)
unset(RunCMake_TEST_OPTIONS)
run_cmake(NotOn)
+
+function(run_CMakeCTestArguments)
+ run_cmake_with_options(CMakeCTestArguments "-DCMAKE_CTEST_ARGUMENTS=--quiet\\;--output-log\\;output-log.txt")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMakeCTestArguments-build)
+ if(RunCMake_GENERATOR MATCHES "Make|Ninja")
+ set(test "test")
+ else()
+ set(test "RUN_TESTS")
+ endif()
+ run_cmake_command(CMakeCTestArguments-test ${CMAKE_COMMAND} --build . --config Debug --target "${test}")
+endfunction()
+run_CMakeCTestArguments()