I have run into an issue regarding using environment variables in CMakePresets.json to set the CMAKE_TOOLCHAIN_FILE to the vcpkg folder. I have set an environment system variable VCPKG_ROOT to D:/Apps/vcpkg/vcpkg.
My CMakePresets.json looks like this:
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}
When I try to build the project with CMakeTools, I get the following error message: [cmake] Could not find toolchain file: /scripts/buildsystems/vcpkg.cmake
If I use the full path, D:/Apps/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake, the build succeeds.
Does anyone have an idea why the environment variable is treated as empty? I also tried using $env:VCPKG_ROOT, $VCPKG_ROOT, ${VCPKG_ROOT} to no success.
I got the CMakePresets.json file from the Microsoft vcpkg and VS Code guide
It is not a huge problem but I would still like to know the cause of the issue. Thank you in advance!