1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 19:43:23 +08:00

VS: improve options generation

Make use of the `Elem` and `OptionsHelper` classes; some cleanup
This commit is contained in:
Vitaly Stakhovsky
2018-05-05 17:35:37 -04:00
parent 135825df20
commit e76a0c6071
2 changed files with 99 additions and 124 deletions

View File

@@ -77,23 +77,14 @@ struct cmVisualStudio10TargetGenerator::Elem
this->WriteString("<") << tag; this->WriteString("<") << tag;
return *this; return *this;
} }
template <typename T>
void WriteElem(const char* tag, const T& val)
{
this->WriteString("<") << tag << ">" << val << "</" << tag << ">\n";
}
void Element(const char* tag, const std::string& val) void Element(const char* tag, const std::string& val)
{ {
Elem(*this).WriteElem(tag, cmVS10EscapeXML(val)); Elem(*this).WriteString("<") << tag << ">" << cmVS10EscapeXML(val) << "</"
} << tag << ">\n";
template <typename T>
void Attr(const char* an, const T& av)
{
this->S << " " << an << "=\"" << av << "\"";
} }
Elem& Attribute(const char* an, const std::string& av) Elem& Attribute(const char* an, const std::string& av)
{ {
Attr(an, cmVS10EscapeAttr(av)); this->S << " " << an << "=\"" << cmVS10EscapeAttr(av) << "\"";
return *this; return *this;
} }
// This method for now assumes that this->Tag has been set, e.g. by calling // This method for now assumes that this->Tag has been set, e.g. by calling
@@ -117,6 +108,7 @@ struct cmVisualStudio10TargetGenerator::Elem
class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions
{ {
public: public:
typedef cmVisualStudio10TargetGenerator::Elem Elem;
cmVS10GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool, cmVS10GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
cmVS7FlagTable const* table, cmVS7FlagTable const* table,
cmVisualStudio10TargetGenerator* g = nullptr) cmVisualStudio10TargetGenerator* g = nullptr)
@@ -125,48 +117,50 @@ public:
{ {
} }
void OutputFlag(std::ostream& fout, int indent, const char* tag, void OutputFlag(std::ostream& /*fout*/, int /*indent*/, const char* tag,
const std::string& content) override const std::string& content) override
{ {
if (!this->GetConfiguration().empty()) { if (!this->GetConfiguration().empty()) {
// if there are configuration specific flags, then // if there are configuration specific flags, then
// use the configuration specific tag for PreprocessorDefinitions // use the configuration specific tag for PreprocessorDefinitions
this->TargetGenerator->WritePlatformConfigTag( this->TargetGenerator->WritePlatformConfigTag(
tag, this->GetConfiguration(), indent, content); tag, this->GetConfiguration(), *Parent, content);
} else { } else {
fout.fill(' '); Parent->Element(tag, content);
fout.width(indent * 2);
// write an empty string to get the fill level indent to print
fout << "";
fout << "<" << tag << ">";
fout << cmVS10EscapeXML(content);
fout << "</" << tag << ">\n";
} }
} }
private: private:
cmVisualStudio10TargetGenerator* TargetGenerator; cmVisualStudio10TargetGenerator* const TargetGenerator;
Elem* Parent = nullptr;
friend cmVisualStudio10TargetGenerator::OptionsHelper;
}; };
inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag, struct cmVisualStudio10TargetGenerator::OptionsHelper
const char* val,
int indentLevel)
{ {
Elem(*this->BuildFileStream, indentLevel).WriteElem(tag, val); cmVS10GeneratorOptions& O;
} OptionsHelper(cmVS10GeneratorOptions& o, Elem& e)
: O(o)
{
O.Parent = &e;
}
~OptionsHelper() { O.Parent = nullptr; }
inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag, void OutputPreprocessorDefinitions(const std::string& lang)
std::string const& val, {
int indentLevel) O.OutputPreprocessorDefinitions(O.Parent->S, O.Parent->Indent + 1, lang);
{ }
Elem(*this->BuildFileStream, indentLevel).WriteElem(tag, val); void OutputAdditionalIncludeDirectories(const std::string& lang)
} {
O.OutputAdditionalIncludeDirectories(O.Parent->S, O.Parent->Indent + 1,
inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML( lang);
const char* tag, std::string const& val, int indentLevel) }
{ void OutputFlagMap() { O.OutputFlagMap(O.Parent->S, O.Parent->Indent + 1); }
this->WriteElem(tag, cmVS10EscapeXML(val), indentLevel); void PrependInheritedString(std::string const& key)
} {
O.PrependInheritedString(key);
}
};
static std::string cmVS10EscapeComment(std::string comment) static std::string cmVS10EscapeComment(std::string comment)
{ {
@@ -275,18 +269,12 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition(
} }
void cmVisualStudio10TargetGenerator::WritePlatformConfigTag( void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
const char* tag, const std::string& config, int indentLevel, const char* tag, const std::string& config, Elem& parent,
const std::string& content) const std::string& content)
{ {
std::ostream& stream = *this->BuildFileStream; Elem(parent, tag)
stream.fill(' '); .Attribute("Condition", this->CalcCondition(config))
stream.width(indentLevel * 2); .Content(content);
stream << ""; // applies indentation
stream << "<" << tag << " Condition=\"";
stream << this->CalcCondition(config);
stream << "\"";
stream << ">" << cmVS10EscapeXML(content);
stream << "</" << tag << ">\n";
} }
std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString( std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
@@ -847,7 +835,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
s = "$(RootNamespace)."; s = "$(RootNamespace).";
} }
s += "%(Filename).resources"; s += "%(Filename).resources";
this->WritePlatformConfigTag("LogicalName", i, e2.Indent + 1, s); this->WritePlatformConfigTag("LogicalName", i, e2, s);
} }
} else { } else {
std::string binDir = this->Makefile->GetCurrentBinaryDirectory(); std::string binDir = this->Makefile->GetCurrentBinaryDirectory();
@@ -1179,7 +1167,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
e1.Element("StartProgram", outDir + assemblyName + ".exe"); e1.Element("StartProgram", outDir + assemblyName + ".exe");
} }
o.OutputFlagMap(e1.S, e1.Indent + 1); OptionsHelper oh(o, e1);
oh.OutputFlagMap();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -2127,7 +2116,6 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
// use them // use them
if (!flags.empty() || !options.empty() || !configDefines.empty() || if (!flags.empty() || !options.empty() || !configDefines.empty() ||
!includes.empty() || compileAs || noWinRT) { !includes.empty() || compileAs || noWinRT) {
e2.SetHasElements();
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
cmIDEFlagTable const* flagtable = nullptr; cmIDEFlagTable const* flagtable = nullptr;
const std::string& srclang = source->GetLanguage(); const std::string& srclang = source->GetLanguage();
@@ -2193,10 +2181,11 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
} }
clOptions.AddIncludes(includeList); clOptions.AddIncludes(includeList);
clOptions.SetConfiguration(config); clOptions.SetConfiguration(config);
clOptions.PrependInheritedString("AdditionalOptions"); OptionsHelper oh(clOptions, e2);
clOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, lang); oh.PrependInheritedString("AdditionalOptions");
clOptions.OutputFlagMap(e2.S, e2.Indent + 1); oh.OutputAdditionalIncludeDirectories(lang);
clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, lang); oh.OutputFlagMap();
oh.OutputPreprocessorDefinitions(lang);
} }
} }
if (this->IsXamlSource(source->GetFullPath())) { if (this->IsXamlSource(source->GetFullPath())) {
@@ -2250,7 +2239,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
for (std::string const& config : this->Configurations) { for (std::string const& config : this->Configurations) {
if (ttype >= cmStateEnums::UTILITY) { if (ttype >= cmStateEnums::UTILITY) {
this->WritePlatformConfigTag( this->WritePlatformConfigTag(
"IntDir", config, e1.Indent + 1, "IntDir", config, e1,
"$(Platform)\\$(Configuration)\\$(ProjectName)\\"); "$(Platform)\\$(Configuration)\\$(ProjectName)\\");
} else { } else {
std::string intermediateDir = std::string intermediateDir =
@@ -2271,68 +2260,67 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
ConvertToWindowsSlash(intermediateDir); ConvertToWindowsSlash(intermediateDir);
ConvertToWindowsSlash(outDir); ConvertToWindowsSlash(outDir);
this->WritePlatformConfigTag("OutDir", config, e1.Indent + 1, outDir); this->WritePlatformConfigTag("OutDir", config, e1, outDir);
this->WritePlatformConfigTag("IntDir", config, e1.Indent + 1, this->WritePlatformConfigTag("IntDir", config, e1, intermediateDir);
intermediateDir);
if (const char* sdkExecutableDirectories = this->Makefile->GetDefinition( if (const char* sdkExecutableDirectories = this->Makefile->GetDefinition(
"CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES")) { "CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES")) {
this->WritePlatformConfigTag("ExecutablePath", config, e1.Indent + 1, this->WritePlatformConfigTag("ExecutablePath", config, e1,
sdkExecutableDirectories); sdkExecutableDirectories);
} }
if (const char* sdkIncludeDirectories = this->Makefile->GetDefinition( if (const char* sdkIncludeDirectories = this->Makefile->GetDefinition(
"CMAKE_VS_SDK_INCLUDE_DIRECTORIES")) { "CMAKE_VS_SDK_INCLUDE_DIRECTORIES")) {
this->WritePlatformConfigTag("IncludePath", config, e1.Indent + 1, this->WritePlatformConfigTag("IncludePath", config, e1,
sdkIncludeDirectories); sdkIncludeDirectories);
} }
if (const char* sdkReferenceDirectories = this->Makefile->GetDefinition( if (const char* sdkReferenceDirectories = this->Makefile->GetDefinition(
"CMAKE_VS_SDK_REFERENCE_DIRECTORIES")) { "CMAKE_VS_SDK_REFERENCE_DIRECTORIES")) {
this->WritePlatformConfigTag("ReferencePath", config, e1.Indent + 1, this->WritePlatformConfigTag("ReferencePath", config, e1,
sdkReferenceDirectories); sdkReferenceDirectories);
} }
if (const char* sdkLibraryDirectories = this->Makefile->GetDefinition( if (const char* sdkLibraryDirectories = this->Makefile->GetDefinition(
"CMAKE_VS_SDK_LIBRARY_DIRECTORIES")) { "CMAKE_VS_SDK_LIBRARY_DIRECTORIES")) {
this->WritePlatformConfigTag("LibraryPath", config, e1.Indent + 1, this->WritePlatformConfigTag("LibraryPath", config, e1,
sdkLibraryDirectories); sdkLibraryDirectories);
} }
if (const char* sdkLibraryWDirectories = this->Makefile->GetDefinition( if (const char* sdkLibraryWDirectories = this->Makefile->GetDefinition(
"CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES")) { "CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES")) {
this->WritePlatformConfigTag("LibraryWPath", config, e1.Indent + 1, this->WritePlatformConfigTag("LibraryWPath", config, e1,
sdkLibraryWDirectories); sdkLibraryWDirectories);
} }
if (const char* sdkSourceDirectories = if (const char* sdkSourceDirectories =
this->Makefile->GetDefinition("CMAKE_VS_SDK_SOURCE_DIRECTORIES")) { this->Makefile->GetDefinition("CMAKE_VS_SDK_SOURCE_DIRECTORIES")) {
this->WritePlatformConfigTag("SourcePath", config, e1.Indent + 1, this->WritePlatformConfigTag("SourcePath", config, e1,
sdkSourceDirectories); sdkSourceDirectories);
} }
if (const char* sdkExcludeDirectories = this->Makefile->GetDefinition( if (const char* sdkExcludeDirectories = this->Makefile->GetDefinition(
"CMAKE_VS_SDK_EXCLUDE_DIRECTORIES")) { "CMAKE_VS_SDK_EXCLUDE_DIRECTORIES")) {
this->WritePlatformConfigTag("ExcludePath", config, e1.Indent + 1, this->WritePlatformConfigTag("ExcludePath", config, e1,
sdkExcludeDirectories); sdkExcludeDirectories);
} }
if (const char* workingDir = this->GeneratorTarget->GetProperty( if (const char* workingDir = this->GeneratorTarget->GetProperty(
"VS_DEBUGGER_WORKING_DIRECTORY")) { "VS_DEBUGGER_WORKING_DIRECTORY")) {
this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", config, this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", config,
e1.Indent + 1, workingDir); e1, workingDir);
} }
if (const char* debuggerCommand = if (const char* debuggerCommand =
this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) { this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) {
this->WritePlatformConfigTag("LocalDebuggerCommand", config, this->WritePlatformConfigTag("LocalDebuggerCommand", config, e1,
e1.Indent + 1, debuggerCommand); debuggerCommand);
} }
std::string name = std::string name =
cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
this->WritePlatformConfigTag("TargetName", config, e1.Indent + 1, name); this->WritePlatformConfigTag("TargetName", config, e1, name);
std::string ext = std::string ext =
cmSystemTools::GetFilenameLastExtension(targetNameFull); cmSystemTools::GetFilenameLastExtension(targetNameFull);
@@ -2341,7 +2329,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
// A single "." appears to be treated as an empty extension. // A single "." appears to be treated as an empty extension.
ext = "."; ext = ".";
} }
this->WritePlatformConfigTag("TargetExt", config, e1.Indent + 1, ext); this->WritePlatformConfigTag("TargetExt", config, e1, ext);
this->OutputLinkIncremental(e1, config); this->OutputLinkIncremental(e1, config);
} }
@@ -2367,12 +2355,12 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
Options& linkOptions = *(this->LinkOptions[configName]); Options& linkOptions = *(this->LinkOptions[configName]);
const char* incremental = linkOptions.GetFlag("LinkIncremental"); const char* incremental = linkOptions.GetFlag("LinkIncremental");
this->WritePlatformConfigTag("LinkIncremental", configName, e1.Indent + 1, this->WritePlatformConfigTag("LinkIncremental", configName, e1,
(incremental ? incremental : "true")); (incremental ? incremental : "true"));
linkOptions.RemoveFlag("LinkIncremental"); linkOptions.RemoveFlag("LinkIncremental");
const char* manifest = linkOptions.GetFlag("GenerateManifest"); const char* manifest = linkOptions.GetFlag("GenerateManifest");
this->WritePlatformConfigTag("GenerateManifest", configName, e1.Indent + 1, this->WritePlatformConfigTag("GenerateManifest", configName, e1,
(manifest ? manifest : "true")); (manifest ? manifest : "true"));
linkOptions.RemoveFlag("GenerateManifest"); linkOptions.RemoveFlag("GenerateManifest");
@@ -2382,7 +2370,7 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
for (const char** f = flags; *f; ++f) { for (const char** f = flags; *f; ++f) {
const char* flag = *f; const char* flag = *f;
if (const char* value = linkOptions.GetFlag(flag)) { if (const char* value = linkOptions.GetFlag(flag)) {
this->WritePlatformConfigTag(flag, configName, e1.Indent + 1, value); this->WritePlatformConfigTag(flag, configName, e1, value);
linkOptions.RemoveFlag(flag); linkOptions.RemoveFlag(flag);
} }
} }
@@ -2612,13 +2600,11 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
return; return;
} }
Elem e2(e1, "ClCompile"); Elem e2(e1, "ClCompile");
e2.SetHasElements(); OptionsHelper oh(clOptions, e2);
clOptions.PrependInheritedString("AdditionalOptions"); oh.PrependInheritedString("AdditionalOptions");
clOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, oh.OutputAdditionalIncludeDirectories(this->LangForClCompile);
this->LangForClCompile); oh.OutputFlagMap();
clOptions.OutputFlagMap(e2.S, e2.Indent + 1); oh.OutputPreprocessorDefinitions(this->LangForClCompile);
clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1,
this->LangForClCompile);
if (this->NsightTegra) { if (this->NsightTegra) {
if (const char* processMax = if (const char* processMax =
@@ -2714,13 +2700,12 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions(
return; return;
} }
Elem e2(e1, "ResourceCompile"); Elem e2(e1, "ResourceCompile");
e2.SetHasElements();
Options& rcOptions = *(this->RcOptions[configName]); OptionsHelper rcOptions(*(this->RcOptions[configName]), e2);
rcOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "RC"); rcOptions.OutputPreprocessorDefinitions("RC");
rcOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, "RC"); rcOptions.OutputAdditionalIncludeDirectories("RC");
rcOptions.PrependInheritedString("AdditionalOptions"); rcOptions.PrependInheritedString("AdditionalOptions");
rcOptions.OutputFlagMap(e2.S, e2.Indent + 1); rcOptions.OutputFlagMap();
e2.EndElement(); e2.EndElement();
} }
@@ -2863,13 +2848,12 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions(
return; return;
} }
Elem e2(e1, "CudaCompile"); Elem e2(e1, "CudaCompile");
e2.SetHasElements();
Options& cudaOptions = *(this->CudaOptions[configName]); OptionsHelper cudaOptions(*(this->CudaOptions[configName]), e2);
cudaOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, "CUDA"); cudaOptions.OutputAdditionalIncludeDirectories("CUDA");
cudaOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "CUDA"); cudaOptions.OutputPreprocessorDefinitions("CUDA");
cudaOptions.PrependInheritedString("AdditionalOptions"); cudaOptions.PrependInheritedString("AdditionalOptions");
cudaOptions.OutputFlagMap(e2.S, e2.Indent + 1); cudaOptions.OutputFlagMap();
e2.EndElement(); e2.EndElement();
} }
@@ -2937,9 +2921,8 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions(
} }
Elem e2(e1, "CudaLink"); Elem e2(e1, "CudaLink");
e2.SetHasElements(); OptionsHelper cudaLinkOptions(*(this->CudaLinkOptions[configName]), e2);
Options& cudaLinkOptions = *(this->CudaLinkOptions[configName]); cudaLinkOptions.OutputFlagMap();
cudaLinkOptions.OutputFlagMap(e2.S, e2.Indent + 1);
e2.EndElement(); e2.EndElement();
} }
@@ -2987,17 +2970,15 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions(
return; return;
} }
Elem e2(e1, "MASM"); Elem e2(e1, "MASM");
e2.SetHasElements();
// Preprocessor definitions and includes are shared with clOptions. // Preprocessor definitions and includes are shared with clOptions.
Options& clOptions = *(this->ClOptions[configName]); OptionsHelper clOptions(*(this->ClOptions[configName]), e2);
clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "ASM_MASM"); clOptions.OutputPreprocessorDefinitions("ASM_MASM");
Options& masmOptions = *(this->MasmOptions[configName]); OptionsHelper masmOptions(*(this->MasmOptions[configName]), e2);
masmOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, masmOptions.OutputAdditionalIncludeDirectories("ASM_MASM");
"ASM_MASM");
masmOptions.PrependInheritedString("AdditionalOptions"); masmOptions.PrependInheritedString("AdditionalOptions");
masmOptions.OutputFlagMap(e2.S, e2.Indent + 1); masmOptions.OutputFlagMap();
e2.EndElement(); e2.EndElement();
} }
@@ -3047,20 +3028,18 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions(
return; return;
} }
Elem e2(e1, "NASM"); Elem e2(e1, "NASM");
e2.SetHasElements();
std::vector<std::string> includes = std::vector<std::string> includes =
this->GetIncludes(configName, "ASM_NASM"); this->GetIncludes(configName, "ASM_NASM");
Options& nasmOptions = *(this->NasmOptions[configName]); OptionsHelper nasmOptions(*(this->NasmOptions[configName]), e2);
nasmOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, nasmOptions.OutputAdditionalIncludeDirectories("ASM_NASM");
"ASM_NASM"); nasmOptions.OutputFlagMap();
nasmOptions.OutputFlagMap(e2.S, e2.Indent + 1);
nasmOptions.PrependInheritedString("AdditionalOptions"); nasmOptions.PrependInheritedString("AdditionalOptions");
nasmOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "ASM_NASM"); nasmOptions.OutputPreprocessorDefinitions("ASM_NASM");
// Preprocessor definitions and includes are shared with clOptions. // Preprocessor definitions and includes are shared with clOptions.
Options& clOptions = *(this->ClOptions[configName]); OptionsHelper clOptions(*(this->ClOptions[configName]), e2);
clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "ASM_NASM"); clOptions.OutputPreprocessorDefinitions("ASM_NASM");
e2.EndElement(); e2.EndElement();
} }
@@ -3077,14 +3056,14 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
libflags, cmSystemTools::UpperCase(config), this->GeneratorTarget); libflags, cmSystemTools::UpperCase(config), this->GeneratorTarget);
if (!libflags.empty()) { if (!libflags.empty()) {
Elem e2(e1, "Lib"); Elem e2(e1, "Lib");
e2.SetHasElements();
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
cmVS10GeneratorOptions libOptions(this->LocalGenerator, cmVS10GeneratorOptions libOptions(this->LocalGenerator,
cmVisualStudioGeneratorOptions::Linker, cmVisualStudioGeneratorOptions::Linker,
gg->GetLibFlagTable(), this); gg->GetLibFlagTable(), this);
libOptions.Parse(libflags.c_str()); libOptions.Parse(libflags.c_str());
libOptions.PrependInheritedString("AdditionalOptions"); OptionsHelper oh(libOptions, e2);
libOptions.OutputFlagMap(e2.S, e2.Indent + 1); oh.PrependInheritedString("AdditionalOptions");
oh.OutputFlagMap();
e2.EndElement(); e2.EndElement();
} }
@@ -3514,13 +3493,12 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(
if (this->ProjectType == csproj) { if (this->ProjectType == csproj) {
return; return;
} }
Options& linkOptions = *(this->LinkOptions[config]);
{ {
Elem e2(e1, "Link"); Elem e2(e1, "Link");
e2.SetHasElements(); OptionsHelper linkOptions(*(this->LinkOptions[config]), e2);
linkOptions.PrependInheritedString("AdditionalOptions"); linkOptions.PrependInheritedString("AdditionalOptions");
linkOptions.OutputFlagMap(e2.S, e2.Indent + 1); linkOptions.OutputFlagMap();
e2.EndElement(); e2.EndElement();
} }

View File

@@ -32,10 +32,6 @@ public:
cmGlobalVisualStudio10Generator* gg); cmGlobalVisualStudio10Generator* gg);
~cmVisualStudio10TargetGenerator(); ~cmVisualStudio10TargetGenerator();
void Generate(); void Generate();
// used by cmVisualStudioGeneratorOptions
std::string CalcCondition(const std::string& config) const;
void WritePlatformConfigTag(const char* tag, const std::string& config,
int indentLevel, const std::string& content);
private: private:
struct ToolSource struct ToolSource
@@ -54,13 +50,13 @@ private:
}; };
struct Elem; struct Elem;
struct OptionsHelper;
std::string ConvertPath(std::string const& path, bool forceRelative); std::string ConvertPath(std::string const& path, bool forceRelative);
void WriteString(const char* line, int indentLevel); void WriteString(const char* line, int indentLevel);
void WriteElem(const char* tag, const char* val, int indentLevel); std::string CalcCondition(const std::string& config) const;
void WriteElem(const char* tag, std::string const& val, int indentLevel); void WritePlatformConfigTag(const char* tag, const std::string& config,
void WriteElemEscapeXML(const char* tag, std::string const& val, Elem& parent, const std::string& content);
int indentLevel);
void WriteProjectConfigurations(Elem& e0); void WriteProjectConfigurations(Elem& e0);
void WriteProjectConfigurationValues(Elem& e0); void WriteProjectConfigurationValues(Elem& e0);
void WriteMSToolConfigurationValues(Elem& e1, std::string const& config); void WriteMSToolConfigurationValues(Elem& e1, std::string const& config);
@@ -182,6 +178,7 @@ private:
void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link); void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link);
private: private:
friend class cmVS10GeneratorOptions;
typedef cmVS10GeneratorOptions Options; typedef cmVS10GeneratorOptions Options;
typedef std::map<std::string, std::unique_ptr<Options>> OptionsMap; typedef std::map<std::string, std::unique_ptr<Options>> OptionsMap;
OptionsMap ClOptions; OptionsMap ClOptions;