presets: penv should use the environment from `inherits`, not directly using the parent process environment
$env{<variable-name>}
Environment variable with name <variable-name>. The variable name may not be an empty string. If the variable is defined in the environment field, that value is used instead of the value from the parent environment. If the environment variable is not defined, this evaluates as an empty string.
Note that while Windows environment variable names are case-insensitive, variable names within a preset are still case-sensitive. This may lead to unexpected results when using inconsistent casing. For best results, keep the casing of environment variable names consistent.
The document didn't define what's the parent environment means, but from practice usage, it's better
interpret parent environment
as the environment comes from the inherits when inherits exist, otherwise using the current process environment
For example:
By interpret parent environment
as inherits environment
,
the following presets should works
{
"name": "vs2015",
"inherits": "windows-only",
"environment": {
"INCLUDE": "$env{VS2015}\\VC\\INCLUDE;$env{VS2015}\\VC\\ATLMFC\\INCLUDE;$env{WINDOWS_KITS}\\include\\$env{WINDOWS_KIT_VERSION}\\ucrt;$env{WINDOWS_KITS}\\include\\$env{WINDOWS_KIT_VERSION}\\shared;$env{WINDOWS_KITS}\\include\\$env{WINDOWS_KIT_VERSION}\\um;$env{WINDOWS_KITS}\\include\\$env{WINDOWS_KIT_VERSION}\\winrt;",
"PATH": "$env{VS2015}\\Common7\\IDE\\;$env{VS2015}\\VC\\BIN;$env{VS2015}\\Common7\\Tools;C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319;$env{CMAKE_PROGRAM_FILES_X86}\\HTML Help Workshop;$env{WINDOWS_KITS}\\bin\\$env{WINDOWS_KIT_VERSION}\\x86;$env{WINDOWS_KITS}\\bin\\x86;$penv{PATH}",
"LIB":"$env{VS2015}\\VC\\LIB;$env{VS2015}\\VC\\ATLMFC\\LIB;$env{WINDOWS_KITS}\\lib\\$env{WINDOWS_KIT_VERSION}\\ucrt\\x86;$env{WINDOWS_KITS}\\lib\\$env{WINDOWS_KIT_VERSION}\\um\\x86;",
"LIBPATH":"C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319;$env{VS2015}\\VC\\LIB;$env{VS2015}\\VC\\ATLMFC\\LIB;$env{WINDOWS_KITS}\\UnionMetadata;$env{WINDOWS_KITS}\\References;\\Microsoft.VCLibs\\14.0\\References\\CommonConfiguration\\neutral;"
}
},
{
"name": "vs2015-qt",
"inherits": "vs2015",
"environment": {
"QTDIR": "C:\\Qt\\Qt5.9.9\\5.9.9\\msvc2015",
"PATH": "$env{QTDIR}\\bin;$penv{PATH}"
}
}