summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-16 14:49:54 +0000
committerKitware Robot <kwrobot@kitware.com>2019-01-16 09:50:00 -0500
commita8b447d72e13b3356893737adba0a46ea065f70d (patch)
treee4f94e3c99f65b3c9be7ae05b6cdcb3fa7f52f1f /Source
parent68a30b50a5894d0425122ae4bbfd40b0492ff116 (diff)
parentc8ba777f6dfd7a5d8a4c4fa7b420bbdb5b93b366 (diff)
downloadcmake-a8b447d72e13b3356893737adba0a46ea065f70d.tar.gz
Merge topic 'support_per_toolset_json_flags'
c8ba777f6d GlobalVisualStudio10Generator: Support non-standard toolset json flag files. Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2772
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx116
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h4
-rw-r--r--Source/cmVisualStudio10ToolsetOptions.cxx30
-rw-r--r--Source/cmVisualStudio10ToolsetOptions.h20
4 files changed, 100 insertions, 70 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index f6c8012a79..79757a8751 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1138,14 +1138,32 @@ static cmIDEFlagTable const* cmLoadFlagTableJson(
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(
- 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;
- std::string filename = cmSystemTools::GetCMakeRoot() +
- "/Templates/MSBuild/FlagTables/" + flagTableName + "_" + table + ".json";
- ret = cmLoadFlagTableJson(filename);
+ std::string filename;
+ if (!optionsName.empty()) {
+ 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) {
cmMakefile* mf = this->GetCurrentMakefile();
@@ -1162,71 +1180,95 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const
{
- std::string flagTableName = this->ToolsetOptions.GetClFlagTableName(
- this->GetPlatformName(), this->GetPlatformToolsetString(),
- this->DefaultCLFlagTableName);
-
- return LoadFlagTable(flagTableName, "CL");
+ std::string optionsName = this->ToolsetOptions.GetClFlagTableName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultCLFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "CL");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable()
const
{
- std::string flagTableName = this->ToolsetOptions.GetCSharpFlagTableName(
- this->GetPlatformName(), this->GetPlatformToolsetString(),
- this->DefaultCSharpFlagTableName);
-
- return LoadFlagTable(flagTableName, "CSharp");
+ std::string optionsName = this->ToolsetOptions.GetCSharpFlagTableName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultCSharpFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const
{
- std::string flagTableName = this->ToolsetOptions.GetRcFlagTableName(
- this->GetPlatformName(), this->GetPlatformToolsetString(),
- this->DefaultRCFlagTableName);
-
- return LoadFlagTable(flagTableName, "RC");
+ std::string optionsName = this->ToolsetOptions.GetRcFlagTableName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultRCFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "RC");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const
{
- std::string flagTableName = this->ToolsetOptions.GetLibFlagTableName(
- this->GetPlatformName(), this->GetPlatformToolsetString(),
- this->DefaultLibFlagTableName);
-
- return LoadFlagTable(flagTableName, "LIB");
+ std::string optionsName = this->ToolsetOptions.GetLibFlagTableName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultLibFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const
{
- std::string flagTableName = this->ToolsetOptions.GetLinkFlagTableName(
- this->GetPlatformName(), this->GetPlatformToolsetString(),
- this->DefaultLinkFlagTableName);
-
- return LoadFlagTable(flagTableName, "Link");
+ std::string optionsName = this->ToolsetOptions.GetLinkFlagTableName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultLinkFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "Link");
}
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()
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
{
- std::string flagTableName = this->ToolsetOptions.GetMasmFlagTableName(
- this->GetPlatformName(), this->GetPlatformToolsetString(),
- this->DefaultMasmFlagTableName);
-
- return LoadFlagTable(flagTableName, "MASM");
+ std::string optionsName = this->ToolsetOptions.GetMasmFlagTableName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultMasmFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM");
}
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");
}
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 7f7c516c0c..7c8918ac98 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -142,7 +142,9 @@ protected:
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 GeneratorToolset;
diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx
index f71b8b74bb..39063ed917 100644
--- a/Source/cmVisualStudio10ToolsetOptions.cxx
+++ b/Source/cmVisualStudio10ToolsetOptions.cxx
@@ -7,8 +7,7 @@
#include "cmVisualStudioGeneratorOptions.h"
std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName(
- std::string const& name, std::string const& toolset,
- std::string const& defaultToolset) const
+ std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -23,13 +22,12 @@ std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName(
} else if (useToolset == "v100") {
return "v10";
} else {
- return this->GetToolsetName(name, defaultToolset);
+ return "";
}
}
std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName(
- std::string const& name, std::string const& toolset,
- std::string const& defaultToolset) const
+ std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -44,13 +42,12 @@ std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName(
} else if (useToolset == "v100") {
return "v10";
} else {
- return this->GetToolsetName(name, defaultToolset);
+ return "";
}
}
std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName(
- std::string const& name, std::string const& toolset,
- std::string const& defaultToolset) const
+ std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -63,13 +60,12 @@ std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName(
} else if (useToolset == "v100") {
return "v10";
} else {
- return this->GetToolsetName(name, defaultToolset);
+ return "";
}
}
std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName(
- std::string const& name, std::string const& toolset,
- std::string const& defaultToolset) const
+ std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -82,13 +78,12 @@ std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName(
} else if (useToolset == "v100") {
return "v10";
} else {
- return this->GetToolsetName(name, defaultToolset);
+ return "";
}
}
std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName(
- std::string const& name, std::string const& toolset,
- std::string const& defaultToolset) const
+ std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -103,13 +98,12 @@ std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName(
} else if (useToolset == "v100") {
return "v10";
} else {
- return this->GetToolsetName(name, defaultToolset);
+ return "";
}
}
std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName(
- std::string const& name, std::string const& toolset,
- std::string const& defaultToolset) const
+ std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
@@ -122,7 +116,7 @@ std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName(
} else if (useToolset == "v100") {
return "v10";
} else {
- return this->GetToolsetName(name, defaultToolset);
+ return "";
}
}
diff --git a/Source/cmVisualStudio10ToolsetOptions.h b/Source/cmVisualStudio10ToolsetOptions.h
index 43946f01f9..875a35b248 100644
--- a/Source/cmVisualStudio10ToolsetOptions.h
+++ b/Source/cmVisualStudio10ToolsetOptions.h
@@ -16,25 +16,17 @@ class cmVisualStudio10ToolsetOptions
{
public:
std::string GetClFlagTableName(std::string const& name,
- std::string const& toolset,
- std::string const& defaultToolset) const;
+ std::string const& toolset) const;
std::string GetCSharpFlagTableName(std::string const& name,
- std::string const& toolset,
- std::string const& defaultToolset) const;
+ std::string const& toolset) const;
std::string GetRcFlagTableName(std::string const& name,
- std::string const& toolset,
- std::string const& defaultToolset) const;
+ std::string const& toolset) const;
std::string GetLibFlagTableName(std::string const& name,
- std::string const& toolset,
- std::string const& defaultToolset) const;
+ std::string const& toolset) const;
std::string GetLinkFlagTableName(std::string const& name,
- std::string const& toolset,
- std::string const& defaultToolset) const;
+ std::string const& toolset) const;
std::string GetMasmFlagTableName(std::string const& name,
- std::string const& toolset,
- std::string const& defaultToolset) const;
-
-private:
+ std::string const& toolset) const;
std::string GetToolsetName(std::string const& name,
std::string const& toolset) const;
};