mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
cmGeneratorTarget: Factor out a GetTargetObjectNames method
This commit is contained in:
@@ -33,8 +33,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
class cmSourceFile;
|
|
||||||
|
|
||||||
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
||||||
std::string const& prop, cmLocalGenerator* lg,
|
std::string const& prop, cmLocalGenerator* lg,
|
||||||
cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
|
cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
|
||||||
@@ -1254,38 +1252,22 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmSourceFile const*> objectSources;
|
std::vector<std::string> objects;
|
||||||
gt->GetObjectSources(objectSources, context->Config);
|
gt->GetTargetObjectNames(context->Config, objects);
|
||||||
std::map<cmSourceFile const*, std::string> mapping;
|
|
||||||
|
|
||||||
for (std::vector<cmSourceFile const*>::const_iterator it =
|
for (std::vector<std::string>::iterator oi = objects.begin();
|
||||||
objectSources.begin();
|
oi != objects.end(); ++oi) {
|
||||||
it != objectSources.end(); ++it) {
|
*oi = gt->ObjectDirectory + *oi;
|
||||||
mapping[*it];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
// Create the cmSourceFile instances in the referencing directory.
|
||||||
|
|
||||||
cmMakefile* mf = context->LG->GetMakefile();
|
cmMakefile* mf = context->LG->GetMakefile();
|
||||||
|
for (std::vector<std::string>::iterator oi = objects.begin();
|
||||||
std::string obj_dir = gt->ObjectDirectory;
|
oi != objects.end(); ++oi) {
|
||||||
std::string result;
|
mf->AddTargetObject(tgtName, *oi);
|
||||||
const char* sep = "";
|
|
||||||
for (std::vector<cmSourceFile const*>::const_iterator it =
|
|
||||||
objectSources.begin();
|
|
||||||
it != objectSources.end(); ++it) {
|
|
||||||
// Find the object file name corresponding to this source file.
|
|
||||||
std::map<cmSourceFile const*, std::string>::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 = ";";
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
return cmJoin(objects, ";");
|
||||||
}
|
}
|
||||||
} targetObjectsNode;
|
} targetObjectsNode;
|
||||||
|
|
||||||
|
|||||||
@@ -3254,6 +3254,33 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
|
|||||||
return prefix + base + ".pdb";
|
return prefix + base + ".pdb";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmGeneratorTarget::GetTargetObjectNames(
|
||||||
|
std::string const& config, std::vector<std::string>& objects) const
|
||||||
|
{
|
||||||
|
std::vector<cmSourceFile const*> objectSources;
|
||||||
|
this->GetObjectSources(objectSources, config);
|
||||||
|
std::map<cmSourceFile const*, std::string> mapping;
|
||||||
|
|
||||||
|
for (std::vector<cmSourceFile const*>::const_iterator it =
|
||||||
|
objectSources.begin();
|
||||||
|
it != objectSources.end(); ++it) {
|
||||||
|
mapping[*it];
|
||||||
|
}
|
||||||
|
|
||||||
|
this->LocalGenerator->ComputeObjectFilenames(mapping, this);
|
||||||
|
|
||||||
|
for (std::vector<cmSourceFile const*>::const_iterator it =
|
||||||
|
objectSources.begin();
|
||||||
|
it != objectSources.end(); ++it) {
|
||||||
|
// Find the object file name corresponding to this source file.
|
||||||
|
std::map<cmSourceFile const*, std::string>::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()(
|
bool cmGeneratorTarget::StrictTargetComparison::operator()(
|
||||||
cmGeneratorTarget const* t1, cmGeneratorTarget const* t2) const
|
cmGeneratorTarget const* t1, cmGeneratorTarget const* t2) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -209,6 +209,11 @@ public:
|
|||||||
bool realname) const;
|
bool realname) const;
|
||||||
std::string NormalGetRealName(const std::string& config) 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<std::string>& objects) const;
|
||||||
|
|
||||||
/** What hierarchy level should the reported directory contain */
|
/** What hierarchy level should the reported directory contain */
|
||||||
enum BundleDirectoryLevel
|
enum BundleDirectoryLevel
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user