diff options
author | Brad King <brad.king@kitware.com> | 2024-02-19 16:45:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-02-19 17:06:48 (GMT) |
commit | 3a7fbd04c8acb89cd14186930aa80f08c08bada0 (patch) | |
tree | 8ffbc38805cc6ddc885c96e9d606f42c3b387b66 /Source | |
parent | df4d6c71438a70902d9605f208e450a77f14676c (diff) | |
download | CMake-3a7fbd04c8acb89cd14186930aa80f08c08bada0.zip CMake-3a7fbd04c8acb89cd14186930aa80f08c08bada0.tar.gz CMake-3a7fbd04c8acb89cd14186930aa80f08c08bada0.tar.bz2 |
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.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 8 |
1 files 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" |