mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
cmVisualStudioGeneratorOptions: Move XML code to subclasses
This commit is contained in:
committed by
Brad King
parent
8aec07e057
commit
a0d9429bd7
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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, "&", "&");
|
||||
cmSystemTools::ReplaceString(arg, "<", "<");
|
||||
cmSystemTools::ReplaceString(arg, ">", ">");
|
||||
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, "&", "&");
|
||||
cmSystemTools::ReplaceString(arg, "<", "<");
|
||||
cmSystemTools::ReplaceString(arg, ">", ">");
|
||||
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 =
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, "&", "&");
|
||||
cmSystemTools::ReplaceString(ret, "<", "<");
|
||||
cmSystemTools::ReplaceString(ret, ">", ">");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
|
||||
{
|
||||
cmSystemTools::ReplaceString(ret, "&", "&");
|
||||
cmSystemTools::ReplaceString(ret, "\"", """);
|
||||
cmSystemTools::ReplaceString(ret, "<", "<");
|
||||
cmSystemTools::ReplaceString(ret, ">", ">");
|
||||
cmSystemTools::ReplaceString(ret, "\n", "
");
|
||||
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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user