summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio10Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-03-11 21:59:20 (GMT)
committerBrad King <brad.king@kitware.com>2021-03-12 13:36:40 (GMT)
commit58a50a3a0aa814c0fb00720cb8fc9edb2cf72344 (patch)
tree19b9ef83bef46cff1ae566967ca629727df2ca63 /Source/cmGlobalVisualStudio10Generator.cxx
parent09f59da7f09ef864c592cb7e3ffd26373ae2f705 (diff)
downloadCMake-58a50a3a0aa814c0fb00720cb8fc9edb2cf72344.zip
CMake-58a50a3a0aa814c0fb00720cb8fc9edb2cf72344.tar.gz
CMake-58a50a3a0aa814c0fb00720cb8fc9edb2cf72344.tar.bz2
VS: Fix '-T version=14.28' under VS 16.9
CMake accepts the toolset version that is default in the current VS version by matching the name later VS versions will use for the SxS props files. It predicts the future name based on the first two components of the current VS version's default toolset. However, this heuristic breaks naming the VS 16.8 toolset version 14.28 under VS 16.9 because the latter's default toolset version is 14.28.29910, which did not increment the second version component (unprecedented in VS). Fix this by always using the requested version's SxS props file when it exists, even if it matches the first two components of the current VS version's default toolset. Also add a special case for the name VS 16.10 will use for VS 16.9's default toolset, so that it can be used with VS 16.9 too. Fixes: #21922
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx63
1 files changed, 27 insertions, 36 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 7011333..badce2e 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -3,6 +3,7 @@
#include "cmGlobalVisualStudio10Generator.h"
#include <algorithm>
+#include <utility>
#include <cm/memory>
@@ -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
-{
- return true;
-}
-
-std::string cmGlobalVisualStudio10Generator::GetAuxiliaryToolset() const
+cmGlobalVisualStudio10Generator::AuxToolset
+cmGlobalVisualStudio10Generator::FindAuxToolset(std::string&,
+ std::string&) const
{
- return {};
+ return AuxToolset::None;
}
bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)