presets: add --config command line argument to workflow
Currently there is no way to pass configuration type to build/tests/package presets in case cmake --workflow
command or environment variable.
None of theres environment variables have an effect (unless it is a bug):
- CMAKE_BUILD_TYPE
- CMAKE_CONFIG_TYPE
Also cmake --workflow
command does not accept any additional arguments like -D
.
This limits use case of Ninja Multi-Config generator in configurePresets
because:
- testPresets requires explicitly set
configuration
field otherwise:Test not available without configuration. (Missing "-C <config>"?)
- packagePresets requires explicitly set
configurations
otherwise it will always tries to assume Release.
So once you set these fields then you are not able to change them and you have to duplicate all build/test/pack presets. This makes Ninja Multi-Config as Ninja generator.
Propose solution:
Add --config <cfg>
command line argument to cmake --workflow
.
cmake --workflow --preset <name> --config <cfg>
cmake --workflow --preset default --config Debug
It could be used in two ways:
- If a configure preset uses Ninja Multi-Config generator then
- pass
--config <cfg>
to a build command - pass
-C <cfg>
to a test command - pass `-C to a package command
- pass
- If a configure preset uses non Multi-Config generator then
- pass
-DCMAKE_BUILD_TYPE=<cfg>
to a build command
- pass
Edited by Mikhail Svetkin