diff options
author | Brad King <brad.king@kitware.com> | 2019-03-22 13:19:02 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-22 13:19:09 (GMT) |
commit | fb05b6a8f53bbfd15dc549f24c11035ec5272b36 (patch) | |
tree | 0caa59327206868dc0e814b05daacfc3d01b7dec | |
parent | 6d8f0627a39ff18c7c7d1d744de405f30aa4d9c4 (diff) | |
parent | 965da8d787ad0ca9b78f98cd276211e997016d07 (diff) | |
download | CMake-fb05b6a8f53bbfd15dc549f24c11035ec5272b36.zip CMake-fb05b6a8f53bbfd15dc549f24c11035ec5272b36.tar.gz CMake-fb05b6a8f53bbfd15dc549f24c11035ec5272b36.tar.bz2 |
Merge topic 'cmTarget_micro_fixes'
965da8d787 cmTarget: Acquire data only when needed
03d17a35b5 cmTarget: Use helper function to append to lists
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3135
-rw-r--r-- | Source/cmTarget.cxx | 91 |
1 files changed, 34 insertions, 57 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c0b9ba1..c6a69be 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) @@ -309,10 +316,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, #endif } - // Collect the set of configuration types. - std::vector<std::string> configNames; - mf->GetConfigurations(configNames); - // Setup per-configuration property default values. if (this->GetType() != cmStateEnums::UTILITY) { static const auto configProps = { @@ -322,6 +325,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, "COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_", "INTERPROCEDURAL_OPTIMIZATION_" }; + // Collect the set of configuration types. + std::vector<std::string> configNames; + mf->GetConfigurations(configNames); for (std::string const& configName : configNames) { std::string configUpper = cmSystemTools::UpperCase(configName); for (auto const& prop : configProps) { @@ -356,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 && |