diff options
author | Brad King <brad.king@kitware.com> | 2022-11-04 15:26:17 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-11-04 15:26:59 (GMT) |
commit | 6a999992df8bff05a5347c1dfa891dc1b18596fd (patch) | |
tree | a9f5c5b88b1fe96b99853bc642685c907491d0de | |
parent | 392f53c022b418ea7ad8acb1319272bb5662b490 (diff) | |
parent | c50df859c5120788aded3ebfff039c59044dd90c (diff) | |
download | CMake-6a999992df8bff05a5347c1dfa891dc1b18596fd.zip CMake-6a999992df8bff05a5347c1dfa891dc1b18596fd.tar.gz CMake-6a999992df8bff05a5347c1dfa891dc1b18596fd.tar.bz2 |
Merge topic 'vs-default-toolset' into release-3.25
c50df859c5 VS: Restore support for two-part default toolset version
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7864
-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; } } |