VS: Do not apply any '/external:*' flag table mapping on VS < 16.10

Since commit 887e9df0c7 (VS: Update v142 CL flag table for VS 16.10,
2021-06-04) we map several `/external:*` flags to their corresponding
`.vcxproj` elements.  These elements were added to `cl.xml` in VS 16.10,
so filter them out in older VS versions.  Add a field to the json flag
table format to specify the minimum version of VS needed for a given
mapping.

Issue: #22308
This commit is contained in:
Brad King 2021-06-17 08:25:04 -04:00
parent 3fd65f5ca6
commit b0f830ced6
2 changed files with 18 additions and 8 deletions

View File

@ -1361,8 +1361,6 @@ static unsigned int cmLoadFlagTableSpecial(Json::Value entry,
namespace {
std::string const vsVer16_10_0 = "16.10.31321.278";
cmIDEFlagTable const* cmLoadFlagTableJson(std::string const& flagJsonPath,
cm::optional<std::string> vsVer)
{
@ -1380,18 +1378,22 @@ cmIDEFlagTable const* cmLoadFlagTableJson(std::string const& flagJsonPath,
if (reader.parse(stream, flags, false) && flags.isArray()) {
std::vector<cmIDEFlagTable> flagTable;
for (auto const& flag : flags) {
Json::Value const& vsminJson = flag["vsmin"];
if (vsminJson.isString()) {
std::string const& vsmin = vsminJson.asString();
if (!vsmin.empty()) {
if (!vsVer ||
cmSystemTools::VersionCompareGreater(vsmin, *vsVer)) {
continue;
}
}
}
cmIDEFlagTable flagEntry;
flagEntry.IDEName = cmLoadFlagTableString(flag, "name");
flagEntry.commandFlag = cmLoadFlagTableString(flag, "switch");
flagEntry.comment = cmLoadFlagTableString(flag, "comment");
flagEntry.value = cmLoadFlagTableString(flag, "value");
flagEntry.special = cmLoadFlagTableSpecial(flag, "flags");
// FIXME: Port this version check to a Json field.
if (vsVer &&
!cmSystemTools::VersionCompareGreaterEq(*vsVer, vsVer16_10_0) &&
flagEntry.IDEName == "ExternalWarningLevel") {
continue;
}
flagTable.push_back(flagEntry);
}
cmIDEFlagTable endFlag{ "", "", "", "", 0 };

View File

@ -572,6 +572,7 @@
"switch": "external:W0",
"comment": "Turn Off All Warnings",
"value": "TurnOffAllWarnings",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@ -579,6 +580,7 @@
"switch": "external:W1",
"comment": "Level1",
"value": "Level1",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@ -586,6 +588,7 @@
"switch": "external:W2",
"comment": "Level2",
"value": "Level2",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@ -593,6 +596,7 @@
"switch": "external:W3",
"comment": "Level3",
"value": "Level3",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@ -600,6 +604,7 @@
"switch": "external:W4",
"comment": "Level4",
"value": "Level4",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@ -1141,6 +1146,7 @@
"switch": "external:anglebrackets",
"comment": "Treat Files Included with Angle Brackets as External",
"value": "true",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@ -1148,6 +1154,7 @@
"switch": "external:templates-",
"comment": "Template Diagnostics in External Headers",
"value": "true",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@ -1277,6 +1284,7 @@
"switch": "external:env:",
"comment": "External Directories Environment Variables",
"value": "",
"vsmin": "16.10.31321.278",
"flags": [
"UserValue",
"SemicolonAppendable"