diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2017-12-19 15:03:41 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@sap.com> | 2018-01-23 09:25:03 (GMT) |
commit | 3073bd1f3deecaaf090202075382e372a3b3656a (patch) | |
tree | b7d4e16f8e35e2f617b7453decf4fb4e58df109e /Source/cmLocalVisualStudio7Generator.cxx | |
parent | 78b1c2e09ee5005d75e31c68c1c7b112e4b36d90 (diff) | |
download | CMake-3073bd1f3deecaaf090202075382e372a3b3656a.zip CMake-3073bd1f3deecaaf090202075382e372a3b3656a.tar.gz CMake-3073bd1f3deecaaf090202075382e372a3b3656a.tar.bz2 |
VisualStudio generators: refactoring
Uniformize include directories handling.
Fix memory leaks in class cmVisualStudio10TargetGenerator:
OptionsMap uses now std::unique_ptr.
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 83 |
1 files changed, 21 insertions, 62 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 31e8d16..f46c01a 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -45,15 +45,6 @@ public: extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[]; -static void cmConvertToWindowsSlash(std::string& s) -{ - std::string::size_type pos = 0; - while ((pos = s.find('/', pos)) != std::string::npos) { - s[pos] = '\\'; - pos++; - } -} - cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator( cmGlobalGenerator* gg, cmMakefile* mf) : cmLocalVisualStudioGenerator(gg, mf) @@ -704,11 +695,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - std::vector<std::string> targetDefines; if (!langForClCompile.empty()) { + std::vector<std::string> targetDefines; target->GetCompileDefinitions(targetDefines, configName, langForClCompile); + targetOptions.AddDefines(targetDefines); + + std::vector<std::string> targetIncludes; + this->GetIncludeDirectories(targetIncludes, target, langForClCompile, + configName); + targetOptions.AddIncludes(targetIncludes); } - targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); @@ -795,27 +791,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( << this->ConvertToXMLOutputPath(modDir.c_str()) << "\\$(ConfigurationName)\"\n"; } - fout << "\t\t\t\tAdditionalIncludeDirectories=\""; - std::vector<std::string> includes_cl; - if (!langForClCompile.empty()) { - this->GetIncludeDirectories(includes_cl, target, langForClCompile, - configName); - } - std::vector<std::string>::iterator i = includes_cl.begin(); - for (; i != includes_cl.end(); ++i) { - // output the include path - std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); - fout << ipath << ";"; - // if this is fortran then output the include with - // a ConfigurationName on the end of it. - if (this->FortranProject) { - ipath = i->c_str(); - ipath += "/$(ConfigurationName)"; - ipath = this->ConvertToXMLOutputPath(ipath.c_str()); - fout << ipath << ";"; - } - } - fout << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories( + fout, "\t\t\t\t", "\n", + this->FortranProject ? "Fortran" : langForClCompile); targetOptions.OutputFlagMap(fout, "\t\t\t\t"); targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", langForClCompile); @@ -835,20 +813,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( fout << "\t\t\t<Tool\n" "\t\t\t\tName=\"MASM\"\n" - "\t\t\t\tIncludePaths=\"" ; - std::vector<std::string> includes_masm; - this->GetIncludeDirectories(includes_masm, target, "ASM_MASM", - configName); /* clang-format on */ - const char* sep = ""; - for (i = includes_masm.begin(); i != includes_masm.end(); ++i) { - std::string inc = *i; - cmConvertToWindowsSlash(inc); - fout << sep << this->EscapeForXML(inc); - sep = ";"; - } - fout << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", "\n", + "ASM_MASM"); // Use same preprocessor definitions as VCCLCompilerTool. targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "ASM_MASM"); @@ -868,16 +836,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( if (this->FortranProject) { tool = "VFResourceCompilerTool"; } - fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n" - << "\t\t\t\tAdditionalIncludeDirectories=\""; - std::vector<std::string> includes_rc; - this->GetIncludeDirectories(includes_rc, target, "RC", configName); - for (i = includes_rc.begin(); i != includes_rc.end(); ++i) { - std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); - fout << ipath << ";"; - } + fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories(fout, "\n\t\t\t\t", "", + "RC"); // add the -D flags to the RC tool - fout << "\""; targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC"); fout << "/>\n"; tool = "VCMIDLTool"; @@ -885,14 +847,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( tool = "VFMIDLTool"; } fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"; - fout << "\t\t\t\tAdditionalIncludeDirectories=\""; - std::vector<std::string> includes_midl; - this->GetIncludeDirectories(includes_midl, target, "MIDL", configName); - for (i = includes_midl.begin(); i != includes_midl.end(); ++i) { - std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); - fout << ipath << ";"; - } - fout << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories(fout, "\n\t\t\t\t", "", + "MIDL"); fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n"; if (gg->GetPlatformName() == "x64") { fout << "\t\t\t\tTargetEnvironment=\"3\"\n"; @@ -1658,7 +1614,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( this->WriteCustomRule(fout, configs, source.c_str(), *command, fcinfo); } else if (!fcinfo.FileConfigMap.empty()) { const char* aCompilerTool = "VCCLCompilerTool"; - const char* ppLang = "CXX"; + std::string ppLang = "CXX"; if (this->FortranProject) { aCompilerTool = "VFFortranCompilerTool"; } @@ -1718,6 +1674,9 @@ bool cmLocalVisualStudio7Generator::WriteGroup( fileOptions.AddDefines(fc.CompileDefs.c_str()); fileOptions.AddDefines(fc.CompileDefsConfig.c_str()); fileOptions.OutputFlagMap(fout, "\t\t\t\t\t"); + fileOptions.OutputAdditionalIncludeDirectories( + fout, "\t\t\t\t\t", "\n", + ppLang == "CXX" && this->FortranProject ? "Fortran" : ppLang); fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", "\n", ppLang); } |