forked from qt-creator/qt-creator
vcpkg: Set VCPKG_ROOT environment variable for Qt Creator process
This way CMakeProjectManager's auto-setup.cmake would pick it up and find vcpkg.exe Change-Id: Iafa84f13e0f50321ce771fc687ecc9e2df148de7 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include "vcpkg_test.h"
|
#include "vcpkg_test.h"
|
||||||
#endif // WITH_TESTS
|
#endif // WITH_TESTS
|
||||||
#include "vcpkgmanifesteditor.h"
|
#include "vcpkgmanifesteditor.h"
|
||||||
|
#include "vcpkgsettings.h"
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
@@ -35,6 +36,8 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void extensionsInitialized() final { settings().setVcpkgRootEnvironmentVariable(); }
|
||||||
|
|
||||||
std::unique_ptr<VcpkgPluginPrivate> d;
|
std::unique_ptr<VcpkgPluginPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ VcpkgSettings::VcpkgSettings()
|
|||||||
if (defaultPath.isDir())
|
if (defaultPath.isDir())
|
||||||
vcpkgRoot.setDefaultValue(defaultPath.toUserOutput());
|
vcpkgRoot.setDefaultValue(defaultPath.toUserOutput());
|
||||||
|
|
||||||
|
connect(this, &AspectContainer::applied, this, &VcpkgSettings::setVcpkgRootEnvironmentVariable);
|
||||||
|
|
||||||
setLayouter([this] {
|
setLayouter([this] {
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
auto websiteButton = new QToolButton;
|
auto websiteButton = new QToolButton;
|
||||||
@@ -70,6 +72,12 @@ VcpkgSettings::VcpkgSettings()
|
|||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcpkgSettings::setVcpkgRootEnvironmentVariable()
|
||||||
|
{
|
||||||
|
// Set VCPKG_ROOT environment variable so that auto-setup.cmake would pick it up
|
||||||
|
Environment::modifySystemEnvironment({{Constants::ENVVAR_VCPKG_ROOT, vcpkgRoot.value()}});
|
||||||
|
}
|
||||||
|
|
||||||
class VcpkgSettingsPage : public Core::IOptionsPage
|
class VcpkgSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ class VcpkgSettings : public Utils::AspectContainer
|
|||||||
public:
|
public:
|
||||||
VcpkgSettings();
|
VcpkgSettings();
|
||||||
|
|
||||||
|
void setVcpkgRootEnvironmentVariable();
|
||||||
|
|
||||||
Utils::FilePathAspect vcpkgRoot{this};
|
Utils::FilePathAspect vcpkgRoot{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ macro(qtc_auto_setup_vcpkg)
|
|||||||
if (EXISTS "${CMAKE_SOURCE_DIR}/vcpkg.json" AND NOT QT_CREATOR_SKIP_VCPKG_SETUP)
|
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)
|
option(QT_CREATOR_SKIP_VCPKG_SETUP "Skip Qt Creator's vcpkg package manager auto-setup" OFF)
|
||||||
|
|
||||||
find_program(vcpkg_program vcpkg ${CMAKE_SOURCE_DIR}/vcpkg)
|
find_program(vcpkg_program vcpkg $ENV{VCPKG_ROOT} ${CMAKE_SOURCE_DIR}/vcpkg)
|
||||||
if (NOT vcpkg_program)
|
if (NOT vcpkg_program)
|
||||||
message(WARNING "Qt Creator: vcpkg executable not found. "
|
message(WARNING "Qt Creator: vcpkg executable not found. "
|
||||||
"Package manager auto-setup will be skipped. "
|
"Package manager auto-setup will be skipped. "
|
||||||
|
|||||||
Reference in New Issue
Block a user