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
+10 -8
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 };