From 841001028a579bea093482fc3c1beb5d45f2b2d6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Aug 2014 13:39:35 -0400 Subject: cmIDEOptions: Add an AppendFlag overload to append multiple values --- Source/cmIDEOptions.cxx | 8 ++++++++ Source/cmIDEOptions.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 72bd593..e9980cf 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -203,6 +203,14 @@ void cmIDEOptions::AppendFlag(std::string const& flag, } //---------------------------------------------------------------------------- +void cmIDEOptions::AppendFlag(std::string const& flag, + std::vector const& value) +{ + FlagValue& fv = this->FlagMap[flag]; + std::copy(value.begin(), value.end(), std::back_inserter(fv)); +} + +//---------------------------------------------------------------------------- void cmIDEOptions::RemoveFlag(const char* flag) { this->FlagMap.erase(flag); diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 9b60f80..2bedbad 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -31,6 +31,8 @@ public: void AddFlag(const char* flag, const char* value); void AddFlag(const char* flag, std::vector const& value); void AppendFlag(std::string const& flag, std::string const& value); + void AppendFlag(std::string const& flag, + std::vector const& value); void RemoveFlag(const char* flag); const char* GetFlag(const char* flag); -- cgit v0.12 From 9633d112794e1bb6b08ab6de0c20baca3a8c5847 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Aug 2014 14:07:07 -0400 Subject: cmIDEOptions: Add HasFlag method to test if a flag is set --- Source/cmIDEOptions.cxx | 6 ++++++ Source/cmIDEOptions.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index e9980cf..0eb903d 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -217,6 +217,12 @@ void cmIDEOptions::RemoveFlag(const char* flag) } //---------------------------------------------------------------------------- +bool cmIDEOptions::HasFlag(std::string const& flag) const +{ + return this->FlagMap.find(flag) != this->FlagMap.end(); +} + +//---------------------------------------------------------------------------- const char* cmIDEOptions::GetFlag(const char* flag) { // This method works only for single-valued flags! diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 2bedbad..7386016 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -34,6 +34,7 @@ public: void AppendFlag(std::string const& flag, std::vector const& value); void RemoveFlag(const char* flag); + bool HasFlag(std::string const& flag) const; const char* GetFlag(const char* flag); protected: -- cgit v0.12 From 8e026aa7f27aaa545b6421e61d7ba3add1c5d10d Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Aug 2014 13:24:48 -0400 Subject: VS: Refactor include directory slash conversion Convert each include directory to windows slashes once instead of repeating it each time they are written out to the project file. --- Source/cmVisualStudio10TargetGenerator.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1e9e8e8..5ad63b5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1584,9 +1584,7 @@ OutputIncludes(std::vector const & includes) for(std::vector::const_iterator i = includes.begin(); i != includes.end(); ++i) { - std::string incDir = *i; - this->ConvertToWindowsSlash(incDir); - *this->BuildFileStream << cmVS10EscapeXML(incDir) << ";"; + *this->BuildFileStream << cmVS10EscapeXML(*i) << ";"; } this->WriteString("%(AdditionalIncludeDirectories)" "\n", 0); @@ -1978,6 +1976,11 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", i->c_str()); + for(std::vector::iterator ii = includes.begin(); + ii != includes.end(); ++ii) + { + this->ConvertToWindowsSlash(*ii); + } this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1); *this->BuildFileStream << "\n"; // output cl compile flags -- cgit v0.12 From 5fcb42ab69b030f8bbc20f800b1e0639c5ee7077 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Aug 2014 14:09:24 -0400 Subject: VS: Refactor include directory generation in .vcxproj files Use the cmVisualStudioGeneratorOptions flag map to add the AdditionalIncludeDirectories element to the project file. Move appending of %(AdditionalIncludeDirectories) to the locations that populate the flag vectors instead of where they are written out. --- Source/cmVisualStudio10TargetGenerator.cxx | 37 +++++++++++++++--------------- Source/cmVisualStudio10TargetGenerator.h | 1 - Source/cmVisualStudioGeneratorOptions.cxx | 4 ---- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5ad63b5..3c7745d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1305,6 +1305,11 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( clOptions.AddFlag("CompileAs", compileAs); } clOptions.Parse(flags.c_str()); + if(clOptions.HasFlag("AdditionalIncludeDirectories")) + { + clOptions.AppendFlag("AdditionalIncludeDirectories", + "%(AdditionalIncludeDirectories)"); + } clOptions.AddDefines(configDefines.c_str()); clOptions.SetConfiguration((*config).c_str()); clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); @@ -1546,7 +1551,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( Options& clOptions = *(this->ClOptions[configName]); this->WriteString("\n", 2); clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); - this->OutputIncludes(includes); + clOptions.AppendFlag("AdditionalIncludeDirectories", includes); + clOptions.AppendFlag("AdditionalIncludeDirectories", + "%(AdditionalIncludeDirectories)"); clOptions.OutputFlagMap(*this->BuildFileStream, " "); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "CXX"); @@ -1577,21 +1584,6 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( this->WriteString("\n", 2); } -void cmVisualStudio10TargetGenerator:: -OutputIncludes(std::vector const & includes) -{ - this->WriteString("", 3); - for(std::vector::const_iterator i = includes.begin(); - i != includes.end(); ++i) - { - *this->BuildFileStream << cmVS10EscapeXML(*i) << ";"; - } - this->WriteString("%(AdditionalIncludeDirectories)" - "\n", 0); -} - - - //---------------------------------------------------------------------------- bool cmVisualStudio10TargetGenerator::ComputeRcOptions() { @@ -1643,9 +1635,11 @@ WriteRCOptions(std::string const& configName, Options& clOptions = *(this->ClOptions[configName]); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "RC"); - this->OutputIncludes(includes); Options& rcOptions = *(this->RcOptions[configName]); + rcOptions.AppendFlag("AdditionalIncludeDirectories", includes); + rcOptions.AppendFlag("AdditionalIncludeDirectories", + "%(AdditionalIncludeDirectories)"); rcOptions.OutputFlagMap(*this->BuildFileStream, " "); rcOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); @@ -1951,7 +1945,14 @@ WriteMidlOptions(std::string const& /*config*/, // only). Perhaps there's something to be done to make this more automatic // on the CMake side? this->WriteString("\n", 2); - this->OutputIncludes(includes); + this->WriteString("", 3); + for(std::vector::const_iterator i = includes.begin(); + i != includes.end(); ++i) + { + *this->BuildFileStream << cmVS10EscapeXML(*i) << ";"; + } + this->WriteString("%(AdditionalIncludeDirectories)" + "\n", 0); this->WriteString("$(IntDir)\n", 3); this->WriteString("%(Filename).h\n", 3); this->WriteString( diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 2bbdb8c..4e9bcd1 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -83,7 +83,6 @@ private: void WriteLinkOptions(std::string const& config); void WriteMidlOptions(std::string const& config, std::vector const & includes); - void OutputIncludes(std::vector const & includes); void OutputLinkIncremental(std::string const& configName); void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index b14fc45..745961f 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -324,10 +324,6 @@ cmVisualStudioGeneratorOptions fout << sep << cmVisualStudio10GeneratorOptionsEscapeForXML(*i); sep = ";"; } - if (m->first == "AdditionalIncludeDirectories") - { - fout << sep << "%(AdditionalIncludeDirectories)"; - } fout << "first << ">\n"; } } -- cgit v0.12