The VCPKG_LOAD_VCVARS_ENV
option cannot be used to disable vcvars loading
#40480
Labels
category:vcpkg-bug
The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)
Describe the bug
If you set the
VCPKG_LOAD_VCVARS_ENV
to false, then vcpkg will still launch a VS Command prompt to get the vcvars environment.Environment
To Reproduce
Steps to reproduce the behavior:
set(VCPKG_LOAD_VCVARS_ENV OFF)
. For example:PATH
, noLIB
env var set, etc.Expected behavior
vcpkg/CMake complains that it can't find a compiler.
Additional context
The bug occurs when vcpkg uses the value
load_vcvars_env
which is set byVCPKG_LOAD_VCVARS_ENV
:If there is no external toolchain file (
VCPKG_CHAINLOAD_TOOLCHAIN_FILE
is not set) then!external_toolchain_file.has_value()
istrue
and so the value ofload_vcvars_env
is ignored, thusVCPKG_LOAD_VCVARS_ENV
cannot be used to disable vcvargs loading.It could, however, be used to re-enable vcvars loading if
VCPKG_CHAINLOAD_TOOLCHAIN_FILE
was set - but that's not what the documentation indicates it does: "Determines whether vcpkg will search for and use an instance of Visual Studio as part of the triplet environment."For anyone who came across this issue looking for a way to disable vcvars loading WITHOUT using a custom toolchain file, the workaround is to add
set(VCPKG_CMAKE_SYSTEM_NAME Windows)
to your triplet.It should be noted that changing the behavior now would be a breaking change, which I'm not sure how vcpkg handles.
The text was updated successfully, but these errors were encountered: