From 3a7fbd04c8acb89cd14186930aa80f08c08bada0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Feb 2024 11:45:50 -0500 Subject: VS: Verify toolset version= field format more strictly In commit 5f13168419 (VS: Add option to select the version of the toolset used by VS 2017, 2018-05-19, v3.12.0-rc1~38^2) we added logic to verify that the toolset version, such as `14.35`, matches the toolset name, such as `v143`. Clarify the logic to not construct a temporary nonsensical toolset name like `v1435`. Also verify the format of the toolset version more strictly, e.g., to reject `14.350` earlier. Previously the latter example was only rejected by the `.props` file not existing. --- Source/cmGlobalVisualStudio10Generator.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index c93b140..09679cd 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -218,15 +218,17 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( if (vcPlatformToolsetRegex.find(platformToolset) || platformToolset == "Test Toolset"_s) { std::string versionToolset = this->GeneratorToolsetVersion; - cmsys::RegularExpression versionToolsetRegex("^[0-9][0-9]\\.[0-9][0-9]"); + cmsys::RegularExpression versionToolsetRegex( + "^([0-9][0-9])\\.([0-9])[0-9](\\.|$)"); if (versionToolsetRegex.find(versionToolset)) { - versionToolset = cmStrCat('v', versionToolset.erase(2, 1)); + versionToolset = cmStrCat('v', versionToolsetRegex.match(1), + versionToolsetRegex.match(2)); } else { // Version not recognized. Clear it. versionToolset.clear(); } - if (!cmHasPrefix(versionToolset, platformToolset)) { + if (versionToolset != platformToolset) { mf->IssueMessage( MessageType::FATAL_ERROR, cmStrCat("Generator\n" -- cgit v0.12 From d256581bb08799741f9a5221396a5b38b44b3f54 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Feb 2024 11:51:25 -0500 Subject: VS: Fix '-T version=14.40' under VS 17.10 preview 1 VS 17.10 preview 1 comes with toolset `v143` version `14.40`. This is the first time that the first three digits of the version do not match the toolset name. Add a special case to map version `14.40` back to toolset `v143`. --- Source/cmGlobalVisualStudio10Generator.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 09679cd..91fbccc 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -223,6 +223,14 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( if (versionToolsetRegex.find(versionToolset)) { versionToolset = cmStrCat('v', versionToolsetRegex.match(1), versionToolsetRegex.match(2)); + // Hard-code special cases for toolset versions whose first + // three digits do not match their toolset name. + if (platformToolset == "v143"_s && versionToolset == "v144"_s && + // VS 17.10 toolset v143 version 14.40. + (this->GeneratorToolsetVersion == "14.40"_s || + cmHasLiteralPrefix(this->GeneratorToolsetVersion, "14.40."))) { + versionToolset = "v143"; + } } else { // Version not recognized. Clear it. versionToolset.clear(); -- cgit v0.12