request: workflow presets: allow "-D" options
For CMake 3.25's new --workflow
option, a design decision was made to generally disallow setting of any variables using the typical "-Dopt=on" or "--install-prefix" CMake configure syntax.
In general, the CMakePresets.json fanout to cover all those test cases would be impractical vs. simply using '-Dopt' as works with non-workflow presets.
A workaround below has the caveat that one must watch that the configure options aren't overridden by workflow configure presets, perhaps defeating a key advantage of workflows:
cmake --preset default -Dopt=true
cmake --workflow --preset default
Possible feature upgrades to CMake workflows would be:
- if '-D' options are to remain disallowed for
--workflow
, make the "configure" workflow step not mandatory if a configuration can be inherited from the first workflow step e.g. build preset that has a configurePreset. This has the disadvantage of requiring the configure step be a separate command. Always at least two commands to configure, build and test. - allow '-D' options: this allows a big advantage of workflows: a single command for configure, build, test. I wouldn't mind if "-D" had to be before "--workflow" if that makes the CMake command line parsing better. This "-D" first restriction is already so when using
cmake -Dopt=true -P script.cmake
and that's fine.
in CMakePresets.json, one must watch to not override options given in the first configure step by the workflow configure step, since workflows mandate a configure step be used in the workflow.
{
"version": 6,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "error"
}
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
},
{
"type": "test",
"name": "default"
}
]
}
]
}