1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

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 { namespace {
std::string const vsVer16_10_0 = "16.10.31321.278";
cmIDEFlagTable const* cmLoadFlagTableJson(std::string const& flagJsonPath, cmIDEFlagTable const* cmLoadFlagTableJson(std::string const& flagJsonPath,
cm::optional<std::string> vsVer) cm::optional<std::string> vsVer)
{ {
@@ -1380,18 +1378,22 @@ cmIDEFlagTable const* cmLoadFlagTableJson(std::string const& flagJsonPath,
if (reader.parse(stream, flags, false) && flags.isArray()) { if (reader.parse(stream, flags, false) && flags.isArray()) {
std::vector<cmIDEFlagTable> flagTable; std::vector<cmIDEFlagTable> flagTable;
for (auto const& flag : flags) { 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; cmIDEFlagTable flagEntry;
flagEntry.IDEName = cmLoadFlagTableString(flag, "name"); flagEntry.IDEName = cmLoadFlagTableString(flag, "name");
flagEntry.commandFlag = cmLoadFlagTableString(flag, "switch"); flagEntry.commandFlag = cmLoadFlagTableString(flag, "switch");
flagEntry.comment = cmLoadFlagTableString(flag, "comment"); flagEntry.comment = cmLoadFlagTableString(flag, "comment");
flagEntry.value = cmLoadFlagTableString(flag, "value"); flagEntry.value = cmLoadFlagTableString(flag, "value");
flagEntry.special = cmLoadFlagTableSpecial(flag, "flags"); 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); flagTable.push_back(flagEntry);
} }
cmIDEFlagTable endFlag{ "", "", "", "", 0 }; cmIDEFlagTable endFlag{ "", "", "", "", 0 };

View File

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