cmVSSetupHelper: Factor out install location string construction

This also adds a missing conversion to unix slashes in one code path.
This commit is contained in:
Brad King 2017-09-26 11:49:58 -04:00
parent a91eb5e41f
commit 4c3116d754
2 changed files with 12 additions and 6 deletions

View File

@ -49,6 +49,14 @@ const WCHAR* Win81SDKComponent =
L"Microsoft.VisualStudio.Component.Windows81SDK";
const WCHAR* ComponentType = L"Component";
std::string VSInstanceInfo::GetInstallLocation() const
{
std::string loc(this->VSInstallLocation.begin(),
this->VSInstallLocation.end());
cmSystemTools::ConvertToUnixSlashes(loc);
return loc;
}
cmVSSetupAPIHelper::cmVSSetupAPIHelper()
: setupConfig(NULL)
, setupConfig2(NULL)
@ -222,9 +230,7 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(std::string& vsInstallLocation)
bool isInstalled = this->EnumerateAndChooseVSInstance();
if (isInstalled) {
std::string str(chosenInstanceInfo.VSInstallLocation.begin(),
chosenInstanceInfo.VSInstallLocation.end());
vsInstallLocation = str;
vsInstallLocation = chosenInstanceInfo.GetInstallLocation();
}
return isInstalled;
@ -281,9 +287,7 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
if (isInstalled) {
if (!envVSCommonToolsDir.empty()) {
std::string currentVSLocation(instanceInfo.VSInstallLocation.begin(),
instanceInfo.VSInstallLocation.end());
cmSystemTools::ConvertToUnixSlashes(currentVSLocation);
std::string currentVSLocation = instanceInfo.GetInstallLocation();
currentVSLocation += "/Common7/Tools";
if (cmSystemTools::ComparePath(currentVSLocation,
envVSCommonToolsDir)) {

View File

@ -116,6 +116,8 @@ struct VSInstanceInfo
ullVersion = 0;
IsWin10SDKInstalled = IsWin81SDKInstalled = false;
}
std::string GetInstallLocation() const;
};
class cmVSSetupAPIHelper