vscode-cmake-tools
                                
                                 vscode-cmake-tools copied to clipboard
                                
                                    vscode-cmake-tools copied to clipboard
                            
                            
                            
                        Use environment variables from cmake.[configure]environment when loading CMakePresets
Brief Issue Summary
In Version 7 the includes allow to use of $penv{} macro expansion.
However, the environment variables defined in cmake.environment or cmake.configureEnvironment are not expanded there. Environment variables defined before starting vscode are expanded.
I have tried this with the latest pre-release version.
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response
@tnixeu To confirm, what you are requesting is that in your Preset, you would like the cmake.environment and the cmake.configureEnvironment to be included in the penv context when the include field uses the $penv{} macro expansion?
Currently, this is not supported as we view the cmake.environment being used during Presets to be a more temporary measure, environment settings that are added to your environment when doing various commands like configure, etc.
However, this is a valid request to be made, so we can open it up to the community to upvote. Also, could you help us understand your use case for this more?
Thank you so much for your input!
@gcampbell-msft Yes this what I had in mind.
I am currently using a variable in the include field in order to change which CMakeUserPreset.txt is loaded. They have have gotten to big to not check them in somewhere. However, I can not check it into the source directory directly, because it would be loaded in the CI environment or on a colleagues machine.
@gcampbell-msft This seems to be related to #1836 and #3537. First of all, thank you so much for taking care of that issue!
However, I am still not able to override parts of the parent environment:
- Parent environment
SOME_PREFIX_PATH=<some/prefix/path>
- .vscode/settings.json
{
  "cmake.environment": {  // same for configureEnvironment
    "SOME_PREFIX_PATH": "<some/prefix/override>"
  }
}
- CMakePresets.json
...
"configurePresets": [
  ...
  "cacheVariables": {
    "CMAKE_PREFIX_PATH": "$penv{SOME_PREFIX_PATH}"  // same for $env
  }
  ...
- CMake configure
[driver] NOTE: You are configuring with preset Development Config, but there are some overrides being applied from your VS Code settings.
[proc] Executing command: /usr/bin/cmake ... "-DCMAKE_PREFIX_PATH=<some/prefix/path>" ...
- CMakeLists.txt
message(STATUS "SOME_PREFIX_PATH=$ENV{SOME_PREFIX_PATH}")
# [cmake] -- SOME_PREFIX_PATH=<some/prefix/override>
So it seems that the override from the folder settings sadly does not work for the preset.
configureEnvironment or $env do not work either.
However, CMake still picks up the overridden env variable in 5, although CMakeTools does not pick it up.