diff options
author | Brad King <brad.king@kitware.com> | 2018-05-30 14:18:50 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-05-30 14:19:21 (GMT) |
commit | 958191a95c9d06c0efa9240d0e98ada429e9bc3f (patch) | |
tree | 329c70681bd6591e964ef0bbcb1380d8ad8c2126 /Source/cmGlobalVisualStudio10Generator.cxx | |
parent | fdb9d1ba042fb517da0bf03a3781dd7a3b506f69 (diff) | |
parent | 5f1316841944198037d6463d3ddd12efcfae45b3 (diff) | |
download | CMake-958191a95c9d06c0efa9240d0e98ada429e9bc3f.zip CMake-958191a95c9d06c0efa9240d0e98ada429e9bc3f.tar.gz CMake-958191a95c9d06c0efa9240d0e98ada429e9bc3f.tar.bz2 |
Merge topic 'vs-toolset-version'
5f13168419 VS: Add option to select the version of the toolset used by VS 2017
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Francisco Facioni <fran6co@gmail.com>
Merge-request: !2093
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 51e9ab1..8c20313 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -231,9 +231,66 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( } } + if (!this->GeneratorToolsetVersion.empty() && + this->GeneratorToolsetVersion != "Test Toolset Version") { + // If a specific minor version of the toolset was requested, verify that it + // is compatible to the major version and that is exists on disk. + // If not clear the value. + std::string version = this->GeneratorToolsetVersion; + cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9][0-9]"); + if (regex.find(version)) { + version = "v" + version.erase(2, 1); + } else { + // Version not recognized. Clear it. + version.clear(); + } + + if (version.find(this->GetPlatformToolsetString()) != 0) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given toolset and version specification\n" + " " << this->GetPlatformToolsetString() << ",version=" << + this->GeneratorToolsetVersion << "\n" + "contains an invalid version specification." + ; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + + // Clear the configured tool-set + this->GeneratorToolsetVersion.clear(); + } + + std::string const toolsetPath = this->GetAuxiliaryToolset(); + if (!toolsetPath.empty() && !cmSystemTools::FileExists(toolsetPath)) { + + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given toolset and version specification\n" + " " << this->GetPlatformToolsetString() << ",version=" << + this->GeneratorToolsetVersion << "\n" + "does not seem to be installed at\n" << + " " << toolsetPath; + ; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + + // Clear the configured tool-set + this->GeneratorToolsetVersion.clear(); + } + } + if (const char* toolset = this->GetPlatformToolset()) { mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset); } + if (const char* version = this->GetPlatformToolsetVersion()) { + mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_VERSION", version); + } if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) { mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE", hostArch); } @@ -319,6 +376,10 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField( this->GeneratorToolsetCuda = value; return true; } + if (key == "version") { + this->GeneratorToolsetVersion = value; + return true; + } return false; } @@ -512,6 +573,25 @@ std::string const& cmGlobalVisualStudio10Generator::GetPlatformToolsetString() return empty; } +const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetVersion() const +{ + std::string const& version = this->GetPlatformToolsetVersionString(); + if (version.empty()) { + return nullptr; + } + return version.c_str(); +} + +std::string const& +cmGlobalVisualStudio10Generator::GetPlatformToolsetVersionString() const +{ + if (!this->GeneratorToolsetVersion.empty()) { + return this->GeneratorToolsetVersion; + } + static std::string const empty; + return empty; +} + const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const { @@ -535,6 +615,11 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaString() const return this->GeneratorToolsetCuda; } +std::string cmGlobalVisualStudio10Generator::GetAuxiliaryToolset() const +{ + return {}; +} + bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf) { if (!this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf)) { |