diff options
author | Brad King <brad.king@kitware.com> | 2017-02-15 15:40:00 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-02-15 15:41:36 (GMT) |
commit | 109b8a6fd32be9886de71f98170e0c512ac9883f (patch) | |
tree | 092fe04e949e31e691bae6b18f4b69fe9ca08fe4 | |
parent | bd5ea6993c8376cd3612100019e15ee256a758d8 (diff) | |
download | CMake-109b8a6fd32be9886de71f98170e0c512ac9883f.zip CMake-109b8a6fd32be9886de71f98170e0c512ac9883f.tar.gz CMake-109b8a6fd32be9886de71f98170e0c512ac9883f.tar.bz2 |
VS: Refactor AdditionalOptions generation
Store unknown flags directly in a flag map entry for `AdditionalOptions`
instead of having a separate member for them. This avoids duplicating
the output generation logic for the entry.
-rw-r--r-- | Source/cmIDEOptions.h | 3 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 27 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.h | 2 |
5 files changed, 9 insertions, 41 deletions
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index aaa9d3d..465cf2c 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -74,9 +74,6 @@ protected: // Preprocessor definitions. std::vector<std::string> Defines; - // Unrecognized flags that get no special handling. - std::string FlagString; - bool DoingDefine; bool AllowDefine; bool AllowSlash; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 38dda04..6e976e1 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -787,7 +787,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( << this->ConvertToXMLOutputPath(modDir.c_str()) << "\\$(ConfigurationName)\"\n"; } - targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); fout << "\t\t\t\tAdditionalIncludeDirectories=\""; std::vector<std::string> includes; this->GetIncludeDirectories(includes, target, "C", configName); @@ -1090,7 +1089,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (!gg->NeedLinkLibraryDependencies(target)) { fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; } - linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); // Use the NOINHERIT macro to avoid getting VS project default // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " @@ -1176,7 +1174,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (!gg->NeedLinkLibraryDependencies(target)) { fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; } - linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); // Use the NOINHERIT macro to avoid getting VS project default // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " @@ -1675,7 +1672,6 @@ bool cmLocalVisualStudio7Generator::WriteGroup( fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); fileOptions.AddDefines(fc.CompileDefsConfig.c_str()); - fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n"); fileOptions.OutputFlagMap(fout, "\t\t\t\t\t"); fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", "\n", ppLang); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f084e19..e3853ed 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1939,7 +1939,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } clOptions.AddDefines(configDefines.c_str()); clOptions.SetConfiguration((*config).c_str()); - clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + clOptions.PrependInheritedString("AdditionalOptions"); clOptions.OutputFlagMap(*this->BuildFileStream, " "); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", lang); @@ -2293,7 +2293,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( return; } this->WriteString("<ClCompile>\n", 2); - clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + clOptions.PrependInheritedString("AdditionalOptions"); clOptions.AppendFlag("AdditionalIncludeDirectories", includes); clOptions.AppendFlag("AdditionalIncludeDirectories", "%(AdditionalIncludeDirectories)"); @@ -2395,8 +2395,8 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions( rcOptions.AppendFlag("AdditionalIncludeDirectories", includes); rcOptions.AppendFlag("AdditionalIncludeDirectories", "%(AdditionalIncludeDirectories)"); + rcOptions.PrependInheritedString("AdditionalOptions"); rcOptions.OutputFlagMap(*this->BuildFileStream, " "); - rcOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); this->WriteString("</ResourceCompile>\n", 2); } @@ -2453,8 +2453,8 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions( Options& masmOptions = *(this->MasmOptions[configName]); masmOptions.AppendFlag("IncludePaths", includes); masmOptions.AppendFlag("IncludePaths", "%(IncludePaths)"); + masmOptions.PrependInheritedString("AdditionalOptions"); masmOptions.OutputFlagMap(*this->BuildFileStream, " "); - masmOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); this->WriteString("</MASM>\n", 2); } @@ -2512,7 +2512,7 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions( nasmOptions.AppendFlag("IncludePaths", includes); nasmOptions.AppendFlag("IncludePaths", "%(IncludePaths)"); nasmOptions.OutputFlagMap(*this->BuildFileStream, " "); - nasmOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + nasmOptions.PrependInheritedString("AdditionalOptions"); nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "ASM_NASM"); @@ -2542,7 +2542,7 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions( this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker, gg->GetLibFlagTable(), 0, this); libOptions.Parse(libflags.c_str()); - libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + libOptions.PrependInheritedString("AdditionalOptions"); libOptions.OutputFlagMap(*this->BuildFileStream, " "); this->WriteString("</Lib>\n", 2); } @@ -3019,7 +3019,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions( Options& linkOptions = *(this->LinkOptions[config]); this->WriteString("<Link>\n", 2); - linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + linkOptions.PrependInheritedString("AdditionalOptions"); linkOptions.OutputFlagMap(*this->BuildFileStream, " "); this->WriteString("</Link>\n", 2); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index f8de3f8..dfe5ce6 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -245,10 +245,10 @@ void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag) } // This option is not known. Store it in the output flags. - this->FlagString += " "; - this->FlagString += cmOutputConverter::EscapeWindowsShellArgument( + std::string const opts = cmOutputConverter::EscapeWindowsShellArgument( flag, cmOutputConverter::Shell_Flag_AllowMakeVariables | cmOutputConverter::Shell_Flag_VSIDE); + this->AppendFlagString("AdditionalOptions", opts); } void cmVisualStudioGeneratorOptions::SetConfiguration(const char* config) @@ -343,26 +343,3 @@ void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout, } } } - -void cmVisualStudioGeneratorOptions::OutputAdditionalOptions( - std::ostream& fout, const char* prefix, const char* suffix) -{ - if (!this->FlagString.empty()) { - if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { - fout << prefix; - if (!this->Configuration.empty()) { - this->TargetGenerator->WritePlatformConfigTag( - "AdditionalOptions", this->Configuration.c_str(), 0, 0, 0, &fout); - } else { - fout << "<AdditionalOptions>"; - } - fout << "%(AdditionalOptions) " - << cmVisualStudio10GeneratorOptionsEscapeForXML(this->FlagString) - << "</AdditionalOptions>\n"; - } else { - fout << prefix << "AdditionalOptions=\""; - fout << cmVisualStudioGeneratorOptionsEscapeForXML(this->FlagString); - fout << "\"" << suffix; - } - } -} diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index ee9d0a5..8c49470 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -67,8 +67,6 @@ public: const char* suffix, const std::string& lang); void OutputFlagMap(std::ostream& fout, const char* indent); - void OutputAdditionalOptions(std::ostream& fout, const char* prefix, - const char* suffix); void SetConfiguration(const char* config); private: |