From 8a7ad923a89030e63e60fb333169abd258732615 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Tue, 2 Jun 2020 12:46:07 -0700 Subject: VS: Extract instance version from VS Installer --- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 6 ++++++ Source/cmGlobalVisualStudioVersionedGenerator.h | 2 ++ Source/cmVSSetupHelper.cxx | 14 ++++++++++++++ Source/cmVSSetupHelper.h | 1 + 4 files changed, 23 insertions(+) diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 13ae32a..d44433b 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -366,6 +366,12 @@ bool cmGlobalVisualStudioVersionedGenerator::GetVSInstance( return vsSetupAPIHelper.GetVSInstanceInfo(dir); } +bool cmGlobalVisualStudioVersionedGenerator::GetVSInstanceVersion( + unsigned long long& vsInstanceVersion) const +{ + return vsSetupAPIHelper.GetVSInstanceVersion(vsInstanceVersion); +} + bool cmGlobalVisualStudioVersionedGenerator::IsDefaultToolset( const std::string& version) const { diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index abb6095..bcf8546 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -29,6 +29,8 @@ public: bool GetVSInstance(std::string& dir) const; + bool GetVSInstanceVersion(unsigned long long& vsInstanceVersion) const; + bool IsDefaultToolset(const std::string& version) const override; std::string GetAuxiliaryToolset() const override; diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index dd9f058..9626599 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -258,6 +258,20 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(std::string& vsInstallLocation) return isInstalled; } +bool cmVSSetupAPIHelper::GetVSInstanceVersion( + unsigned long long& vsInstanceVersion) +{ + vsInstanceVersion = 0; + bool isInstalled = this->EnumerateAndChooseVSInstance(); + + if (isInstalled) { + vsInstanceVersion = + static_cast(chosenInstanceInfo.ullVersion); + } + + return isInstalled; +} + bool cmVSSetupAPIHelper::GetVCToolsetVersion(std::string& vsToolsetVersion) { vsToolsetVersion.clear(); diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h index a2fd3d5..a926eee 100644 --- a/Source/cmVSSetupHelper.h +++ b/Source/cmVSSetupHelper.h @@ -106,6 +106,7 @@ public: bool IsVSInstalled(); bool GetVSInstanceInfo(std::string& vsInstallLocation); + bool GetVSInstanceVersion(unsigned long long& vsInstanceVersion); bool GetVCToolsetVersion(std::string& vsToolsetVersion); bool IsWin10SDKInstalled(); bool IsWin81SDKInstalled(); -- cgit v0.12