summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2018-03-22 14:15:36 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-26 13:35:58 (GMT)
commita0d9429bd70426b6444d3987d7023fe40e203b88 (patch)
tree50458dbc1596acc7db050447af2ce1faa7d3bcf0
parent8aec07e0576a6121174a210dd3e3440a9f7105aa (diff)
downloadCMake-a0d9429bd70426b6444d3987d7023fe40e203b88.zip
CMake-a0d9429bd70426b6444d3987d7023fe40e203b88.tar.gz
CMake-a0d9429bd70426b6444d3987d7023fe40e203b88.tar.bz2
cmVisualStudioGeneratorOptions: Move XML code to subclasses
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx9
-rw-r--r--Source/cmLocalVisualStudio7Generator.h15
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx66
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h4
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx53
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h18
6 files changed, 82 insertions, 83 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 500a0aa..c7bb38cc 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -2065,6 +2065,15 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(
return ret;
}
+void cmVS7GeneratorOptions::OutputFlag(std::ostream& fout, const char* indent,
+ const char* tag,
+ const std::string& content)
+{
+ fout << indent << tag << "=\"";
+ fout << cmLocalVisualStudio7GeneratorEscapeForXML(content);
+ fout << "\"";
+}
+
// This class is used to parse an existing vs 7 project
// and extract the GUID
class cmVS7XMLParser : public cmXMLParser
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 02e6931..22b4264 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -21,6 +21,19 @@ class cmMakefile;
class cmSourceFile;
class cmSourceGroup;
+class cmVS7GeneratorOptions : public cmVisualStudioGeneratorOptions
+{
+public:
+ cmVS7GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
+ cmVS7FlagTable const* table = nullptr,
+ cmVS7FlagTable const* extraTable = nullptr)
+ : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable)
+ {
+ }
+ void OutputFlag(std::ostream& fout, const char* indent, const char* tag,
+ const std::string& content) override;
+};
+
/** \class cmLocalVisualStudio7Generator
* \brief Write Visual Studio .NET project files.
*
@@ -70,7 +83,7 @@ protected:
void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt);
private:
- typedef cmVisualStudioGeneratorOptions Options;
+ typedef cmVS7GeneratorOptions Options;
typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
const std::string& configName);
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 7e6e803..f1aed88 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -18,6 +18,16 @@
#include <iterator>
#include <memory> // IWYU pragma: keep
+static void ConvertToWindowsSlash(std::string& s);
+
+static std::string cmVS10EscapeXML(std::string arg)
+{
+ cmSystemTools::ReplaceString(arg, "&", "&amp;");
+ cmSystemTools::ReplaceString(arg, "<", "&lt;");
+ cmSystemTools::ReplaceString(arg, ">", "&gt;");
+ return arg;
+}
+
struct cmVisualStudio10TargetGenerator::Elem
{
cmGeneratedFileStream& S;
@@ -57,6 +67,37 @@ struct cmVisualStudio10TargetGenerator::Elem
}
};
+class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions
+{
+public:
+ cmVS10GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
+ cmVS7FlagTable const* table,
+ cmVisualStudio10TargetGenerator* g = nullptr)
+ : cmVisualStudioGeneratorOptions(lg, tool, table)
+ , TargetGenerator(g)
+ {
+ }
+
+ void OutputFlag(std::ostream& fout, const char* indent, const char* tag,
+ const std::string& content) override
+ {
+ if (!this->GetConfiguration().empty()) {
+ // if there are configuration specific flags, then
+ // use the configuration specific tag for PreprocessorDefinitions
+ fout << indent;
+ this->TargetGenerator->WritePlatformConfigTag(
+ tag, this->GetConfiguration(), 0, 0, 0, &fout);
+ } else {
+ fout << indent << "<" << tag << ">";
+ }
+ fout << cmVS10EscapeXML(content);
+ fout << "</" << tag << ">";
+ }
+
+private:
+ cmVisualStudio10TargetGenerator* TargetGenerator;
+};
+
inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag,
const char* val,
int indentLevel)
@@ -73,16 +114,6 @@ inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag,
(*this->BuildFileStream) << tag << ">" << val << "</" << tag << ">\n";
}
-static void ConvertToWindowsSlash(std::string& s);
-
-static std::string cmVS10EscapeXML(std::string arg)
-{
- cmSystemTools::ReplaceString(arg, "&", "&amp;");
- cmSystemTools::ReplaceString(arg, "<", "&lt;");
- cmSystemTools::ReplaceString(arg, ">", "&gt;");
- return arg;
-}
-
inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML(
const char* tag, std::string const& val, int indentLevel)
{
@@ -2048,9 +2079,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmGeneratorExpressionInterpreter genexInterpreter(
this->LocalGenerator, this->GeneratorTarget, config,
this->GeneratorTarget->GetName(), lang);
- cmVisualStudioGeneratorOptions clOptions(
+ cmVS10GeneratorOptions clOptions(
this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
- flagtable, 0, this);
+ flagtable, this);
if (compileAs) {
clOptions.AddFlag("CompileAs", compileAs);
}
@@ -2893,9 +2924,9 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
if (!libflags.empty()) {
this->WriteString("<Lib>\n", 2);
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
- cmVisualStudioGeneratorOptions libOptions(
- this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker,
- gg->GetLibFlagTable(), 0, this);
+ cmVS10GeneratorOptions libOptions(this->LocalGenerator,
+ cmVisualStudioGeneratorOptions::Linker,
+ gg->GetLibFlagTable(), this);
libOptions.Parse(libflags.c_str());
libOptions.PrependInheritedString("AdditionalOptions");
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
@@ -3063,9 +3094,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string const& config)
{
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
- auto pOptions =
- cm::make_unique<Options>(this->LocalGenerator, Options::Linker,
- gg->GetLinkFlagTable(), nullptr, this);
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::Linker, gg->GetLinkFlagTable(), this);
Options& linkOptions = *pOptions;
cmGeneratorTarget::LinkClosure const* linkClosure =
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index d557255..87f735d 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -21,7 +21,7 @@ class cmLocalVisualStudio7Generator;
class cmMakefile;
class cmSourceFile;
class cmSourceGroup;
-class cmVisualStudioGeneratorOptions;
+class cmVS10GeneratorOptions;
class cmVisualStudio10TargetGenerator
{
@@ -176,7 +176,7 @@ private:
void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link);
private:
- typedef cmVisualStudioGeneratorOptions Options;
+ typedef cmVS10GeneratorOptions Options;
typedef std::map<std::string, std::unique_ptr<Options>> OptionsMap;
OptionsMap ClOptions;
OptionsMap RcOptions;
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 7d7000b..26fce4b 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -4,47 +4,19 @@
#include "cmLocalVisualStudioGenerator.h"
#include "cmOutputConverter.h"
#include "cmSystemTools.h"
-#include "cmVisualStudio10TargetGenerator.h"
static void cmVS10EscapeForMSBuild(std::string& ret)
{
cmSystemTools::ReplaceString(ret, ";", "%3B");
}
-static std::string cmVisualStudio10GeneratorOptionsEscapeForXML(
- std::string ret)
-{
- cmSystemTools::ReplaceString(ret, "&", "&amp;");
- cmSystemTools::ReplaceString(ret, "<", "&lt;");
- cmSystemTools::ReplaceString(ret, ">", "&gt;");
- return ret;
-}
-
-static std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
-{
- cmSystemTools::ReplaceString(ret, "&", "&amp;");
- cmSystemTools::ReplaceString(ret, "\"", "&quot;");
- cmSystemTools::ReplaceString(ret, "<", "&lt;");
- cmSystemTools::ReplaceString(ret, ">", "&gt;");
- cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
- return ret;
-}
-
-cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
- cmLocalVisualStudioGenerator* lg, Tool tool,
- cmVisualStudio10TargetGenerator* g)
- : cmVisualStudioGeneratorOptions(lg, tool, nullptr, nullptr, g)
-{
-}
-
cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table,
- cmVS7FlagTable const* extraTable, cmVisualStudio10TargetGenerator* g)
+ cmVS7FlagTable const* extraTable)
: cmIDEOptions()
, LocalGenerator(lg)
, Version(lg->GetVersion())
, CurrentTool(tool)
- , TargetGenerator(g)
{
// Store the given flag tables.
this->AddTable(table);
@@ -444,28 +416,9 @@ void cmVisualStudioGeneratorOptions::SetConfiguration(
this->Configuration = config;
}
-void cmVisualStudioGeneratorOptions::OutputFlag(std::ostream& fout,
- const char* indent,
- const char* tag,
- const std::string& content)
+const std::string& cmVisualStudioGeneratorOptions::GetConfiguration() const
{
- if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
- if (!this->Configuration.empty()) {
- // if there are configuration specific flags, then
- // use the configuration specific tag for PreprocessorDefinitions
- fout << indent;
- this->TargetGenerator->WritePlatformConfigTag(tag, this->Configuration,
- 0, 0, 0, &fout);
- } else {
- fout << indent << "<" << tag << ">";
- }
- fout << cmVisualStudio10GeneratorOptionsEscapeForXML(content);
- fout << "</" << tag << ">";
- } else {
- fout << indent << tag << "=\"";
- fout << cmVisualStudioGeneratorOptionsEscapeForXML(content);
- fout << "\"";
- }
+ return this->Configuration;
}
void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 517760a..40290d1 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -16,8 +16,6 @@ class cmLocalVisualStudioGenerator;
typedef cmIDEFlagTable cmVS7FlagTable;
-class cmVisualStudio10TargetGenerator;
-
class cmVisualStudioGeneratorOptions : public cmIDEOptions
{
public:
@@ -34,12 +32,8 @@ public:
CSharpCompiler
};
cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
- cmVS7FlagTable const* table,
- cmVS7FlagTable const* extraTable = 0,
- cmVisualStudio10TargetGenerator* g = 0);
-
- cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
- cmVisualStudio10TargetGenerator* g = 0);
+ cmVS7FlagTable const* table = nullptr,
+ cmVS7FlagTable const* extraTable = nullptr);
// Add a table of flags.
void AddTable(cmVS7FlagTable const* table);
@@ -92,10 +86,11 @@ public:
const std::string& lang);
void OutputFlagMap(std::ostream& fout, const char* indent);
void SetConfiguration(const std::string& config);
+ const std::string& GetConfiguration() const;
-private:
- void OutputFlag(std::ostream& fout, const char* indent, const char* tag,
- const std::string& content);
+protected:
+ virtual void OutputFlag(std::ostream& fout, const char* indent,
+ const char* tag, const std::string& content) = 0;
private:
cmLocalVisualStudioGenerator* LocalGenerator;
@@ -103,7 +98,6 @@ private:
std::string Configuration;
Tool CurrentTool;
- cmVisualStudio10TargetGenerator* TargetGenerator;
bool FortranRuntimeDebug;
bool FortranRuntimeDLL;