Condition field for workflow presets

Workflows presets don’t currently have a condition field, which is unfortunate. Some workflows may consist of platform-specific presets, such as building for XCode or Visual Studio.

I suggest either:

  • giving workflow presets a condition field
  • calculating which workflow presets are unavailable based on each step preset’s condition(s)
1 Like

The former makes more sense to me. Maybe one wants to skip a step in some situation (e.g., testing for clang-tidy?) and having to do a new workflow for that seems a bit unfortunate.

1 Like

Having a workflow silently skip steps for which a condition is false seems attractive at first, but I would have concerns about the robustness of that. Giving workflow presets as a whole a condition field would be less risky.

1 Like

If workflows are going to allow but skip steps that have false conditions, then I would suggest that CMake exits with a success code if at least the configure preset had a true condition, and exits with a failure code otherwise.

IMHO: It is a bug, if the workflow preset does not inherit the condition of its configure preset:

bash-3.2$ cmake --workflow --list-presets
Available workflow presets:

  "windows-clang-debug"
  "windows-clang-release"
  "clang-debug"
  "clang-release"
  "gcc-debug"
  "gcc-release"
bash-3.2$ cmake --list-presets
Available configure presets:

  "gcc-debug"     - gcc Debug
  "gcc-release"   - gcc Release
  "clang-debug"   - clang Debug
  "clang-release" - clang Release
bash-3.2$ cmake --workflow --preset=windows-clang-debug
CMake Error: Cannot use disabled configure preset in /Users/clausklein/Workspace/cmake/project_options/examples/cpp_vcpkg_project: "windows-clang-debug"
bash-3.2$ 
1 Like

A conditionally disabled preset should be allowed to have a duplicate name

bash-3.2$ !json
jsonschema -i CMakePresets.json schema.json 
bash-3.2$ jsonschema -i CMakePresets.json schema.json 
bash-3.2$ cmake --workflow --list-presets
CMake Error: Could not read presets from /Users/clausklein/Workspace/cmake/project_options/examples/cpp_vcpkg_project:
Duplicate preset: "clang-install"
bash-3.2$ 

That would help to write simple and clear CMakePresets.json.

1 Like

@craig.scott @ben.boeckel Is it planed to change this behaviour?

I’m not that familiar with presets. @kyle.edwards would know more.

see too Presets - conditional config

I have created an issue

1 Like

I used a Workaround possible with cmake preset schema version 9

see