summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-02-23 14:12:55 (GMT)
committerBrad King <brad.king@kitware.com>2021-02-23 14:22:00 (GMT)
commit6fa36470239a40ef81752ddea923d8618ad6eb7c (patch)
treeb1a9b98b5485f9a824d5986446163883bc22b62d
parent3357d377612fc238ff9da61666041764792034bb (diff)
downloadCMake-6fa36470239a40ef81752ddea923d8618ad6eb7c.zip
CMake-6fa36470239a40ef81752ddea923d8618ad6eb7c.tar.gz
CMake-6fa36470239a40ef81752ddea923d8618ad6eb7c.tar.bz2
ctest: Add support for '--prefix=<prefix>' form of the argument
The main `cmake --preset` argument for configure presets supports both forms, so support it for `ctest --preset` too. Fixes: #21855
-rw-r--r--Help/manual/ctest.1.rst2
-rw-r--r--Source/cmCTest.cxx10
-rw-r--r--Source/ctest.cxx3
-rw-r--r--Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake12
4 files changed, 21 insertions, 6 deletions
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 0a3614f..175359d 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -30,7 +30,7 @@ This program will run the tests and report results.
Options
=======
-``--preset <preset>``
+``--preset <preset>``, ``--preset=<preset>``
Use a test preset to specify test options. The project binary directory
is inferred from the ``configurePreset`` key. The current working directory
must contain CMake preset files.
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index e8d7c05..620ba19 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2574,7 +2574,10 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
bool listPresets =
find(args.begin(), args.end(), "--list-presets") != args.end();
- auto it = find(args.begin(), args.end(), "--preset");
+ auto it =
+ std::find_if(args.begin(), args.end(), [](std::string const& arg) -> bool {
+ return arg == "--preset" || cmHasLiteralPrefix(arg, "--preset=");
+ });
if (listPresets || it != args.end()) {
std::string errormsg;
bool success;
@@ -2583,7 +2586,10 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// If listing presets we don't need a presetName
success = this->SetArgsFromPreset("", listPresets);
} else {
- if (++it != args.end()) {
+ if (cmHasLiteralPrefix(*it, "--preset=")) {
+ auto presetName = it->substr(9);
+ success = this->SetArgsFromPreset(presetName, listPresets);
+ } else if (++it != args.end()) {
auto presetName = *it;
success = this->SetArgsFromPreset(presetName, listPresets);
} else {
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 1404b0c..3c331d3 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -26,7 +26,8 @@ static const char* cmDocumentationUsage[][2] = { { nullptr,
{ nullptr, nullptr } };
static const char* cmDocumentationOptions[][2] = {
- { "--preset <preset>", "Read arguments from a test preset." },
+ { "--preset <preset>, --preset=<preset>",
+ "Read arguments from a test preset." },
{ "--list-presets", "List available test presets." },
{ "-C <cfg>, --build-config <cfg>", "Choose configuration to test." },
{ "--progress", "Enable short progress output from tests." },
diff --git a/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake
index 6360fc2..4ffdfab 100644
--- a/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake
@@ -51,6 +51,7 @@ function(run_cmake_test_presets name CMakePresetsTest_CONFIGURE_PRESETS CMakePre
endforeach()
endif()
+ set(eq 0)
foreach(TEST_PRESET ${CMakePresetsTest_TEST_PRESETS})
if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-test-${TEST_PRESET}-check.cmake")
set(RunCMake-check-file "${name}-test-${TEST_PRESET}-check.cmake")
@@ -58,8 +59,15 @@ function(run_cmake_test_presets name CMakePresetsTest_CONFIGURE_PRESETS CMakePre
set(RunCMake-check-file "check.cmake")
endif()
- run_cmake_command(${name}-test-${TEST_PRESET}
- ${CMAKE_CTEST_COMMAND} "--preset" "${TEST_PRESET}" ${ARGN})
+ if(eq)
+ run_cmake_command(${name}-test-${TEST_PRESET}
+ ${CMAKE_CTEST_COMMAND} "--preset=${TEST_PRESET}" ${ARGN})
+ set(eq 0)
+ else()
+ run_cmake_command(${name}-test-${TEST_PRESET}
+ ${CMAKE_CTEST_COMMAND} "--preset" "${TEST_PRESET}" ${ARGN})
+ set(eq 1)
+ endif()
endforeach()
endfunction()