diff options
author | Brad King <brad.king@kitware.com> | 2019-01-09 16:39:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-11 15:37:41 (GMT) |
commit | bdef729646a5a559c295ef9c0fb83eb8a6b34905 (patch) | |
tree | a8f5616d92faab452f1d80d367d4ceb1df4bd3d7 | |
parent | 68d316e0cf278021d9fa4553471d29803d09a394 (diff) | |
download | CMake-bdef729646a5a559c295ef9c0fb83eb8a6b34905.zip CMake-bdef729646a5a559c295ef9c0fb83eb8a6b34905.tar.gz CMake-bdef729646a5a559c295ef9c0fb83eb8a6b34905.tar.bz2 |
VS: Parameterize VS 2017 generator to support future versions
-rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.cxx | 49 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.h | 2 |
2 files changed, 42 insertions, 9 deletions
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 354af72..7d04be2 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -8,6 +8,26 @@ #include "cmMakefile.h" #include "cmVSSetupHelper.h" +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; + } + return 0; +} + static const char vs15generatorName[] = "Visual Studio 15 2017"; // Map generator name without year to name with year. @@ -38,16 +58,19 @@ public: return 0; } if (!*p) { - return new cmGlobalVisualStudioVersionedGenerator(cm, genName, ""); + return new cmGlobalVisualStudioVersionedGenerator( + cmGlobalVisualStudioGenerator::VS15, cm, genName, ""); } if (*p++ != ' ') { return 0; } if (strcmp(p, "Win64") == 0) { - return new cmGlobalVisualStudioVersionedGenerator(cm, genName, "x64"); + return new cmGlobalVisualStudioVersionedGenerator( + cmGlobalVisualStudioGenerator::VS15, cm, genName, "x64"); } if (strcmp(p, "ARM") == 0) { - return new cmGlobalVisualStudioVersionedGenerator(cm, genName, "ARM"); + return new cmGlobalVisualStudioVersionedGenerator( + cmGlobalVisualStudioGenerator::VS15, cm, genName, "ARM"); } return 0; } @@ -77,25 +100,35 @@ cmGlobalVisualStudioVersionedGenerator::NewFactory15() } cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator( - cmake* cm, const std::string& name, + VSVersion version, cmake* cm, const std::string& name, std::string const& platformInGeneratorName) : cmGlobalVisualStudio14Generator(cm, name, platformInGeneratorName) - , vsSetupAPIHelper(15) + , vsSetupAPIHelper(VSVersionToMajor(version)) { this->ExpressEdition = false; this->DefaultPlatformToolset = "v141"; this->DefaultCLFlagTableName = "v141"; this->DefaultCSharpFlagTableName = "v141"; this->DefaultLinkFlagTableName = "v141"; - this->Version = VS15; + this->Version = version; } 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; } return false; } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index 2ffd568..531f5a6 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -32,7 +32,7 @@ public: protected: cmGlobalVisualStudioVersionedGenerator( - cmake* cm, const std::string& name, + VSVersion version, cmake* cm, const std::string& name, std::string const& platformInGeneratorName); bool InitializeWindows(cmMakefile* mf) override; |