diff options
author | Brad King <brad.king@kitware.com> | 2021-03-15 12:49:43 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-03-15 12:50:13 (GMT) |
commit | 3d661c6c3a23bed6fc34d93f6f43228691d14320 (patch) | |
tree | 12cb48dba1c52fb5c2162a9231cb4dddd9cae648 /Source/cmGlobalVisualStudio10Generator.cxx | |
parent | 05616645692cabd9af4c7483376256172f6fcad3 (diff) | |
parent | 30c835428fffbf91191ebb1150d7fec00803523c (diff) | |
download | CMake-3d661c6c3a23bed6fc34d93f6f43228691d14320.zip CMake-3d661c6c3a23bed6fc34d93f6f43228691d14320.tar.gz CMake-3d661c6c3a23bed6fc34d93f6f43228691d14320.tar.bz2 |
Merge topic 'vs-toolset-version'
30c835428f VS: Accept and translate '-T version=' values with three components
58a50a3a0a VS: Fix '-T version=14.28' under VS 16.9
09f59da7f0 cmGlobalVisualStudioVersionedGenerator: Clarify local variable name
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5903
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 8d68bf6..74d8135 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -3,6 +3,7 @@ #include "cmGlobalVisualStudio10Generator.h" #include <algorithm> +#include <utility> #include <cm/memory> @@ -302,16 +303,16 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( // 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; + std::string versionToolset = this->GeneratorToolsetVersion; cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9][0-9]"); - if (regex.find(version)) { - version = "v" + version.erase(2, 1); + if (regex.find(versionToolset)) { + versionToolset = "v" + versionToolset.erase(2, 1); } else { // Version not recognized. Clear it. - version.clear(); + versionToolset.clear(); } - if (!cmHasPrefix(version, this->GetPlatformToolsetString())) { + if (!cmHasPrefix(versionToolset, this->GetPlatformToolsetString())) { std::ostringstream e; /* clang-format off */ e << @@ -329,15 +330,20 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( this->GeneratorToolsetVersion.clear(); } - bool const isDefaultToolset = - this->IsDefaultToolset(this->GeneratorToolsetVersion); - if (isDefaultToolset) { - // If the given version is the default toolset, remove the setting - this->GeneratorToolsetVersion.clear(); - } else { - std::string const toolsetPath = this->GetAuxiliaryToolset(); - if (!toolsetPath.empty() && !cmSystemTools::FileExists(toolsetPath)) { - + std::string auxProps; + switch (this->FindAuxToolset(this->GeneratorToolsetVersion, auxProps)) { + case AuxToolset::None: + this->GeneratorToolsetVersionProps = {}; + break; + case AuxToolset::Default: + // The given version is the default toolset. Remove the setting. + this->GeneratorToolsetVersion.clear(); + this->GeneratorToolsetVersionProps = {}; + break; + case AuxToolset::PropsExist: + this->GeneratorToolsetVersionProps = std::move(auxProps); + break; + case AuxToolset::PropsMissing: { std::ostringstream e; /* clang-format off */ e << @@ -347,22 +353,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( " " << this->GetPlatformToolsetString() << ",version=" << this->GeneratorToolsetVersion << "\n" "does not seem to be installed at\n" << - " " << toolsetPath; + " " << auxProps; ; /* clang-format on */ mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); // Clear the configured tool-set this->GeneratorToolsetVersion.clear(); - } + this->GeneratorToolsetVersionProps = {}; + } break; } } 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 (!this->GeneratorToolsetVersion.empty()) { + mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_VERSION", + this->GeneratorToolsetVersion); } if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) { mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE", hostArch); @@ -719,23 +727,10 @@ 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 +cmGlobalVisualStudio10Generator::GetPlatformToolsetVersionProps() const { - if (!this->GeneratorToolsetVersion.empty()) { - return this->GeneratorToolsetVersion; - } - static std::string const empty; - return empty; + return this->GeneratorToolsetVersionProps; } const char* @@ -792,15 +787,11 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDirString() const return this->GeneratorToolsetCudaCustomDir; } -bool cmGlobalVisualStudio10Generator::IsDefaultToolset( - const std::string&) const +cmGlobalVisualStudio10Generator::AuxToolset +cmGlobalVisualStudio10Generator::FindAuxToolset(std::string&, + std::string&) const { - return true; -} - -std::string cmGlobalVisualStudio10Generator::GetAuxiliaryToolset() const -{ - return {}; + return AuxToolset::None; } bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf) |