Updates will be applied on October 27th between 12pm - 12:45pm EDT (UTC-0400). Gitlab may be slow during the maintenance window.

Commit 17edfa41 authored by Brad King's avatar Brad King
Browse files

cmVSSetupHelper: Add option to specify an instance

parent a19b8113
...@@ -80,6 +80,14 @@ cmVSSetupAPIHelper::~cmVSSetupAPIHelper() ...@@ -80,6 +80,14 @@ cmVSSetupAPIHelper::~cmVSSetupAPIHelper()
CoUninitialize(); CoUninitialize();
} }
bool cmVSSetupAPIHelper::SetVSInstance(std::string const& vsInstallLocation)
{
this->SpecifiedVSInstallLocation = vsInstallLocation;
cmSystemTools::ConvertToUnixSlashes(this->SpecifiedVSInstallLocation);
chosenInstanceInfo = VSInstanceInfo();
return this->EnumerateAndChooseVSInstance();
}
bool cmVSSetupAPIHelper::IsVS2017Installed() bool cmVSSetupAPIHelper::IsVS2017Installed()
{ {
return this->EnumerateAndChooseVSInstance(); return this->EnumerateAndChooseVSInstance();
...@@ -296,16 +304,29 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() ...@@ -296,16 +304,29 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
instance = instance2 = NULL; instance = instance2 = NULL;
if (isInstalled) { if (isInstalled) {
if (!envVSCommonToolsDir.empty()) { if (!this->SpecifiedVSInstallLocation.empty()) {
// We are looking for a specific instance.
std::string currentVSLocation = instanceInfo.GetInstallLocation(); std::string currentVSLocation = instanceInfo.GetInstallLocation();
currentVSLocation += "/Common7/Tools";
if (cmSystemTools::ComparePath(currentVSLocation, if (cmSystemTools::ComparePath(currentVSLocation,
envVSCommonToolsDir)) { this->SpecifiedVSInstallLocation)) {
chosenInstanceInfo = instanceInfo; chosenInstanceInfo = instanceInfo;
return true; return true;
} }
} else {
// We are not looking for a specific instance.
// If we've been given a hint then use it.
if (!envVSCommonToolsDir.empty()) {
std::string currentVSLocation = instanceInfo.GetInstallLocation();
currentVSLocation += "/Common7/Tools";
if (cmSystemTools::ComparePath(currentVSLocation,
envVSCommonToolsDir)) {
chosenInstanceInfo = instanceInfo;
return true;
}
}
// Otherwise, add this to the list of candidates.
vecVSInstances.push_back(instanceInfo);
} }
vecVSInstances.push_back(instanceInfo);
} }
} }
......
...@@ -126,6 +126,8 @@ public: ...@@ -126,6 +126,8 @@ public:
cmVSSetupAPIHelper(); cmVSSetupAPIHelper();
~cmVSSetupAPIHelper(); ~cmVSSetupAPIHelper();
bool SetVSInstance(std::string const& vsInstallLocation);
bool IsVS2017Installed(); bool IsVS2017Installed();
bool GetVSInstanceInfo(std::string& vsInstallLocation); bool GetVSInstanceInfo(std::string& vsInstallLocation);
bool IsWin10SDKInstalled(); bool IsWin10SDKInstalled();
...@@ -150,6 +152,8 @@ private: ...@@ -150,6 +152,8 @@ private:
HRESULT comInitialized; HRESULT comInitialized;
// current best instance of VS selected // current best instance of VS selected
VSInstanceInfo chosenInstanceInfo; VSInstanceInfo chosenInstanceInfo;
std::string SpecifiedVSInstallLocation;
}; };
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment