diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2018-04-25 15:01:37 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2018-04-25 15:01:37 (GMT) |
commit | 7d407b438ddc9470687f0fe30d1cef3749dbd8c5 (patch) | |
tree | 1065c7658cbc180e62726127c0055f32a695ed6c | |
parent | 83e3b1497d4889f8dbb7238a270296377035e40b (diff) | |
download | CMake-7d407b438ddc9470687f0fe30d1cef3749dbd8c5.zip CMake-7d407b438ddc9470687f0fe30d1cef3749dbd8c5.tar.gz CMake-7d407b438ddc9470687f0fe30d1cef3749dbd8c5.tar.bz2 |
cmVisualStudioGeneratorOptions: specify indentation with integer
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 41 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.h | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 72 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 10 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.h | 11 |
5 files changed, 68 insertions, 68 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index fcdcdc5..3460289 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -812,10 +812,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( << "\\$(ConfigurationName)\"\n"; } targetOptions.OutputAdditionalIncludeDirectories( - fout, "\t\t\t\t", this->FortranProject ? "Fortran" : langForClCompile); - targetOptions.OutputFlagMap(fout, "\t\t\t\t"); - targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", - langForClCompile); + fout, 4, this->FortranProject ? "Fortran" : langForClCompile); + targetOptions.OutputFlagMap(fout, 4); + targetOptions.OutputPreprocessorDefinitions(fout, 4, langForClCompile); fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. @@ -834,11 +833,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( "\t\t\t\tName=\"MASM\"\n" ; /* clang-format on */ - targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", - "ASM_MASM"); + targetOptions.OutputAdditionalIncludeDirectories(fout, 4, "ASM_MASM"); // Use same preprocessor definitions as VCCLCompilerTool. - targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "ASM_MASM"); - masmOptions.OutputFlagMap(fout, "\t\t\t\t"); + targetOptions.OutputPreprocessorDefinitions(fout, 4, "ASM_MASM"); + masmOptions.OutputFlagMap(fout, 4); /* clang-format off */ fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n" @@ -855,16 +853,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( tool = "VFResourceCompilerTool"; } fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"; - targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", "RC"); + targetOptions.OutputAdditionalIncludeDirectories(fout, 4, "RC"); // add the -D flags to the RC tool - targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "RC"); + targetOptions.OutputPreprocessorDefinitions(fout, 4, "RC"); fout << "\t\t\t/>\n"; tool = "VCMIDLTool"; if (this->FortranProject) { tool = "VFMIDLTool"; } fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"; - targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", "MIDL"); + targetOptions.OutputAdditionalIncludeDirectories(fout, 4, "MIDL"); fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n"; if (gg->GetPlatformName() == "x64") { fout << "\t\t\t\tTargetEnvironment=\"3\"\n"; @@ -1089,7 +1087,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; this->WriteTargetVersionAttribute(fout, target); - linkOptions.OutputFlagMap(fout, "\t\t\t\t"); + linkOptions.OutputFlagMap(fout, 4); fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, cli.GetDirectories()); fout << "\"\n"; @@ -1174,7 +1172,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; this->WriteTargetVersionAttribute(fout, target); - linkOptions.OutputFlagMap(fout, "\t\t\t\t"); + linkOptions.OutputFlagMap(fout, 4); fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, cli.GetDirectories()); fout << "\"\n"; @@ -1711,12 +1709,11 @@ bool cmLocalVisualStudio7Generator::WriteGroup( std::vector<std::string> includes; this->AppendIncludeDirectories(includes, fc.IncludeDirs, **sf); fileOptions.AddIncludes(includes); - fileOptions.OutputFlagMap(fout, "\t\t\t\t\t"); + fileOptions.OutputFlagMap(fout, 5); fileOptions.OutputAdditionalIncludeDirectories( - fout, "\t\t\t\t\t", + fout, 5, ppLang == "CXX" && this->FortranProject ? "Fortran" : ppLang); - fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", - ppLang); + fileOptions.OutputPreprocessorDefinitions(fout, 5, ppLang); } if (!fc.AdditionalDeps.empty()) { fout << "\t\t\t\t\tAdditionalDependencies=\"" << fc.AdditionalDeps @@ -2092,11 +2089,15 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle( return ret; } -void cmVS7GeneratorOptions::OutputFlag(std::ostream& fout, const char* indent, - const char* tag, +void cmVS7GeneratorOptions::OutputFlag(std::ostream& fout, int indent, + const char* flag, const std::string& content) { - fout << indent << tag << "=\""; + fout.fill('\t'); + fout.width(indent); + // write an empty string to get the fill level indent to print + fout << ""; + fout << flag << "=\""; fout << cmLocalVisualStudio7GeneratorEscapeForXML(content); fout << "\"\n"; } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 22b4264..b093e6f 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -30,7 +30,7 @@ public: : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable) { } - void OutputFlag(std::ostream& fout, const char* indent, const char* tag, + void OutputFlag(std::ostream& fout, int indent, const char* tag, const std::string& content) override; }; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 50b7d52..a22a315 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -99,17 +99,20 @@ public: { } - void OutputFlag(std::ostream& fout, const char* indent, const char* tag, + void OutputFlag(std::ostream& fout, int 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); + tag, this->GetConfiguration(), indent); } else { - fout << indent << "<" << tag << ">"; + fout.fill(' '); + 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"; @@ -1144,7 +1147,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( << ".exe</StartProgram>\n"; } - o.OutputFlagMap(*this->BuildFileStream, " "); + o.OutputFlagMap(*this->BuildFileStream, 2); } //---------------------------------------------------------------------------- @@ -2163,11 +2166,10 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( clOptions.AddIncludes(includeList); clOptions.SetConfiguration(config); clOptions.PrependInheritedString("AdditionalOptions"); - clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, - " ", lang); - clOptions.OutputFlagMap(*this->BuildFileStream, " "); - clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", - lang); + clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3, + lang); + clOptions.OutputFlagMap(*this->BuildFileStream, 3); + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, lang); } } if (this->IsXamlSource(source->GetFullPath())) { @@ -2587,10 +2589,10 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } this->WriteString("<ClCompile>\n", 2); clOptions.PrependInheritedString("AdditionalOptions"); - clOptions.OutputAdditionalIncludeDirectories( - *this->BuildFileStream, " ", this->LangForClCompile); - clOptions.OutputFlagMap(*this->BuildFileStream, " "); - clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3, + this->LangForClCompile); + clOptions.OutputFlagMap(*this->BuildFileStream, 3); + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, this->LangForClCompile); if (this->NsightTegra) { @@ -2676,12 +2678,11 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions( this->WriteString("<ResourceCompile>\n", 2); Options& rcOptions = *(this->RcOptions[configName]); - rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", - "RC"); - rcOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, - " ", "RC"); + rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, "RC"); + rcOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3, + "RC"); rcOptions.PrependInheritedString("AdditionalOptions"); - rcOptions.OutputFlagMap(*this->BuildFileStream, " "); + rcOptions.OutputFlagMap(*this->BuildFileStream, 3); this->WriteString("</ResourceCompile>\n", 2); } @@ -2826,12 +2827,11 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions( this->WriteString("<CudaCompile>\n", 2); Options& cudaOptions = *(this->CudaOptions[configName]); - cudaOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, - " ", "CUDA"); - cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", - "CUDA"); + cudaOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3, + "CUDA"); + cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, "CUDA"); cudaOptions.PrependInheritedString("AdditionalOptions"); - cudaOptions.OutputFlagMap(*this->BuildFileStream, " "); + cudaOptions.OutputFlagMap(*this->BuildFileStream, 3); this->WriteString("</CudaCompile>\n", 2); } @@ -2900,7 +2900,7 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions( this->WriteString("<CudaLink>\n", 2); Options& cudaLinkOptions = *(this->CudaLinkOptions[configName]); - cudaLinkOptions.OutputFlagMap(*this->BuildFileStream, " "); + cudaLinkOptions.OutputFlagMap(*this->BuildFileStream, 3); this->WriteString("</CudaLink>\n", 2); } @@ -2951,14 +2951,14 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions( // Preprocessor definitions and includes are shared with clOptions. Options& clOptions = *(this->ClOptions[configName]); - clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, "ASM_MASM"); Options& masmOptions = *(this->MasmOptions[configName]); - masmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, - " ", "ASM_MASM"); + masmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3, + "ASM_MASM"); masmOptions.PrependInheritedString("AdditionalOptions"); - masmOptions.OutputFlagMap(*this->BuildFileStream, " "); + masmOptions.OutputFlagMap(*this->BuildFileStream, 3); this->WriteString("</MASM>\n", 2); } @@ -3012,16 +3012,16 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions( std::vector<std::string> includes = this->GetIncludes(configName, "ASM_NASM"); Options& nasmOptions = *(this->NasmOptions[configName]); - nasmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, - " ", "ASM_NASM"); - nasmOptions.OutputFlagMap(*this->BuildFileStream, " "); + nasmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3, + "ASM_NASM"); + nasmOptions.OutputFlagMap(*this->BuildFileStream, 3); nasmOptions.PrependInheritedString("AdditionalOptions"); - nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, "ASM_NASM"); // Preprocessor definitions and includes are shared with clOptions. Options& clOptions = *(this->ClOptions[configName]); - clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, "ASM_NASM"); this->WriteString("</NASM>\n", 2); @@ -3045,7 +3045,7 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions( gg->GetLibFlagTable(), this); libOptions.Parse(libflags.c_str()); libOptions.PrependInheritedString("AdditionalOptions"); - libOptions.OutputFlagMap(*this->BuildFileStream, " "); + libOptions.OutputFlagMap(*this->BuildFileStream, 3); this->WriteString("</Lib>\n", 2); } @@ -3473,7 +3473,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions( this->WriteString("<Link>\n", 2); linkOptions.PrependInheritedString("AdditionalOptions"); - linkOptions.OutputFlagMap(*this->BuildFileStream, " "); + linkOptions.OutputFlagMap(*this->BuildFileStream, 3); this->WriteString("</Link>\n", 2); if (!this->GlobalGenerator->NeedLinkLibraryDependencies( diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 5cf9a08..3ec3355 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -422,7 +422,7 @@ const std::string& cmVisualStudioGeneratorOptions::GetConfiguration() const } void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( - std::ostream& fout, const char* prefix, const std::string& lang) + std::ostream& fout, int indent, const std::string& lang) { if (this->Defines.empty()) { return; @@ -460,11 +460,11 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( oss << ";%(" << tag << ")"; } - this->OutputFlag(fout, prefix, tag, oss.str()); + this->OutputFlag(fout, indent, tag, oss.str()); } void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( - std::ostream& fout, const char* prefix, const std::string& lang) + std::ostream& fout, int indent, const std::string& lang) { if (this->Includes.empty()) { return; @@ -508,11 +508,11 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( oss << sep << "%(" << tag << ")"; } - this->OutputFlag(fout, prefix, tag, oss.str()); + this->OutputFlag(fout, indent, tag, oss.str()); } void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout, - const char* indent) + int indent) { for (auto const& m : this->FlagMap) { std::ostringstream oss; diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 974ca62..c6b594d 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -77,18 +77,17 @@ public: bool IsWinRt() const; bool IsManaged() const; // Write options to output. - void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, + void OutputPreprocessorDefinitions(std::ostream& fout, int indent, const std::string& lang); - void OutputAdditionalIncludeDirectories(std::ostream& fout, - const char* prefix, + void OutputAdditionalIncludeDirectories(std::ostream& fout, int indent, const std::string& lang); - void OutputFlagMap(std::ostream& fout, const char* indent); + void OutputFlagMap(std::ostream& fout, int indent); void SetConfiguration(const std::string& config); const std::string& GetConfiguration() const; protected: - virtual void OutputFlag(std::ostream& fout, const char* indent, - const char* tag, const std::string& content) = 0; + virtual void OutputFlag(std::ostream& fout, int indent, const char* tag, + const std::string& content) = 0; private: cmLocalVisualStudioGenerator* LocalGenerator; |