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/cmVisualStudioGeneratorOptions.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/cmVisualStudioGeneratorOptions.cxx')
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 83 |
1 files changed, 67 insertions, 16 deletions
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 106bdff..ccbff83 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -29,23 +29,8 @@ static std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret) cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( cmLocalVisualStudioGenerator* lg, Tool tool, cmVisualStudio10TargetGenerator* g) - : cmIDEOptions() - , LocalGenerator(lg) - , Version(lg->GetVersion()) - , CurrentTool(tool) - , TargetGenerator(g) + : cmVisualStudioGeneratorOptions(lg, tool, nullptr, nullptr, g) { - // Preprocessor definitions are not allowed for linker tools. - this->AllowDefine = (tool != Linker); - - // Slash options are allowed for VS. - this->AllowSlash = true; - - this->FortranRuntimeDebug = false; - this->FortranRuntimeDLL = false; - this->FortranRuntimeMT = false; - - this->UnknownFlagField = "AdditionalOptions"; } cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( @@ -64,6 +49,9 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( // Preprocessor definitions are not allowed for linker tools. this->AllowDefine = (tool != Linker); + // include directories are not allowed for linker tools. + this->AllowInclude = (tool != Linker); + // Slash options are allowed for VS. this->AllowSlash = true; @@ -511,6 +499,69 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( } } +void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( + std::ostream& fout, const char* prefix, const char* suffix, + const std::string& lang) +{ + if (this->Includes.empty()) { + return; + } + + const char* tag = "AdditionalIncludeDirectories"; + if (lang == "CUDA") { + tag = "Include"; + } else if (lang == "ASM_MASM" || lang == "ASM_NASM") { + tag = "IncludePaths"; + } + + if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { + // if there are configuration specific flags, then + // use the configuration specific tag for PreprocessorDefinitions + if (!this->Configuration.empty()) { + fout << prefix; + this->TargetGenerator->WritePlatformConfigTag( + tag, this->Configuration.c_str(), 0, 0, 0, &fout); + } else { + fout << prefix << "<" << tag << ">"; + } + } else { + fout << prefix << tag << "=\""; + } + + const char* sep = ""; + for (std::string include : this->Includes) { + // first convert all of the slashes + std::string::size_type pos = 0; + while ((pos = include.find('/', pos)) != std::string::npos) { + include[pos] = '\\'; + pos++; + } + + if (lang == "ASM_NASM") { + include += "\\"; + } + + // Escape this include for the IDE. + fout << sep << (this->Version >= cmGlobalVisualStudioGenerator::VS10 + ? cmVisualStudio10GeneratorOptionsEscapeForXML(include) + : cmVisualStudioGeneratorOptionsEscapeForXML(include)); + sep = ";"; + + if (lang == "Fortran") { + include += "/$(ConfigurationName)"; + fout << sep << (this->Version >= cmGlobalVisualStudioGenerator::VS10 + ? cmVisualStudio10GeneratorOptionsEscapeForXML(include) + : cmVisualStudioGeneratorOptionsEscapeForXML(include)); + } + } + + if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { + fout << sep << "%(" << tag << ")</" << tag << ">" << suffix; + } else { + fout << "\"" << suffix; + } +} + void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout, const char* indent) { |