From 930042f2d95e83047231457f4d9134c74b8744fc Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 11 Apr 2017 14:42:39 -0400 Subject: cmGeneratorTarget: Factor out a GetTargetObjectNames method --- Source/cmGeneratorExpressionNode.cxx | 40 ++++++++++-------------------------- Source/cmGeneratorTarget.cxx | 27 ++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 5 +++++ 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 8fee119..29ad5d1 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -33,8 +33,6 @@ #include #include -class cmSourceFile; - std::string cmGeneratorExpressionNode::EvaluateDependentExpression( std::string const& prop, cmLocalGenerator* lg, cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget, @@ -1254,38 +1252,22 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode return std::string(); } - std::vector objectSources; - gt->GetObjectSources(objectSources, context->Config); - std::map mapping; + std::vector objects; + gt->GetTargetObjectNames(context->Config, objects); - for (std::vector::const_iterator it = - objectSources.begin(); - it != objectSources.end(); ++it) { - mapping[*it]; + for (std::vector::iterator oi = objects.begin(); + oi != objects.end(); ++oi) { + *oi = gt->ObjectDirectory + *oi; } - gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - + // Create the cmSourceFile instances in the referencing directory. cmMakefile* mf = context->LG->GetMakefile(); - - std::string obj_dir = gt->ObjectDirectory; - std::string result; - const char* sep = ""; - for (std::vector::const_iterator it = - objectSources.begin(); - it != objectSources.end(); ++it) { - // Find the object file name corresponding to this source file. - std::map::const_iterator map_it = - mapping.find(*it); - // It must exist because we populated the mapping just above. - assert(!map_it->second.empty()); - result += sep; - std::string objFile = obj_dir + map_it->second; - mf->AddTargetObject(tgtName, objFile); - result += objFile; - sep = ";"; + for (std::vector::iterator oi = objects.begin(); + oi != objects.end(); ++oi) { + mf->AddTargetObject(tgtName, *oi); } - return result; + + return cmJoin(objects, ";"); } } targetObjectsNode; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 35b2603..4ce1eca 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3254,6 +3254,33 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const return prefix + base + ".pdb"; } +void cmGeneratorTarget::GetTargetObjectNames( + std::string const& config, std::vector& objects) const +{ + std::vector objectSources; + this->GetObjectSources(objectSources, config); + std::map mapping; + + for (std::vector::const_iterator it = + objectSources.begin(); + it != objectSources.end(); ++it) { + mapping[*it]; + } + + this->LocalGenerator->ComputeObjectFilenames(mapping, this); + + for (std::vector::const_iterator it = + objectSources.begin(); + it != objectSources.end(); ++it) { + // Find the object file name corresponding to this source file. + std::map::const_iterator map_it = + mapping.find(*it); + // It must exist because we populated the mapping just above. + assert(!map_it->second.empty()); + objects.push_back(map_it->second); + } +} + bool cmGeneratorTarget::StrictTargetComparison::operator()( cmGeneratorTarget const* t1, cmGeneratorTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2ea2f2f..bad67d0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -209,6 +209,11 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the names of an object library's object files underneath + its object file directory. */ + void GetTargetObjectNames(std::string const& config, + std::vector& objects) const; + /** What hierarchy level should the reported directory contain */ enum BundleDirectoryLevel { -- cgit v0.12