1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-21 23:00:50 +08:00

VS: Allow specifying VCTools version with the ClangCL toolset

Visual Studio supports specifying both:

    <PlatformToolset>ClangCL</PlatformToolset>
    <VCToolsVersion>14.32.31326</VCToolsVersion>

Fixes: #25189
This commit is contained in:
Richard Dzenis
2023-08-16 18:28:22 +03:00
committed by Brad King
parent e70749e0d6
commit 899376d070

View File

@@ -193,33 +193,39 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
if (!this->GeneratorToolsetVersion.empty() && if (!this->GeneratorToolsetVersion.empty() &&
this->GeneratorToolsetVersion != "Test Toolset Version"_s) { this->GeneratorToolsetVersion != "Test Toolset Version"_s) {
// If a specific minor version of the toolset was requested, verify that it // If a specific minor version of the MSVC toolset is requested, verify
// is compatible to the major version and that is exists on disk. // that it is compatible with the PlatformToolset version. The ability to
// If not clear the value. // choose a minor version of MSVC has been available since v141.
std::string versionToolset = this->GeneratorToolsetVersion; std::string const& platformToolset = this->GetPlatformToolsetString();
cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9][0-9]"); cmsys::RegularExpression vcPlatformToolsetRegex("^v[0-9][0-9][0-9]$");
if (regex.find(versionToolset)) { if (vcPlatformToolsetRegex.find(platformToolset) ||
versionToolset = cmStrCat('v', versionToolset.erase(2, 1)); platformToolset == "Test Toolset"_s) {
} else { std::string versionToolset = this->GeneratorToolsetVersion;
// Version not recognized. Clear it. cmsys::RegularExpression versionToolsetRegex("^[0-9][0-9]\\.[0-9][0-9]");
versionToolset.clear(); if (versionToolsetRegex.find(versionToolset)) {
} versionToolset = cmStrCat('v', versionToolset.erase(2, 1));
} else {
// Version not recognized. Clear it.
versionToolset.clear();
}
if (!cmHasPrefix(versionToolset, this->GetPlatformToolsetString())) { if (!cmHasPrefix(versionToolset, platformToolset)) {
mf->IssueMessage(MessageType::FATAL_ERROR, mf->IssueMessage(
cmStrCat("Generator\n" MessageType::FATAL_ERROR,
" ", cmStrCat("Generator\n"
this->GetName(), " ",
"\n" this->GetName(),
"given toolset and version specification\n" "\n"
" ", "given toolset and version specification\n"
this->GetPlatformToolsetString(), " ",
",version=", this->GeneratorToolsetVersion, this->GetPlatformToolsetString(),
"\n" ",version=", this->GeneratorToolsetVersion,
"contains an invalid version specification.")); "\n"
"contains an invalid version specification."));
// Clear the configured tool-set // Clear the configured tool-set
this->GeneratorToolsetVersion.clear(); this->GeneratorToolsetVersion.clear();
}
} }
std::string auxProps; std::string auxProps;