summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-17 10:45:51 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-06-17 10:45:57 (GMT)
commitcd73f3736b64ab075378f7ef52c53ca13e4d8a21 (patch)
tree40fbb52a569133b92f36b9a6d67e47ab7223a291
parenta9ff600a509d6af1c25f482e1ce0184c97dd3f54 (diff)
parent947f0c8b811a2f5b0681590b449125e07a74ae0f (diff)
downloadCMake-cd73f3736b64ab075378f7ef52c53ca13e4d8a21.zip
CMake-cd73f3736b64ab075378f7ef52c53ca13e4d8a21.tar.gz
CMake-cd73f3736b64ab075378f7ef52c53ca13e4d8a21.tar.bz2
Merge topic 'vs-map-external-warnings' into release-3.20
947f0c8b81 VS: Do not apply '/external:W*' flag table mapping on VS < 16.10 e59a208b69 cmGlobalVisualStudio10Generator: Adopt GetVSInstanceVersion method d6d4af0ec3 cmGlobalVisualStudio10Generator: Move static functions to anonymous namespace Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6233
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx26
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h7
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx17
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.h2
4 files changed, 38 insertions, 14 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index badce2e..b911eef 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1313,8 +1313,12 @@ static unsigned int cmLoadFlagTableSpecial(Json::Value entry,
return value;
}
-static cmIDEFlagTable const* cmLoadFlagTableJson(
- std::string const& flagJsonPath)
+namespace {
+
+unsigned long long const vsVer16_10_0 = 4503644629696790;
+
+cmIDEFlagTable const* cmLoadFlagTableJson(
+ std::string const& flagJsonPath, cm::optional<unsigned long long> vsver)
{
cmIDEFlagTable* ret = nullptr;
auto savedFlagIterator = loadedFlagJsonFiles.find(flagJsonPath);
@@ -1336,6 +1340,11 @@ static cmIDEFlagTable const* cmLoadFlagTableJson(
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 && *vsver < vsVer16_10_0 &&
+ flagEntry.IDEName == "ExternalWarningLevel") {
+ continue;
+ }
flagTable.push_back(flagEntry);
}
cmIDEFlagTable endFlag{ "", "", "", "", 0 };
@@ -1349,12 +1358,13 @@ static cmIDEFlagTable const* cmLoadFlagTableJson(
return ret;
}
-static std::string cmGetFlagTableName(std::string const& toolsetName,
- std::string const& table)
+std::string cmGetFlagTableName(std::string const& toolsetName,
+ std::string const& table)
{
return cmSystemTools::GetCMakeRoot() + "/Templates/MSBuild/FlagTables/" +
toolsetName + "_" + table + ".json";
}
+}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
std::string const& optionsName, std::string const& toolsetName,
@@ -1362,17 +1372,19 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
{
cmIDEFlagTable const* ret = nullptr;
+ cm::optional<unsigned long long> vsver = this->GetVSInstanceVersion();
+
std::string filename;
if (!optionsName.empty()) {
filename = cmGetFlagTableName(optionsName, table);
- ret = cmLoadFlagTableJson(filename);
+ ret = cmLoadFlagTableJson(filename, vsver);
} else {
filename = cmGetFlagTableName(toolsetName, table);
if (cmSystemTools::FileExists(filename)) {
- ret = cmLoadFlagTableJson(filename);
+ ret = cmLoadFlagTableJson(filename, vsver);
} else {
filename = cmGetFlagTableName(defaultName, table);
- ret = cmLoadFlagTableJson(filename);
+ ret = cmLoadFlagTableJson(filename, vsver);
}
}
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 8d30ef8..5022a0f 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -5,6 +5,8 @@
#include <memory>
#include <set>
+#include <cm/optional>
+
#include "cmGlobalVisualStudio8Generator.h"
#include "cmVisualStudio10ToolsetOptions.h"
@@ -119,6 +121,11 @@ public:
std::string Encoding() override;
const char* GetToolsVersion() const;
+ virtual cm::optional<unsigned long long> GetVSInstanceVersion() const
+ {
+ return {};
+ }
+
bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
bool FindMakeProgram(cmMakefile* mf) override;
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index c11ab1b..50dc30b 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -391,10 +391,15 @@ bool cmGlobalVisualStudioVersionedGenerator::GetVSInstance(
return vsSetupAPIHelper.GetVSInstanceInfo(dir);
}
-bool cmGlobalVisualStudioVersionedGenerator::GetVSInstanceVersion(
- unsigned long long& vsInstanceVersion) const
+cm::optional<unsigned long long>
+cmGlobalVisualStudioVersionedGenerator::GetVSInstanceVersion() const
{
- return vsSetupAPIHelper.GetVSInstanceVersion(vsInstanceVersion);
+ cm::optional<unsigned long long> result;
+ unsigned long long vsInstanceVersion;
+ if (vsSetupAPIHelper.GetVSInstanceVersion(vsInstanceVersion)) {
+ result = vsInstanceVersion;
+ }
+ return result;
}
bool cmGlobalVisualStudioVersionedGenerator::IsStdOutEncodingSupported() const
@@ -407,9 +412,9 @@ bool cmGlobalVisualStudioVersionedGenerator::IsStdOutEncodingSupported() const
return false;
}
unsigned long long const vsInstanceVersion16_7_P2 = 4503631666610212;
- unsigned long long vsInstanceVersion;
- return (this->GetVSInstanceVersion(vsInstanceVersion) &&
- vsInstanceVersion > vsInstanceVersion16_7_P2);
+ cm::optional<unsigned long long> vsInstanceVersion =
+ this->GetVSInstanceVersion();
+ return (vsInstanceVersion && *vsInstanceVersion > vsInstanceVersion16_7_P2);
}
const char*
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h
index cee129e..105e495 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.h
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.h
@@ -28,7 +28,7 @@ public:
bool GetVSInstance(std::string& dir) const;
- bool GetVSInstanceVersion(unsigned long long& vsInstanceVersion) const;
+ cm::optional<unsigned long long> GetVSInstanceVersion() const override;
AuxToolset FindAuxToolset(std::string& version,
std::string& props) const override;