diff options
-rw-r--r-- | Help/manual/ctest.1.rst | 2 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 10 | ||||
-rw-r--r-- | Source/ctest.cxx | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake | 12 |
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() |