summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-10-07 13:11:31 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-10-07 13:11:48 (GMT)
commit5b7ab1818bc5f5cb26e46f611fb2607bf42e8aca (patch)
tree4adb579d41994d596bc85592b0b720f836161d00
parent9a14348a2c2816569a1d8f873f2b9e6da37aacc6 (diff)
parentb80aa1d3a3ba1ad351ad57c42361408a72f7254d (diff)
downloadCMake-5b7ab1818bc5f5cb26e46f611fb2607bf42e8aca.zip
CMake-5b7ab1818bc5f5cb26e46f611fb2607bf42e8aca.tar.gz
CMake-5b7ab1818bc5f5cb26e46f611fb2607bf42e8aca.tar.bz2
Merge topic 'cmake--workflow-preset'
b80aa1d3a3 preset: Easier command line interface for Workflow Presets Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: scivision <michael@scivision.dev> Merge-request: !9866
-rw-r--r--Help/manual/cmake.1.rst13
-rw-r--r--Help/release/dev/cmake--workflow-preset.rst6
-rw-r--r--Source/cmakemain.cxx7
-rw-r--r--Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt2
-rw-r--r--Tests/RunCMake/CMakePresetsWorkflow/MultiplePresets.json.in41
-rw-r--r--Tests/RunCMake/CMakePresetsWorkflow/RepeatedPresetArg.cmake3
-rw-r--r--Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/CMakePresetsWorkflow/SinglePresetArg.cmake3
8 files changed, 81 insertions, 5 deletions
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 586a72e..4610e11 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -31,7 +31,7 @@ Synopsis
cmake --find-package [<options>]
`Run a Workflow Preset`_
- cmake --workflow [<options>]
+ cmake --workflow <options>
`View Help`_
cmake --help[-<topic>]
@@ -1394,7 +1394,7 @@ build steps in order:
.. code-block:: shell
- cmake --workflow [<options>]
+ cmake --workflow <options>
The options are:
@@ -1411,6 +1411,15 @@ The options are:
must contain CMake preset files.
See :manual:`preset <cmake-presets(7)>` for more details.
+ .. versionchanged:: 3.31
+ When following immediately after the ``--workflow`` option,
+ the ``--preset`` argument can be omitted and just the ``<preset>``
+ name can be given. This means the following syntax is valid:
+
+ .. code-block:: console
+
+ $ cmake --workflow my-preset
+
.. option:: --list-presets
Lists the available workflow presets. The current working directory must
diff --git a/Help/release/dev/cmake--workflow-preset.rst b/Help/release/dev/cmake--workflow-preset.rst
new file mode 100644
index 0000000..2e07eb9
--- /dev/null
+++ b/Help/release/dev/cmake--workflow-preset.rst
@@ -0,0 +1,6 @@
+cmake--workflow-preset
+----------------------
+
+* When executing a CMake workflow preset, the ``--preset`` option can now be
+ omitted, allowing the simpler command line
+ :option:`cmake --workflow \<preset\> <cmake--workflow --preset>`.
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 804f5ef..b57cdb3 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -1039,6 +1039,11 @@ int do_workflow(int ac, char const* const* av)
break;
}
}
+ if (!matched && i == 0) {
+ inputArgs.insert(inputArgs.begin(), "--preset");
+ matched = true;
+ parsed = arguments[0].parse("--preset", i, inputArgs);
+ }
if (!(matched && parsed)) {
if (!matched) {
presetName.clear();
@@ -1052,7 +1057,7 @@ int do_workflow(int ac, char const* const* av)
if (presetName.empty() && listPresets == WorkflowListPresets::No) {
/* clang-format off */
std::cerr <<
- "Usage: cmake --workflow [options]\n"
+ "Usage: cmake --workflow <options>\n"
"Options:\n"
" --preset <preset> = Workflow preset to execute.\n"
" --list-presets = List available workflow presets.\n"
diff --git a/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt
index 049ff54..8e23c9b 100644
--- a/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt
+++ b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt
@@ -1,5 +1,5 @@
^Unknown argument -DINVALID_OPTION
-Usage: cmake --workflow \[options\]
+Usage: cmake --workflow <options>
Options:
--preset <preset> = Workflow preset to execute\.
--list-presets = List available workflow presets\.
diff --git a/Tests/RunCMake/CMakePresetsWorkflow/MultiplePresets.json.in b/Tests/RunCMake/CMakePresetsWorkflow/MultiplePresets.json.in
new file mode 100644
index 0000000..9e7dcb8
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsWorkflow/MultiplePresets.json.in
@@ -0,0 +1,41 @@
+{
+ "version": 6,
+ "configurePresets": [
+ {
+ "name": "SinglePresetArg",
+ "generator": "@RunCMake_GENERATOR@",
+ "cacheVariables":
+ {
+ "WORKFLOW_PRESET": "SinglePresetArg"
+ }
+ },
+ {
+ "name": "RepeatedPresetArg",
+ "generator": "@RunCMake_GENERATOR@",
+ "cacheVariables":
+ {
+ "WORKFLOW_PRESET": "RepeatedPresetArg"
+ }
+ }
+ ],
+ "workflowPresets": [
+ {
+ "name": "SinglePresetArg",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "SinglePresetArg"
+ }
+ ]
+ },
+ {
+ "name": "RepeatedPresetArg",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "RepeatedPresetArg"
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresetsWorkflow/RepeatedPresetArg.cmake b/Tests/RunCMake/CMakePresetsWorkflow/RepeatedPresetArg.cmake
new file mode 100644
index 0000000..b508d1c
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsWorkflow/RepeatedPresetArg.cmake
@@ -0,0 +1,3 @@
+if(WORKFLOW_PRESET STREQUAL "RepeatedPresetArg")
+ message(FATAL_ERROR "First preset argument used instead of repeated preset argument")
+endif()
diff --git a/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake
index 550600a..8c1002d 100644
--- a/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake
@@ -45,7 +45,9 @@ function(run_cmake_workflow_presets name)
set(RunCMake-check-file "check.cmake")
endif()
- if(eq)
+ if(CMakePresets_DIRECT_ARG)
+ set(preset_arg "${name}")
+ elseif(eq)
set(eq 0 PARENT_SCOPE)
set(preset_arg "--preset=${name}")
else()
@@ -87,3 +89,10 @@ file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/Fresh/build")
file(WRITE "${RunCMake_BINARY_DIR}/Fresh/build/CMakeCache.txt" "FRESH_CONFIGURE:BOOL=OFF\n")
run_cmake_workflow_presets(Fresh --fresh)
unset(RunCMake_TEST_NO_CLEAN)
+
+set(CMakePresets_DIRECT_ARG TRUE)
+set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/MultiplePresets.json.in")
+run_cmake_workflow_presets(SinglePresetArg)
+run_cmake_workflow_presets(RepeatedPresetArg --preset SinglePresetArg)
+unset(CMakePresets_FILE)
+unset(CMakePresets_DIRECT_ARG)
diff --git a/Tests/RunCMake/CMakePresetsWorkflow/SinglePresetArg.cmake b/Tests/RunCMake/CMakePresetsWorkflow/SinglePresetArg.cmake
new file mode 100644
index 0000000..13b754a
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsWorkflow/SinglePresetArg.cmake
@@ -0,0 +1,3 @@
+if(NOT WORKFLOW_PRESET STREQUAL "SinglePresetArg")
+ message(FATAL_ERROR "Expected 'SinglePresetArg' workflow preset, but actual value is ${WORKFLOW_PRESET}")
+endif()