diff options
author | Brad King <brad.king@kitware.com> | 2022-11-03 15:36:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-11-03 15:39:30 (GMT) |
commit | c50df859c5120788aded3ebfff039c59044dd90c (patch) | |
tree | 05ad6c43a6252eba1c3c5c694286bcaa93ea34d4 | |
parent | 48ed0f8a1ce8b524c114f35e603a87f2c004d285 (diff) | |
download | CMake-c50df859c5120788aded3ebfff039c59044dd90c.zip CMake-c50df859c5120788aded3ebfff039c59044dd90c.tar.gz CMake-c50df859c5120788aded3ebfff039c59044dd90c.tar.bz2 |
VS: Restore support for two-part default toolset version
Since commit f972e4fd3a (cmVSGenerator: Add support for two-part toolset
versions for Visual Studio, 2022-09-01, v3.25.0-rc1~180^2), if a
two-part toolset version is requested, we fail early if globbing finds
no auxiliary toolsets with that version. This broke our existing
support for detecting when the default toolset matches the two-part
version requested. Fix the logic to ignore the two-part globbing
results if they are empty so we fall through to checking the default
version.
Fixes: #24107
-rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.cxx | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index e9c8254..be318c1 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -802,26 +802,28 @@ cmGlobalVisualStudioVersionedGenerator::FindAuxToolset( "*/Microsoft.VCToolsVersion."_s, twoComponent, "*.txt"_s); cmsys::Glob glob; glob.SetRecurseThroughSymlinks(false); - // Since we are only using the first two components of the toolset version, - // we require a definite match - if (glob.FindFiles(pattern) && glob.GetFiles().size() == 1) { - std::string const& txt = glob.GetFiles()[0]; - std::string ver; - cmsys::ifstream fin(txt.c_str()); - if (fin && std::getline(fin, ver)) { - // Strip trailing whitespace. - ver = ver.substr(0, ver.find_first_not_of("0123456789.")); - // We assume the version is correct, since it is the only one that - // matched. - cmsys::RegularExpression extractVersion( - "VCToolsVersion\\.([0-9.]+)\\.txt$"); - if (extractVersion.find(txt)) { - version = extractVersion.match(1); + if (glob.FindFiles(pattern) && !glob.GetFiles().empty()) { + // Since we are only using the first two components of the + // toolset version, we require a single match. + if (glob.GetFiles().size() == 1) { + std::string const& txt = glob.GetFiles()[0]; + std::string ver; + cmsys::ifstream fin(txt.c_str()); + if (fin && std::getline(fin, ver)) { + // Strip trailing whitespace. + ver = ver.substr(0, ver.find_first_not_of("0123456789.")); + // We assume the version is correct, since it is the only one that + // matched. + cmsys::RegularExpression extractVersion( + "VCToolsVersion\\.([0-9.]+)\\.txt$"); + if (extractVersion.find(txt)) { + version = extractVersion.match(1); + } } + } else { + props = cmStrCat(instancePath, "/VC/Auxiliary/Build/"_s); + return AuxToolset::PropsIndeterminate; } - } else { - props = cmStrCat(instancePath, "/VC/Auxiliary/Build/"_s); - return AuxToolset::PropsIndeterminate; } } |