forked from qt-creator/qt-creator
vcpkg: Fix usage with Visual C++ 2022
Visual Studio 2022 comes with their own vcpkg and sets the VCPKG_ROOT as part of the 'vcvars.bat' environment. This change makes sure that the 'vcpkg' program specified by the vcpkg plugin is being used. Change-Id: I582a54ed615a2ad8f47814736d4e6dddad9f50cd Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -2086,6 +2086,13 @@ CMakeBuildSystem *CMakeBuildConfiguration::cmakeBuildSystem() const
|
||||
|
||||
void CMakeBuildConfiguration::addToEnvironment(Utils::Environment &env) const
|
||||
{
|
||||
// Use the user provided VCPKG_ROOT if existing
|
||||
// Visual C++ 2022 (and newer) come with their own VCPKG_ROOT
|
||||
// that is incompatible with Qt Creator
|
||||
const QString vcpkgRoot = qtcEnvironmentVariable(Constants::VCPKG_ROOT);
|
||||
if (!vcpkgRoot.isEmpty())
|
||||
env.set(Constants::VCPKG_ROOT, vcpkgRoot);
|
||||
|
||||
const CMakeTool *tool = CMakeKitAspect::cmakeTool(kit());
|
||||
// The hack further down is only relevant for desktop
|
||||
if (tool && tool->cmakeExecutable().needsDevice())
|
||||
|
@@ -27,6 +27,7 @@ const char CMAKEFORMATTER_MENU_ID[] = "CMakeFormatter.Menu";
|
||||
const char CMAKE_DEBUGGING_GROUP[] = "Debugger.Group.CMake";
|
||||
|
||||
const char PACKAGE_MANAGER_DIR[] = ".qtc/package-manager";
|
||||
const char VCPKG_ROOT[] = "VCPKG_ROOT";
|
||||
|
||||
const char CMAKE_LISTS_TXT[] = "CMakeLists.txt";
|
||||
const char CMAKE_CACHE_TXT[] = "CMakeCache.txt";
|
||||
|
@@ -199,7 +199,10 @@ macro(qtc_auto_setup_vcpkg)
|
||||
if (EXISTS "${CMAKE_SOURCE_DIR}/vcpkg.json" AND NOT QT_CREATOR_SKIP_VCPKG_SETUP)
|
||||
option(QT_CREATOR_SKIP_VCPKG_SETUP "Skip Qt Creator's vcpkg package manager auto-setup" OFF)
|
||||
|
||||
find_program(vcpkg_program vcpkg $ENV{VCPKG_ROOT} ${CMAKE_SOURCE_DIR}/vcpkg)
|
||||
find_program(vcpkg_program vcpkg
|
||||
PATHS $ENV{VCPKG_ROOT} ${CMAKE_SOURCE_DIR}/vcpkg
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT vcpkg_program)
|
||||
message(WARNING "Qt Creator: vcpkg executable not found. "
|
||||
"Package manager auto-setup will be skipped. "
|
||||
|
Reference in New Issue
Block a user