presets: Preset activation status inheritance
Trying to minimise the combinatorial explosion described at #22538, I was thinking of using multi-inheritance on conditional presets, hoping that the parent downstream preset would only inherit fields from non-disabled upstream presets.
Given the following CMakePresets.json
snippet:
"configurePresets": [
{
"hidden": true,
"name": "linux-build",
"toolchainFile": "linux-toolchain.cmake",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"hidden": true,
"name": "windows-build",
"toolchainFile": "windows-toolchain.cmake",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "release-build",
"displayName": "Release Build",
"inherits": [
"linux-build",
"windows-build",
"first-option",
"second-option"
]
}
With CMake 3.26.3, it seems like release-build
activation status always evaluates to its first inherited status, here linux-build
activation status. I'm not sure if that behavior is documented at cmake-presets
. I guess the following somehow gives it credence:
If multiple inherits presets provide conflicting values for the same field, the earlier preset in the inherits array will be preferred.
But I think it would be a lot more useful to have the activation status a given downstream preset be computed from the status of all its upsteam ones (deactivating it only if all its upstream presets are themself deactivated). Meaning here that:
status("release-build") = status("linux-build") OR status("windows-build") OR status("first-option") OR status("second-option")
And of course release-build
would only inherit fields from active presets!