GlobalVisualStudio10Generator: Support non-standard toolset json flag files.

If given a toolset that does not have an explicit mapping in
cmVisualStudio10ToolsetOptions, check for a json flag file using the
toolset name before trying the default toolset for the generator.
This commit is contained in:
Stephan Szabo
2019-01-03 12:54:24 -08:00
parent 6b163fc6e5
commit c8ba777f6d
4 changed files with 100 additions and 70 deletions
+79 -37
View File
@@ -1123,14 +1123,32 @@ static cmIDEFlagTable const* cmLoadFlagTableJson(
return ret; return ret;
} }
static std::string cmGetFlagTableName(std::string const& toolsetName,
std::string const& table)
{
return cmSystemTools::GetCMakeRoot() + "/Templates/MSBuild/FlagTables/" +
toolsetName + "_" + table + ".json";
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
std::string const& flagTableName, std::string const& table) const std::string const& optionsName, std::string const& toolsetName,
std::string const& defaultName, std::string const& table) const
{ {
cmIDEFlagTable const* ret = nullptr; cmIDEFlagTable const* ret = nullptr;
std::string filename = cmSystemTools::GetCMakeRoot() + std::string filename;
"/Templates/MSBuild/FlagTables/" + flagTableName + "_" + table + ".json"; if (!optionsName.empty()) {
ret = cmLoadFlagTableJson(filename); filename = cmGetFlagTableName(optionsName, table);
ret = cmLoadFlagTableJson(filename);
} else {
filename = cmGetFlagTableName(toolsetName, table);
if (cmSystemTools::FileExists(filename)) {
ret = cmLoadFlagTableJson(filename);
} else {
filename = cmGetFlagTableName(defaultName, table);
ret = cmLoadFlagTableJson(filename);
}
}
if (!ret) { if (!ret) {
cmMakefile* mf = this->GetCurrentMakefile(); cmMakefile* mf = this->GetCurrentMakefile();
@@ -1147,71 +1165,95 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const
{ {
std::string flagTableName = this->ToolsetOptions.GetClFlagTableName( std::string optionsName = this->ToolsetOptions.GetClFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString(), this->GetPlatformName(), this->GetPlatformToolsetString());
this->DefaultCLFlagTableName); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
return LoadFlagTable(flagTableName, "CL"); std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultCLFlagTableName);
return LoadFlagTable(optionsName, toolsetName, defaultName, "CL");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable()
const const
{ {
std::string flagTableName = this->ToolsetOptions.GetCSharpFlagTableName( std::string optionsName = this->ToolsetOptions.GetCSharpFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString(), this->GetPlatformName(), this->GetPlatformToolsetString());
this->DefaultCSharpFlagTableName); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
return LoadFlagTable(flagTableName, "CSharp"); std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultCSharpFlagTableName);
return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const
{ {
std::string flagTableName = this->ToolsetOptions.GetRcFlagTableName( std::string optionsName = this->ToolsetOptions.GetRcFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString(), this->GetPlatformName(), this->GetPlatformToolsetString());
this->DefaultRCFlagTableName); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
return LoadFlagTable(flagTableName, "RC"); std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultRCFlagTableName);
return LoadFlagTable(optionsName, toolsetName, defaultName, "RC");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const
{ {
std::string flagTableName = this->ToolsetOptions.GetLibFlagTableName( std::string optionsName = this->ToolsetOptions.GetLibFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString(), this->GetPlatformName(), this->GetPlatformToolsetString());
this->DefaultLibFlagTableName); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
return LoadFlagTable(flagTableName, "LIB"); std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultLibFlagTableName);
return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const
{ {
std::string flagTableName = this->ToolsetOptions.GetLinkFlagTableName( std::string optionsName = this->ToolsetOptions.GetLinkFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString(), this->GetPlatformName(), this->GetPlatformToolsetString());
this->DefaultLinkFlagTableName); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
return LoadFlagTable(flagTableName, "Link"); std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultLinkFlagTableName);
return LoadFlagTable(optionsName, toolsetName, defaultName, "Link");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const
{ {
return LoadFlagTable(this->DefaultCudaFlagTableName, "Cuda"); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultCudaFlagTableName);
return LoadFlagTable("", toolsetName, defaultName, "Cuda");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable()
const const
{ {
return LoadFlagTable(this->DefaultCudaHostFlagTableName, "CudaHost"); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultCudaHostFlagTableName);
return LoadFlagTable("", toolsetName, defaultName, "CudaHost");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const
{ {
std::string flagTableName = this->ToolsetOptions.GetMasmFlagTableName( std::string optionsName = this->ToolsetOptions.GetMasmFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString(), this->GetPlatformName(), this->GetPlatformToolsetString());
this->DefaultMasmFlagTableName); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
return LoadFlagTable(flagTableName, "MASM"); std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultMasmFlagTableName);
return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM");
} }
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const
{ {
return LoadFlagTable(this->DefaultNasmFlagTableName, "NASM"); std::string toolsetName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->GetPlatformToolsetString());
std::string defaultName = this->ToolsetOptions.GetToolsetName(
this->GetPlatformName(), this->DefaultNasmFlagTableName);
return LoadFlagTable("", toolsetName, defaultName, "NASM");
} }
+3 -1
View File
@@ -144,7 +144,9 @@ protected:
std::string const& GetMSBuildCommand(); std::string const& GetMSBuildCommand();
cmIDEFlagTable const* LoadFlagTable(std::string const& flagTableName, cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName,
std::string const& toolsetName,
std::string const& defaultName,
std::string const& table) const; std::string const& table) const;
std::string GeneratorToolset; std::string GeneratorToolset;
+12 -18
View File
@@ -7,8 +7,7 @@
#include "cmVisualStudioGeneratorOptions.h" #include "cmVisualStudioGeneratorOptions.h"
std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName( std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName(
std::string const& name, std::string const& toolset, std::string const& name, std::string const& toolset) const
std::string const& defaultToolset) const
{ {
std::string const useToolset = this->GetToolsetName(name, toolset); std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -23,13 +22,12 @@ std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName(
} else if (useToolset == "v100") { } else if (useToolset == "v100") {
return "v10"; return "v10";
} else { } else {
return this->GetToolsetName(name, defaultToolset); return "";
} }
} }
std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName( std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName(
std::string const& name, std::string const& toolset, std::string const& name, std::string const& toolset) const
std::string const& defaultToolset) const
{ {
std::string const useToolset = this->GetToolsetName(name, toolset); std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -44,13 +42,12 @@ std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName(
} else if (useToolset == "v100") { } else if (useToolset == "v100") {
return "v10"; return "v10";
} else { } else {
return this->GetToolsetName(name, defaultToolset); return "";
} }
} }
std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName( std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName(
std::string const& name, std::string const& toolset, std::string const& name, std::string const& toolset) const
std::string const& defaultToolset) const
{ {
std::string const useToolset = this->GetToolsetName(name, toolset); std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -63,13 +60,12 @@ std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName(
} else if (useToolset == "v100") { } else if (useToolset == "v100") {
return "v10"; return "v10";
} else { } else {
return this->GetToolsetName(name, defaultToolset); return "";
} }
} }
std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName( std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName(
std::string const& name, std::string const& toolset, std::string const& name, std::string const& toolset) const
std::string const& defaultToolset) const
{ {
std::string const useToolset = this->GetToolsetName(name, toolset); std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -82,13 +78,12 @@ std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName(
} else if (useToolset == "v100") { } else if (useToolset == "v100") {
return "v10"; return "v10";
} else { } else {
return this->GetToolsetName(name, defaultToolset); return "";
} }
} }
std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName( std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName(
std::string const& name, std::string const& toolset, std::string const& name, std::string const& toolset) const
std::string const& defaultToolset) const
{ {
std::string const useToolset = this->GetToolsetName(name, toolset); std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -103,13 +98,12 @@ std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName(
} else if (useToolset == "v100") { } else if (useToolset == "v100") {
return "v10"; return "v10";
} else { } else {
return this->GetToolsetName(name, defaultToolset); return "";
} }
} }
std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName( std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName(
std::string const& name, std::string const& toolset, std::string const& name, std::string const& toolset) const
std::string const& defaultToolset) const
{ {
std::string const useToolset = this->GetToolsetName(name, toolset); std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -122,7 +116,7 @@ std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName(
} else if (useToolset == "v100") { } else if (useToolset == "v100") {
return "v10"; return "v10";
} else { } else {
return this->GetToolsetName(name, defaultToolset); return "";
} }
} }
+6 -14
View File
@@ -16,25 +16,17 @@ class cmVisualStudio10ToolsetOptions
{ {
public: public:
std::string GetClFlagTableName(std::string const& name, std::string GetClFlagTableName(std::string const& name,
std::string const& toolset, std::string const& toolset) const;
std::string const& defaultToolset) const;
std::string GetCSharpFlagTableName(std::string const& name, std::string GetCSharpFlagTableName(std::string const& name,
std::string const& toolset, std::string const& toolset) const;
std::string const& defaultToolset) const;
std::string GetRcFlagTableName(std::string const& name, std::string GetRcFlagTableName(std::string const& name,
std::string const& toolset, std::string const& toolset) const;
std::string const& defaultToolset) const;
std::string GetLibFlagTableName(std::string const& name, std::string GetLibFlagTableName(std::string const& name,
std::string const& toolset, std::string const& toolset) const;
std::string const& defaultToolset) const;
std::string GetLinkFlagTableName(std::string const& name, std::string GetLinkFlagTableName(std::string const& name,
std::string const& toolset, std::string const& toolset) const;
std::string const& defaultToolset) const;
std::string GetMasmFlagTableName(std::string const& name, std::string GetMasmFlagTableName(std::string const& name,
std::string const& toolset, std::string const& toolset) const;
std::string const& defaultToolset) const;
private:
std::string GetToolsetName(std::string const& name, std::string GetToolsetName(std::string const& name,
std::string const& toolset) const; std::string const& toolset) const;
}; };