mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
Merge topic 'preset-flag-consistency' into release-3.20
6fa3647023ctest: Add support for '--prefix=<prefix>' form of the argument3357d37761cmake: Add support for '--build --prefix=<prefix>' form of the argument2f13fdef0acmake: Document '--preset <preset>' form of the argument Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5849
This commit is contained in:
@@ -377,7 +377,7 @@ Options
|
||||
about:tracing tab of Google Chrome or using a plugin for a tool like Trace
|
||||
Compass.
|
||||
|
||||
``--preset=<preset>``
|
||||
``--preset <preset>``, ``--preset=<preset>``
|
||||
Reads a :manual:`preset <cmake-presets(7)>` from
|
||||
``<path-to-source>/CMakePresets.json`` and
|
||||
``<path-to-source>/CMakeUserPresets.json``. The preset specifies the
|
||||
@@ -416,7 +416,7 @@ following options:
|
||||
Project binary directory to be built. This is required (unless a preset
|
||||
is specified) and must be first.
|
||||
|
||||
``--preset <preset>``
|
||||
``--preset <preset>``, ``--preset=<preset>``
|
||||
Use a build preset to specify build options. The project binary directory
|
||||
is inferred from the ``configurePreset`` key. The current working directory
|
||||
must contain CMake preset files.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -64,7 +64,7 @@ const char* cmDocumentationUsageNote[][2] = {
|
||||
|
||||
const char* cmDocumentationOptions[][2] = {
|
||||
CMAKE_STANDARD_OPTIONS_TABLE,
|
||||
{ "--preset=<preset>", "Specify a configure preset." },
|
||||
{ "--preset <preset>,--preset=<preset>", "Specify a configure preset." },
|
||||
{ "--list-presets", "List available presets." },
|
||||
{ "-E", "CMake command mode." },
|
||||
{ "-L[A][H]", "List non-advanced cached variables." },
|
||||
@@ -511,6 +511,7 @@ int do_build(int ac, char const* const* av)
|
||||
bool hasPreset = false;
|
||||
for (int i = 2; i < ac; ++i) {
|
||||
if (strcmp(av[i], "--list-presets") == 0 ||
|
||||
cmHasLiteralPrefix(av[i], "--preset=") ||
|
||||
strcmp(av[i], "--preset") == 0) {
|
||||
hasPreset = true;
|
||||
break;
|
||||
@@ -584,7 +585,7 @@ int do_build(int ac, char const* const* av)
|
||||
"Usage: cmake --build [<dir> | --preset <preset>] [options] [-- [native-options]]\n"
|
||||
"Options:\n"
|
||||
" <dir> = Project binary directory to be built.\n"
|
||||
" --preset <preset>\n"
|
||||
" --preset <preset>, --preset=<preset>\n"
|
||||
" = Specify a build preset.\n"
|
||||
" --list-presets\n"
|
||||
" = List available build presets.\n"
|
||||
|
||||
@@ -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." },
|
||||
|
||||
@@ -128,7 +128,13 @@
|
||||
{
|
||||
"name": "Good Spaces",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"binaryDir": "${sourceDir}/build"
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"GOOD_SPACES": {
|
||||
"type": "STRING",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "GoodWindowsBackslash",
|
||||
|
||||
3
Tests/RunCMake/CMakePresets/GoodSpaces-stdout.txt
Normal file
3
Tests/RunCMake/CMakePresets/GoodSpaces-stdout.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
Preset CMake variables:
|
||||
|
||||
GOOD_SPACES:STRING="1"
|
||||
3
Tests/RunCMake/CMakePresets/GoodSpacesEq-stdout.txt
Normal file
3
Tests/RunCMake/CMakePresets/GoodSpacesEq-stdout.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
Preset CMake variables:
|
||||
|
||||
GOOD_SPACES:STRING="1"
|
||||
0
Tests/RunCMake/CMakePresets/GoodSpacesEq.cmake
Normal file
0
Tests/RunCMake/CMakePresets/GoodSpacesEq.cmake
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,2 @@
|
||||
^CMake Error: No preset specified for --preset
|
||||
CMake Error: Run 'cmake --help' for all supported options.$
|
||||
@@ -144,7 +144,8 @@ run_cmake_presets(GoodBinaryUp)
|
||||
set(CMakePresets_SOURCE_ARG "../GoodBinaryRelative")
|
||||
run_cmake_presets(GoodBinaryRelative)
|
||||
unset(CMakePresets_SOURCE_ARG)
|
||||
run_cmake_presets(GoodSpaces "--preset=Good Spaces")
|
||||
run_cmake_presets(GoodSpaces "--preset" "Good Spaces")
|
||||
run_cmake_presets(GoodSpacesEq "--preset=Good Spaces")
|
||||
if(WIN32)
|
||||
run_cmake_presets(GoodWindowsBackslash)
|
||||
endif()
|
||||
@@ -207,7 +208,8 @@ endif()
|
||||
|
||||
# Test bad command line arguments
|
||||
run_cmake_presets(NoSuchPreset)
|
||||
run_cmake_presets(NoPresetArgument --preset=)
|
||||
run_cmake_presets(NoPresetArgument --preset)
|
||||
run_cmake_presets(NoPresetArgumentEq --preset= -DA=B)
|
||||
run_cmake_presets(UseHiddenPreset)
|
||||
|
||||
# Test CMakeUserPresets.json
|
||||
|
||||
@@ -40,6 +40,7 @@ function(run_cmake_build_presets name CMakePresetsBuild_CONFIGURE_PRESETS CMakeP
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(eq 0)
|
||||
foreach(BUILD_PRESET ${CMakePresetsBuild_BUILD_PRESETS})
|
||||
if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-build-${BUILD_PRESET}-check.cmake")
|
||||
set(RunCMake-check-file "${name}-build-${BUILD_PRESET}-check.cmake")
|
||||
@@ -47,8 +48,15 @@ function(run_cmake_build_presets name CMakePresetsBuild_CONFIGURE_PRESETS CMakeP
|
||||
set(RunCMake-check-file "check.cmake")
|
||||
endif()
|
||||
|
||||
run_cmake_command(${name}-build-${BUILD_PRESET}
|
||||
${CMAKE_COMMAND} "--build" "--preset" "${BUILD_PRESET}" ${ARGN})
|
||||
if(eq)
|
||||
run_cmake_command(${name}-build-${BUILD_PRESET}
|
||||
${CMAKE_COMMAND} "--build" "--preset=${BUILD_PRESET}" ${ARGN})
|
||||
set(eq 0)
|
||||
else()
|
||||
run_cmake_command(${name}-build-${BUILD_PRESET}
|
||||
${CMAKE_COMMAND} "--build" "--preset" "${BUILD_PRESET}" ${ARGN})
|
||||
set(eq 1)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user