diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-21 15:57:27 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-21 15:57:27 (GMT) |
commit | 03d17a35b50e409d466b3042ad5e79010e746f35 (patch) | |
tree | 0f770301d2cffa2a9b5f5492311342b9e573b00c /Source/cmTarget.cxx | |
parent | e09c606eb47c13bd435892625943e95bb9452996 (diff) | |
download | CMake-03d17a35b50e409d466b3042ad5e79010e746f35.zip CMake-03d17a35b50e409d466b3042ad5e79010e746f35.tar.gz CMake-03d17a35b50e409d466b3042ad5e79010e746f35.tar.bz2 |
cmTarget: Use helper function to append to lists
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 84 |
1 files changed, 31 insertions, 53 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 46f930a..0b83b6b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -32,6 +32,13 @@ #include "cmTargetPropertyComputer.h" #include "cmake.h" +///! Append all elements from the second container to the first container +template <class C, class R> +static inline void CApp(C& container, R const& range) +{ + container.insert(container.end(), range.begin(), range.end()); +} + template <> const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>( cmTarget const* tgt) @@ -355,59 +362,30 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (!this->IsImported()) { // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - const cmStringRange parentIncludes = - this->Makefile->GetIncludeDirectoriesEntries(); - const cmBacktraceRange parentIncludesBts = - this->Makefile->GetIncludeDirectoriesBacktraces(); - - this->Internal->IncludeDirectoriesEntries.insert( - this->Internal->IncludeDirectoriesEntries.end(), parentIncludes.begin(), - parentIncludes.end()); - this->Internal->IncludeDirectoriesBacktraces.insert( - this->Internal->IncludeDirectoriesBacktraces.end(), - parentIncludesBts.begin(), parentIncludesBts.end()); - - const std::set<std::string> parentSystemIncludes = - this->Makefile->GetSystemIncludeDirectories(); - - this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), - parentSystemIncludes.end()); - - const cmStringRange parentCompileOptions = - this->Makefile->GetCompileOptionsEntries(); - const cmBacktraceRange parentCompileOptionsBts = - this->Makefile->GetCompileOptionsBacktraces(); - - this->Internal->CompileOptionsEntries.insert( - this->Internal->CompileOptionsEntries.end(), - parentCompileOptions.begin(), parentCompileOptions.end()); - this->Internal->CompileOptionsBacktraces.insert( - this->Internal->CompileOptionsBacktraces.end(), - parentCompileOptionsBts.begin(), parentCompileOptionsBts.end()); - - const cmStringRange parentLinkOptions = - this->Makefile->GetLinkOptionsEntries(); - const cmBacktraceRange parentLinkOptionsBts = - this->Makefile->GetLinkOptionsBacktraces(); - - this->Internal->LinkOptionsEntries.insert( - this->Internal->LinkOptionsEntries.end(), parentLinkOptions.begin(), - parentLinkOptions.end()); - this->Internal->LinkOptionsBacktraces.insert( - this->Internal->LinkOptionsBacktraces.end(), - parentLinkOptionsBts.begin(), parentLinkOptionsBts.end()); - - const cmStringRange parentLinkDirectories = - this->Makefile->GetLinkDirectoriesEntries(); - const cmBacktraceRange parentLinkDirectoriesBts = - this->Makefile->GetLinkDirectoriesBacktraces(); - - this->Internal->LinkDirectoriesEntries.insert( - this->Internal->LinkDirectoriesEntries.end(), - parentLinkDirectories.begin(), parentLinkDirectories.end()); - this->Internal->LinkDirectoriesBacktraces.insert( - this->Internal->LinkDirectoriesBacktraces.end(), - parentLinkDirectoriesBts.begin(), parentLinkDirectoriesBts.end()); + CApp(this->Internal->IncludeDirectoriesEntries, + this->Makefile->GetIncludeDirectoriesEntries()); + CApp(this->Internal->IncludeDirectoriesBacktraces, + this->Makefile->GetIncludeDirectoriesBacktraces()); + + { + auto const& sysInc = this->Makefile->GetSystemIncludeDirectories(); + this->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); + } + + CApp(this->Internal->CompileOptionsEntries, + this->Makefile->GetCompileOptionsEntries()); + CApp(this->Internal->CompileOptionsBacktraces, + this->Makefile->GetCompileOptionsBacktraces()); + + CApp(this->Internal->LinkOptionsEntries, + this->Makefile->GetLinkOptionsEntries()); + CApp(this->Internal->LinkOptionsBacktraces, + this->Makefile->GetLinkOptionsBacktraces()); + + CApp(this->Internal->LinkDirectoriesEntries, + this->Makefile->GetLinkDirectoriesEntries()); + CApp(this->Internal->LinkDirectoriesBacktraces, + this->Makefile->GetLinkDirectoriesBacktraces()); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && |