diff options
author | Brad King <brad.king@kitware.com> | 2019-01-15 18:23:29 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-15 18:23:38 (GMT) |
commit | 41b0c0dc739c34550b8e9054b9a88405afb6518d (patch) | |
tree | e105225815d76cd1f996416bbafdeeb6f918dc23 /Source | |
parent | 67422bf579e5c274794f131f008bec4ec1e7d4b9 (diff) | |
parent | 57e48f16f2c3b73fb27057267c8092a41005bb75 (diff) | |
download | CMake-41b0c0dc739c34550b8e9054b9a88405afb6518d.zip CMake-41b0c0dc739c34550b8e9054b9a88405afb6518d.tar.gz CMake-41b0c0dc739c34550b8e9054b9a88405afb6518d.tar.bz2 |
Merge topic 'vs2019'
57e48f16f2 VS: Add Visual Studio 16 2019 generator
bdef729646 VS: Parameterize VS 2017 generator to support future versions
68d316e0cf VS: Rename VS 2017 generator sources to be version-independent
d8ed309d05 VS: Parameterize cmVSSetupAPIHelper instances with VS version
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2789
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Source/cmCMakeHostSystemInformationCommand.cxx | 24 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 11 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.cxx (renamed from Source/cmGlobalVisualStudio15Generator.cxx) | 215 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.h (renamed from Source/cmGlobalVisualStudio15Generator.h) | 23 | ||||
-rw-r--r-- | Source/cmVSSetupHelper.cxx | 18 | ||||
-rw-r--r-- | Source/cmVSSetupHelper.h | 6 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 1 | ||||
-rw-r--r-- | Source/cmake.cxx | 12 |
11 files changed, 257 insertions, 62 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 91c45bc..c87ceba 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -696,10 +696,10 @@ if (WIN32) cmGlobalVisualStudio12Generator.cxx cmGlobalVisualStudio14Generator.h cmGlobalVisualStudio14Generator.cxx - cmGlobalVisualStudio15Generator.h - cmGlobalVisualStudio15Generator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h + cmGlobalVisualStudioVersionedGenerator.h + cmGlobalVisualStudioVersionedGenerator.cxx cmIDEFlagTable.h cmIDEOptions.cxx cmIDEOptions.h diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 8822942..54f08bb 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -10,7 +10,7 @@ #if defined(_WIN32) # include "cmAlgorithms.h" # include "cmGlobalGenerator.h" -# include "cmGlobalVisualStudio15Generator.h" +# include "cmGlobalVisualStudioVersionedGenerator.h" # include "cmSystemTools.h" # include "cmVSSetupHelper.h" # define HAVE_VS_SETUP_HELPER @@ -133,15 +133,31 @@ bool cmCMakeHostSystemInformationCommand::GetValue( // If generating for the VS 15 IDE, use the same instance. cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); if (cmHasLiteralPrefix(gg->GetName(), "Visual Studio 15 ")) { - cmGlobalVisualStudio15Generator* vs15gen = - static_cast<cmGlobalVisualStudio15Generator*>(gg); + cmGlobalVisualStudioVersionedGenerator* vs15gen = + static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg); if (vs15gen->GetVSInstance(value)) { return true; } } // Otherwise, find a VS 15 instance ourselves. - cmVSSetupAPIHelper vsSetupAPIHelper; + cmVSSetupAPIHelper vsSetupAPIHelper(15); + if (vsSetupAPIHelper.GetVSInstanceInfo(value)) { + cmSystemTools::ConvertToUnixSlashes(value); + } + } else if (key == "VS_16_DIR") { + // If generating for the VS 16 IDE, use the same instance. + cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); + if (cmHasLiteralPrefix(gg->GetName(), "Visual Studio 16 ")) { + cmGlobalVisualStudioVersionedGenerator* vs16gen = + static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg); + if (vs16gen->GetVSInstance(value)) { + return true; + } + } + + // Otherwise, find a VS 16 instance ourselves. + cmVSSetupAPIHelper vsSetupAPIHelper(16); if (vsSetupAPIHelper.GetVSInstanceInfo(value)) { cmSystemTools::ConvertToUnixSlashes(value); } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a6bec4b..2932970 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1032,6 +1032,8 @@ const char* cmGlobalVisualStudio10Generator::GetToolsVersion() const return "14.0"; case cmGlobalVisualStudioGenerator::VS15: return "15.0"; + case cmGlobalVisualStudioGenerator::VS16: + return "16.0"; } return ""; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index dc8de03..57510df 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -86,6 +86,8 @@ const char* cmGlobalVisualStudioGenerator::GetIDEVersion() const return "14.0"; case cmGlobalVisualStudioGenerator::VS15: return "15.0"; + case cmGlobalVisualStudioGenerator::VS16: + return "16.0"; } return ""; } @@ -139,6 +141,15 @@ void cmGlobalVisualStudioGenerator::WriteSLNHeader(std::ostream& fout) fout << "# Visual Studio 15\n"; } break; + case cmGlobalVisualStudioGenerator::VS16: + // Visual Studio 16 writes .sln format 12.00 + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + if (this->ExpressEdition) { + fout << "# Visual Studio Express 16 for Windows Desktop\n"; + } else { + fout << "# Visual Studio 16\n"; + } + break; } } diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index d44f5a5..039191c 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -38,7 +38,8 @@ public: VS12 = 120, /* VS13 = 130 was skipped */ VS14 = 140, - VS15 = 150 + VS15 = 150, + VS16 = 160 }; virtual ~cmGlobalVisualStudioGenerator(); diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index eb49e87..f06c019 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -1,6 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmGlobalVisualStudio15Generator.h" +#include "cmGlobalVisualStudioVersionedGenerator.h" #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" @@ -8,6 +8,61 @@ #include "cmMakefile.h" #include "cmVSSetupHelper.h" +#if defined(_M_ARM64) +# define HOST_PLATFORM_NAME "ARM64"; +#elif defined(_M_ARM) +# define HOST_PLATFORM_NAME "ARM"; +#elif defined(_M_IA64) +# define HOST_PLATFORM_NAME "Itanium"; +#else +# include "cmsys/SystemInformation.hxx" +#endif + +static unsigned int VSVersionToMajor( + cmGlobalVisualStudioGenerator::VSVersion v) +{ + switch (v) { + case cmGlobalVisualStudioGenerator::VS9: + return 9; + case cmGlobalVisualStudioGenerator::VS10: + return 10; + case cmGlobalVisualStudioGenerator::VS11: + return 11; + case cmGlobalVisualStudioGenerator::VS12: + return 12; + case cmGlobalVisualStudioGenerator::VS14: + return 14; + case cmGlobalVisualStudioGenerator::VS15: + return 15; + case cmGlobalVisualStudioGenerator::VS16: + return 16; + } + return 0; +} + +static const char* VSVersionToToolset( + cmGlobalVisualStudioGenerator::VSVersion v) +{ + switch (v) { + case cmGlobalVisualStudioGenerator::VS9: + return "v90"; + case cmGlobalVisualStudioGenerator::VS10: + return "v100"; + case cmGlobalVisualStudioGenerator::VS11: + return "v110"; + case cmGlobalVisualStudioGenerator::VS12: + return "v120"; + case cmGlobalVisualStudioGenerator::VS14: + return "v140"; + case cmGlobalVisualStudioGenerator::VS15: + return "v141"; + case cmGlobalVisualStudioGenerator::VS16: + // FIXME: VS 2019 Preview 1.1 uses v141 but preview 2 will use v142. + return "v141"; + } + return ""; +} + static const char vs15generatorName[] = "Visual Studio 15 2017"; // Map generator name without year to name with year. @@ -25,7 +80,7 @@ static const char* cmVS15GenName(const std::string& name, std::string& genName) return p; } -class cmGlobalVisualStudio15Generator::Factory +class cmGlobalVisualStudioVersionedGenerator::Factory15 : public cmGlobalGeneratorFactory { public: @@ -38,16 +93,19 @@ public: return 0; } if (!*p) { - return new cmGlobalVisualStudio15Generator(cm, genName, ""); + return new cmGlobalVisualStudioVersionedGenerator( + cmGlobalVisualStudioGenerator::VS15, cm, genName, ""); } if (*p++ != ' ') { return 0; } if (strcmp(p, "Win64") == 0) { - return new cmGlobalVisualStudio15Generator(cm, genName, "x64"); + return new cmGlobalVisualStudioVersionedGenerator( + cmGlobalVisualStudioGenerator::VS15, cm, genName, "x64"); } if (strcmp(p, "ARM") == 0) { - return new cmGlobalVisualStudio15Generator(cm, genName, "ARM"); + return new cmGlobalVisualStudioVersionedGenerator( + cmGlobalVisualStudioGenerator::VS15, cm, genName, "ARM"); } return 0; } @@ -70,35 +128,122 @@ public: bool SupportsPlatform() const override { return true; } }; -cmGlobalGeneratorFactory* cmGlobalVisualStudio15Generator::NewFactory() +cmGlobalGeneratorFactory* +cmGlobalVisualStudioVersionedGenerator::NewFactory15() +{ + return new Factory15; +} + +static const char vs16generatorName[] = "Visual Studio 16 2019"; + +// Map generator name without year to name with year. +static const char* cmVS16GenName(const std::string& name, std::string& genName) +{ + if (strncmp(name.c_str(), vs16generatorName, + sizeof(vs16generatorName) - 6) != 0) { + return 0; + } + const char* p = name.c_str() + sizeof(vs16generatorName) - 6; + if (cmHasLiteralPrefix(p, " 2019")) { + p += 5; + } + genName = std::string(vs16generatorName) + p; + return p; +} + +class cmGlobalVisualStudioVersionedGenerator::Factory16 + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name, + cmake* cm) const + { + std::string genName; + const char* p = cmVS16GenName(name, genName); + if (!p) { + return 0; + } + if (!*p) { + return new cmGlobalVisualStudioVersionedGenerator( + cmGlobalVisualStudioGenerator::VS16, cm, genName, ""); + } + return 0; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = std::string(vs16generatorName); + entry.Brief = "Generates Visual Studio 2019 project files. " + "Use -A option to specify architecture."; + } + + virtual void GetGenerators(std::vector<std::string>& names) const + { + names.push_back(vs16generatorName); + } + + bool SupportsToolset() const override { return true; } + bool SupportsPlatform() const override { return true; } +}; + +cmGlobalGeneratorFactory* +cmGlobalVisualStudioVersionedGenerator::NewFactory16() { - return new Factory; + return new Factory16; } -cmGlobalVisualStudio15Generator::cmGlobalVisualStudio15Generator( - cmake* cm, const std::string& name, +cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator( + VSVersion version, cmake* cm, const std::string& name, std::string const& platformInGeneratorName) : cmGlobalVisualStudio14Generator(cm, name, platformInGeneratorName) + , vsSetupAPIHelper(VSVersionToMajor(version)) { + this->Version = version; this->ExpressEdition = false; - this->DefaultPlatformToolset = "v141"; - this->DefaultCLFlagTableName = "v141"; - this->DefaultCSharpFlagTableName = "v141"; - this->DefaultLinkFlagTableName = "v141"; - this->Version = VS15; + this->DefaultPlatformToolset = VSVersionToToolset(this->Version); + this->DefaultCLFlagTableName = VSVersionToToolset(this->Version); + this->DefaultCSharpFlagTableName = VSVersionToToolset(this->Version); + this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version); + if (this->Version >= cmGlobalVisualStudioGenerator::VS16) { +#ifdef HOST_PLATFORM_NAME + this->DefaultPlatformName = HOST_PLATFORM_NAME; +#else + cmsys::SystemInformation info; + if (info.Is64Bits()) { + this->DefaultPlatformName = "x64"; + } else { + this->DefaultPlatformName = "Win32"; + } +#endif + } } -bool cmGlobalVisualStudio15Generator::MatchesGeneratorName( +bool cmGlobalVisualStudioVersionedGenerator::MatchesGeneratorName( const std::string& name) const { std::string genName; - if (cmVS15GenName(name, genName)) { - return genName == this->GetName(); + switch (this->Version) { + case cmGlobalVisualStudioGenerator::VS9: + case cmGlobalVisualStudioGenerator::VS10: + case cmGlobalVisualStudioGenerator::VS11: + case cmGlobalVisualStudioGenerator::VS12: + case cmGlobalVisualStudioGenerator::VS14: + break; + case cmGlobalVisualStudioGenerator::VS15: + if (cmVS15GenName(name, genName)) { + return genName == this->GetName(); + } + break; + case cmGlobalVisualStudioGenerator::VS16: + if (cmVS16GenName(name, genName)) { + return genName == this->GetName(); + } + break; } return false; } -bool cmGlobalVisualStudio15Generator::SetGeneratorInstance( +bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance( std::string const& i, cmMakefile* mf) { if (!i.empty()) { @@ -140,12 +285,13 @@ bool cmGlobalVisualStudio15Generator::SetGeneratorInstance( return true; } -bool cmGlobalVisualStudio15Generator::GetVSInstance(std::string& dir) const +bool cmGlobalVisualStudioVersionedGenerator::GetVSInstance( + std::string& dir) const { return vsSetupAPIHelper.GetVSInstanceInfo(dir); } -bool cmGlobalVisualStudio15Generator::IsDefaultToolset( +bool cmGlobalVisualStudioVersionedGenerator::IsDefaultToolset( const std::string& version) const { if (version.empty()) { @@ -166,7 +312,7 @@ bool cmGlobalVisualStudio15Generator::IsDefaultToolset( return false; } -std::string cmGlobalVisualStudio15Generator::GetAuxiliaryToolset() const +std::string cmGlobalVisualStudioVersionedGenerator::GetAuxiliaryToolset() const { const char* version = this->GetPlatformToolsetVersion(); if (version) { @@ -185,7 +331,7 @@ std::string cmGlobalVisualStudio15Generator::GetAuxiliaryToolset() const return {}; } -bool cmGlobalVisualStudio15Generator::InitializeWindows(cmMakefile* mf) +bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf) { // If the Win 8.1 SDK is installed then we can select a SDK matching // the target Windows version. @@ -197,13 +343,13 @@ bool cmGlobalVisualStudio15Generator::InitializeWindows(cmMakefile* mf) return this->SelectWindows10SDK(mf, false); } -bool cmGlobalVisualStudio15Generator::SelectWindowsStoreToolset( +bool cmGlobalVisualStudioVersionedGenerator::SelectWindowsStoreToolset( std::string& toolset) const { if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) { if (this->IsWindowsStoreToolsetInstalled() && this->IsWindowsDesktopToolsetInstalled()) { - toolset = "v141"; // VS 15 uses v141 toolset + toolset = VSVersionToToolset(this->Version); return true; } else { return false; @@ -213,17 +359,19 @@ bool cmGlobalVisualStudio15Generator::SelectWindowsStoreToolset( toolset); } -bool cmGlobalVisualStudio15Generator::IsWindowsDesktopToolsetInstalled() const +bool cmGlobalVisualStudioVersionedGenerator::IsWindowsDesktopToolsetInstalled() + const { - return vsSetupAPIHelper.IsVS2017Installed(); + return vsSetupAPIHelper.IsVSInstalled(); } -bool cmGlobalVisualStudio15Generator::IsWindowsStoreToolsetInstalled() const +bool cmGlobalVisualStudioVersionedGenerator::IsWindowsStoreToolsetInstalled() + const { return vsSetupAPIHelper.IsWin10SDKInstalled(); } -bool cmGlobalVisualStudio15Generator::IsWin81SDKInstalled() const +bool cmGlobalVisualStudioVersionedGenerator::IsWin81SDKInstalled() const { // Does the VS installer tool know about one? if (vsSetupAPIHelper.IsWin81SDKInstalled()) { @@ -245,18 +393,23 @@ bool cmGlobalVisualStudio15Generator::IsWin81SDKInstalled() const return false; } -std::string cmGlobalVisualStudio15Generator::GetWindows10SDKMaxVersion() const +std::string cmGlobalVisualStudioVersionedGenerator::GetWindows10SDKMaxVersion() + const { return std::string(); } -std::string cmGlobalVisualStudio15Generator::FindMSBuildCommand() +std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand() { std::string msbuild; // Ask Visual Studio Installer tool. std::string vs; if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { + msbuild = vs + "/MSBuild/Current/Bin/MSBuild.exe"; + if (cmSystemTools::FileExists(msbuild)) { + return msbuild; + } msbuild = vs + "/MSBuild/15.0/Bin/MSBuild.exe"; if (cmSystemTools::FileExists(msbuild)) { return msbuild; @@ -267,7 +420,7 @@ std::string cmGlobalVisualStudio15Generator::FindMSBuildCommand() return msbuild; } -std::string cmGlobalVisualStudio15Generator::FindDevEnvCommand() +std::string cmGlobalVisualStudioVersionedGenerator::FindDevEnvCommand() { std::string devenv; diff --git a/Source/cmGlobalVisualStudio15Generator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index da85d23..466816b 100644 --- a/Source/cmGlobalVisualStudio15Generator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmGlobalVisualStudio15Generator_h -#define cmGlobalVisualStudio15Generator_h +#ifndef cmGlobalVisualStudioVersionedGenerator_h +#define cmGlobalVisualStudioVersionedGenerator_h #include "cmConfigure.h" // IWYU pragma: keep @@ -14,11 +14,13 @@ class cmGlobalGeneratorFactory; class cmake; -/** \class cmGlobalVisualStudio15Generator */ -class cmGlobalVisualStudio15Generator : public cmGlobalVisualStudio14Generator +/** \class cmGlobalVisualStudioVersionedGenerator */ +class cmGlobalVisualStudioVersionedGenerator + : public cmGlobalVisualStudio14Generator { public: - static cmGlobalGeneratorFactory* NewFactory(); + static cmGlobalGeneratorFactory* NewFactory15(); + static cmGlobalGeneratorFactory* NewFactory16(); bool MatchesGeneratorName(const std::string& name) const override; @@ -30,8 +32,9 @@ public: std::string GetAuxiliaryToolset() const override; protected: - cmGlobalVisualStudio15Generator(cmake* cm, const std::string& name, - std::string const& platformInGeneratorName); + cmGlobalVisualStudioVersionedGenerator( + VSVersion version, cmake* cm, const std::string& name, + std::string const& platformInGeneratorName); bool InitializeWindows(cmMakefile* mf) override; bool SelectWindowsStoreToolset(std::string& toolset) const override; @@ -53,8 +56,10 @@ protected: std::string FindDevEnvCommand() override; private: - class Factory; - friend class Factory; + class Factory15; + friend class Factory15; + class Factory16; + friend class Factory16; mutable cmVSSetupAPIHelper vsSetupAPIHelper; }; #endif diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index d80b5a2..9187c29 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 b9cca45..4748a7a 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/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index afe9230..5c3e533 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -70,6 +70,7 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() case cmGlobalVisualStudioGenerator::VS12: case cmGlobalVisualStudioGenerator::VS14: case cmGlobalVisualStudioGenerator::VS15: + case cmGlobalVisualStudioGenerator::VS16: // by default VS puts <ExceptionHandling></ExceptionHandling> empty // for a project, to make our projects look the same put a new line // and space over for the closing </ExceptionHandling> as the default diff --git a/Source/cmake.cxx b/Source/cmake.cxx index bfb066d..dfdcf8a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -55,8 +55,8 @@ # include "cmGlobalVisualStudio11Generator.h" # include "cmGlobalVisualStudio12Generator.h" # include "cmGlobalVisualStudio14Generator.h" -# include "cmGlobalVisualStudio15Generator.h" # include "cmGlobalVisualStudio9Generator.h" +# include "cmGlobalVisualStudioVersionedGenerator.h" # include "cmVSSetupHelper.h" # define CMAKE_HAVE_VS_GENERATORS @@ -1545,8 +1545,9 @@ void cmake::CreateDefaultGlobalGenerator() "\\Setup\\VC;ProductDir", // ";InstallDir" // }; - cmVSSetupAPIHelper vsSetupAPIHelper; - if (vsSetupAPIHelper.IsVS2017Installed()) { + if (cmVSSetupAPIHelper(16).IsVSInstalled()) { + found = "Visual Studio 16 2019"; + } else if (cmVSSetupAPIHelper(15).IsVSInstalled()) { found = "Visual Studio 15 2017"; } else { for (VSVersionedGenerator const* g = cm::cbegin(vsGenerators); @@ -1800,7 +1801,10 @@ void cmake::AddDefaultGenerators() { #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) - this->Generators.push_back(cmGlobalVisualStudio15Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudioVersionedGenerator::NewFactory16()); + this->Generators.push_back( + cmGlobalVisualStudioVersionedGenerator::NewFactory15()); this->Generators.push_back(cmGlobalVisualStudio14Generator::NewFactory()); this->Generators.push_back(cmGlobalVisualStudio12Generator::NewFactory()); this->Generators.push_back(cmGlobalVisualStudio11Generator::NewFactory()); |