From 60bd9f9c92faae368fab1c44cf81b489c6a875cb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 16 Oct 2015 19:19:48 +0200 Subject: [PATCH] cmGeneratorTarget: Move GetObjectLibrariesCMP0026 from cmTarget. --- Source/cmGeneratorTarget.cxx | 51 +++++++++++++++++++++++++++++++----- Source/cmGeneratorTarget.h | 3 +++ Source/cmTarget.cxx | 39 --------------------------- Source/cmTarget.h | 2 -- 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e4abfd346..9b3bf287d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5200,6 +5200,46 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( return true; } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetObjectLibrariesCMP0026( + std::vector& objlibs) const +{ + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + cmStringRange rng = this->Target->GetSourceEntries(); + for(std::vector::const_iterator + i = rng.begin(); i != rng.end(); ++i) + { + std::string const& entry = *i; + + std::vector files; + cmSystemTools::ExpandListArgument(entry, files); + for (std::vector::const_iterator + li = files.begin(); li != files.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') + { + std::string objLibName = li->substr(17, li->size()-18); + + if (cmGeneratorExpression::Find(objLibName) != std::string::npos) + { + continue; + } + cmGeneratorTarget *objLib = + this->LocalGenerator->FindGeneratorTargetToUse(objLibName); + if(objLib) + { + objlibs.push_back(objLib); + } + } + } + } +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const @@ -5220,14 +5260,13 @@ void cmGeneratorTarget::GetLanguages(std::set& languages, std::vector externalObjects; if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) { - std::vector objectTargets; - this->Target->GetObjectLibrariesCMP0026(objectTargets); + std::vector objectTargets; + this->GetObjectLibrariesCMP0026(objectTargets); objectLibraries.reserve(objectTargets.size()); - for (std::vector::const_iterator it = objectTargets.begin(); - it != objectTargets.end(); ++it) + for (std::vector::const_iterator it = + objectTargets.begin(); it != objectTargets.end(); ++it) { - objectLibraries.push_back(this->GlobalGenerator - ->GetGeneratorTarget(*it)); + objectLibraries.push_back(*it); } } else diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 05a7d4d90..39c977209 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -226,6 +226,9 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + void + GetObjectLibrariesCMP0026(std::vector& objlibs) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; bool HaveBuildTreeRPATH(const std::string& config) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fecdc4590..a7372e3ba 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2203,45 +2203,6 @@ const char* cmTarget::GetExportMacro() const } } -//---------------------------------------------------------------------------- -void -cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const -{ - // At configure-time, this method can be called as part of getting the - // LOCATION property or to export() a file to be include()d. However - // there is no cmGeneratorTarget at configure-time, so search the SOURCES - // for TARGET_OBJECTS instead for backwards compatibility with OLD - // behavior of CMP0024 and CMP0026 only. - for(std::vector::const_iterator - i = this->Internal->SourceEntries.begin(); - i != this->Internal->SourceEntries.end(); ++i) - { - std::string const& entry = *i; - - std::vector files; - cmSystemTools::ExpandListArgument(entry, files); - for (std::vector::const_iterator - li = files.begin(); li != files.end(); ++li) - { - if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') - { - std::string objLibName = li->substr(17, li->size()-18); - - if (cmGeneratorExpression::Find(objLibName) != std::string::npos) - { - continue; - } - cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName); - if(objLib) - { - objlibs.push_back(objLib); - } - } - } - } -} - //---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c0b9e098a..dda6e6a58 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -213,8 +213,6 @@ public: bool IsImported() const {return this->IsImportedTarget;} - void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - /** Strip off leading and trailing whitespace from an item named in the link dependencies of this target. */ std::string CheckCMP0004(std::string const& item) const;