Vcpkg: Prefer environment variable over executable path

The executable can be in a different directory.

Change-Id: Ie630d464734d1ef9d0a9e1adfb8da8e56c67b5dd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Marco Bubke
2024-07-27 18:40:55 +02:00
parent 09322f4014
commit ab7225c6d2

View File

@@ -35,10 +35,12 @@ VcpkgSettings::VcpkgSettings()
vcpkgRoot.setSettingsKey("VcpkgRoot");
vcpkgRoot.setExpectedKind(PathChooser::ExistingDirectory);
FilePath defaultPath = Environment::systemEnvironment().searchInPath(Constants::VCPKG_COMMAND)
.parentDir();
FilePath defaultPath = FilePath::fromUserInput(
qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT));
if (!defaultPath.isDir())
defaultPath = FilePath::fromUserInput(qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT));
defaultPath = Environment::systemEnvironment().searchInPath(Constants::VCPKG_COMMAND).parentDir();
if (defaultPath.isDir())
vcpkgRoot.setDefaultPathValue(defaultPath);