diff options
author | Brad King <brad.king@kitware.com> | 2017-09-26 15:49:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-10-16 15:55:53 (GMT) |
commit | 4c3116d7545fa357adad13d8e6a5571770377cdc (patch) | |
tree | acfae65063e8dfd4d35a64cc74520e09e6701855 | |
parent | a91eb5e41f486628910f189bf40403568af013c7 (diff) | |
download | CMake-4c3116d7545fa357adad13d8e6a5571770377cdc.zip CMake-4c3116d7545fa357adad13d8e6a5571770377cdc.tar.gz CMake-4c3116d7545fa357adad13d8e6a5571770377cdc.tar.bz2 |
cmVSSetupHelper: Factor out install location string construction
This also adds a missing conversion to unix slashes in one code path.
-rw-r--r-- | Source/cmVSSetupHelper.cxx | 16 | ||||
-rw-r--r-- | Source/cmVSSetupHelper.h | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 3c50403..d36e350 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -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)) { diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h index d2f514c..5c6c285 100644 --- a/Source/cmVSSetupHelper.h +++ b/Source/cmVSSetupHelper.h @@ -116,6 +116,8 @@ struct VSInstanceInfo ullVersion = 0; IsWin10SDKInstalled = IsWin81SDKInstalled = false; } + + std::string GetInstallLocation() const; }; class cmVSSetupAPIHelper |