Adding conditions and macros
When we discussed the general fields for each stage-specific preset, we mentioned the condition
field. It’s time to return to that subject. The condition field enables or disables a preset, revealing its true potential when integrated with workflows. Essentially, it allows us to bypass presets that aren’t suitable under certain conditions and create alternative presets that are.
Conditions require preset schema version 3 or above (introduced in CMake 3.22) and are JSON objects that codify a few simple logical operations that can determine whether circumstances, like used OS, environment variables, or even chosen generators, fit the scenario of a preset. CMake provides this data through macros, which are essentially a limited set of read-only variables usable in the preset file.
The structure of a condition object varies based on the check type. Each condition must include a type
field and additional fields as defined by the type....