presets: Add condition support for environment variables and cache variables and all non 'condition' preset variables
{
"hidden": [
{
"condition": {
"type": "equals",
"lhs": "$env{PROCESSOR_ARCHITECTURE}",
"rhs": "AMD64"
},
"value": true
},
{
"condition": {
"type": "notEquals",
"lhs": "$env{PROCESSOR_ARCHITECTURE}",
"rhs": "AMD64"
},
"value": false
}
],
"name": "program_files_x86",
"cacheVariables": {
"BUILD_TESTING": [
{
"condition": {
"type": "equals",
"lhs": "$env{PROCESSOR_ARCHITECTURE}",
"rhs": "AMD64"
},
"value": "ON"
},
{
"condition": {
"type": "notEquals",
"lhs": "$env{PROCESSOR_ARCHITECTURE}",
"rhs": "AMD64"
},
"value": "OFF"
}
]
},
"environment": {
"CMAKE_PROGRAM_FILES_X86": [
{
"condition": {
"type": "equals",
"lhs": "$env{PROCESSOR_ARCHITECTURE}",
"rhs": "AMD64"
},
"value": "$env{ProgramFiles(x86)}"
},
{
"condition": {
"type": "notEquals",
"lhs": "$env{PROCESSOR_ARCHITECTURE}",
"rhs": "AMD64"
},
"value": "$env{ProgramFiles}"
}
]
}
}
By using this, we can evaluate environment variable CMAKE_PROGRAM_FILES_X86 properly。 Should also take care of #22523
For general usage, I thinks all variables except "condition" should support "condition"。 That's is
"name": string,
"hidden": boolean,
"inherits": string | string[],
"vendor": string,
"displayName": string,
"description": string,
"generator": string,
"architecture": string,
"toolset": string,
"toolchainFile": string,
"binaryDir": string,
"installDir": string,
"cmakeExecutable": string,
"cacheVariables": {},
"environment": {},
"warnings": {},
"errors": {},
"debug": {},
And also for build/test may have more variables。
The reason to add condition on each cache variables
and environment variables
is for easily merge those variables.
For final macro expansion.
Edited by Yonggang Luo