summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx2
-rw-r--r--Source/cmGlobalVisualStudio15Generator.cxx3
-rw-r--r--Source/cmVSSetupHelper.cxx18
-rw-r--r--Source/cmVSSetupHelper.h6
-rw-r--r--Source/cmake.cxx3
5 files changed, 17 insertions, 15 deletions
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 882294264e..a2423ac53b 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -141,7 +141,7 @@ bool cmCMakeHostSystemInformationCommand::GetValue(
}
// Otherwise, find a VS 15 instance ourselves.
- cmVSSetupAPIHelper vsSetupAPIHelper;
+ cmVSSetupAPIHelper vsSetupAPIHelper(15);
if (vsSetupAPIHelper.GetVSInstanceInfo(value)) {
cmSystemTools::ConvertToUnixSlashes(value);
}
diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx
index eb49e87476..f9fcbdfae6 100644
--- a/Source/cmGlobalVisualStudio15Generator.cxx
+++ b/Source/cmGlobalVisualStudio15Generator.cxx
@@ -79,6 +79,7 @@ cmGlobalVisualStudio15Generator::cmGlobalVisualStudio15Generator(
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio14Generator(cm, name, platformInGeneratorName)
+ , vsSetupAPIHelper(15)
{
this->ExpressEdition = false;
this->DefaultPlatformToolset = "v141";
@@ -215,7 +216,7 @@ bool cmGlobalVisualStudio15Generator::SelectWindowsStoreToolset(
bool cmGlobalVisualStudio15Generator::IsWindowsDesktopToolsetInstalled() const
{
- return vsSetupAPIHelper.IsVS2017Installed();
+ return vsSetupAPIHelper.IsVSInstalled();
}
bool cmGlobalVisualStudio15Generator::IsWindowsStoreToolsetInstalled() const
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx
index d80b5a2b42..9187c29b9f 100644
--- a/Source/cmVSSetupHelper.cxx
+++ b/Source/cmVSSetupHelper.cxx
@@ -57,8 +57,9 @@ std::string VSInstanceInfo::GetInstallLocation() const
return loc;
}
-cmVSSetupAPIHelper::cmVSSetupAPIHelper()
- : setupConfig(NULL)
+cmVSSetupAPIHelper::cmVSSetupAPIHelper(unsigned int version)
+ : Version(version)
+ , setupConfig(NULL)
, setupConfig2(NULL)
, setupHelper(NULL)
, initializationFailure(false)
@@ -88,7 +89,7 @@ bool cmVSSetupAPIHelper::SetVSInstance(std::string const& vsInstallLocation)
return this->EnumerateAndChooseVSInstance();
}
-bool cmVSSetupAPIHelper::IsVS2017Installed()
+bool cmVSSetupAPIHelper::IsVSInstalled()
{
return this->EnumerateAndChooseVSInstance();
}
@@ -312,11 +313,11 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
return false;
std::string envVSCommonToolsDir;
+ std::string envVSCommonToolsDirEnvName =
+ "VS" + std::to_string(this->Version) + "0COMNTOOLS";
- // FIXME: When we support VS versions beyond 2017, the version
- // to choose will be passed in by the caller. We need to map that
- // to a per-version name of this environment variable.
- if (cmSystemTools::GetEnv("VS150COMNTOOLS", envVSCommonToolsDir)) {
+ if (cmSystemTools::GetEnv(envVSCommonToolsDirEnvName.c_str(),
+ envVSCommonToolsDir)) {
cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir);
}
@@ -328,8 +329,7 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
return false;
}
- // FIXME: Add a way for caller to specify other versions.
- std::wstring wantVersion = std::to_wstring(15) + L'.';
+ std::wstring const wantVersion = std::to_wstring(this->Version) + L'.';
SmartCOMPtr<ISetupInstance> instance;
while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) {
diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h
index b9cca4532c..4748a7aec5 100644
--- a/Source/cmVSSetupHelper.h
+++ b/Source/cmVSSetupHelper.h
@@ -120,12 +120,12 @@ struct VSInstanceInfo
class cmVSSetupAPIHelper
{
public:
- cmVSSetupAPIHelper();
+ cmVSSetupAPIHelper(unsigned int version);
~cmVSSetupAPIHelper();
bool SetVSInstance(std::string const& vsInstallLocation);
- bool IsVS2017Installed();
+ bool IsVSInstalled();
bool GetVSInstanceInfo(std::string& vsInstallLocation);
bool GetVCToolsetVersion(std::string& vsToolsetVersion);
bool IsWin10SDKInstalled();
@@ -140,6 +140,8 @@ private:
int ChooseVSInstance(const std::vector<VSInstanceInfo>& vecVSInstances);
bool EnumerateAndChooseVSInstance();
+ unsigned int Version;
+
// COM ptrs to query about VS instances
SmartCOMPtr<ISetupConfiguration> setupConfig;
SmartCOMPtr<ISetupConfiguration2> setupConfig2;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index e1bae3444f..195956b146 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1538,8 +1538,7 @@ void cmake::CreateDefaultGlobalGenerator()
"\\Setup\\VC;ProductDir", //
";InstallDir" //
};
- cmVSSetupAPIHelper vsSetupAPIHelper;
- if (vsSetupAPIHelper.IsVS2017Installed()) {
+ if (cmVSSetupAPIHelper(15).IsVSInstalled()) {
found = "Visual Studio 15 2017";
} else {
for (VSVersionedGenerator const* g = cm::cbegin(vsGenerators);