summaryrefslogtreecommitdiffstats
path: root/Source/cmComputeTargetDepends.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-29 13:36:55 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-29 13:36:55 (GMT)
commitbbc358c3fc1f09fe2a483996ae1359dba3f587f4 (patch)
treeacbe60addb92ac90fc7c91f187a9d9226c2a95dd /Source/cmComputeTargetDepends.cxx
parent0cce556b5fbe629dccee294aeece7c275343ed64 (diff)
parentc51d07d4397ceed55c534a036ef81df44b741ff6 (diff)
downloadCMake-bbc358c3fc1f09fe2a483996ae1359dba3f587f4.zip
CMake-bbc358c3fc1f09fe2a483996ae1359dba3f587f4.tar.gz
CMake-bbc358c3fc1f09fe2a483996ae1359dba3f587f4.tar.bz2
Merge branch 'master' into osx-init-early
Resolve conflict in Source/cmGlobalGenerator.cxx by integrating changes from both sides.
Diffstat (limited to 'Source/cmComputeTargetDepends.cxx')
-rw-r--r--Source/cmComputeTargetDepends.cxx98
1 files changed, 57 insertions, 41 deletions
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 9136869..eb62455 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -16,6 +16,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
+#include "cmSourceFile.h"
#include "cmTarget.h"
#include "cmake.h"
@@ -211,31 +212,45 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// dependencies in all targets, because the generated build-systems can't
// deal with config-specific dependencies.
{
- std::set<cmStdString> emitted;
- {
- std::vector<std::string> tlibs;
- depender->GetDirectLinkLibraries(0, tlibs, depender);
- // A target should not depend on itself.
- emitted.insert(depender->GetName());
- for(std::vector<std::string>::const_iterator lib = tlibs.begin();
- lib != tlibs.end(); ++lib)
- {
- // Don't emit the same library twice for this target.
- if(emitted.insert(*lib).second)
- {
- this->AddTargetDepend(depender_index, lib->c_str(), true);
- this->AddInterfaceDepends(depender_index, lib->c_str(),
- true, emitted);
- }
- }
- }
+ std::set<std::string> emitted;
+ cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(depender);
+
std::vector<std::string> configs;
depender->GetMakefile()->GetConfigurations(configs);
+ if (configs.empty())
+ {
+ configs.push_back("");
+ }
for (std::vector<std::string>::const_iterator it = configs.begin();
it != configs.end(); ++it)
{
+ std::vector<cmSourceFile const*> objectFiles;
+ gt->GetExternalObjects(objectFiles, *it);
+ for(std::vector<cmSourceFile const*>::const_iterator
+ oi = objectFiles.begin(); oi != objectFiles.end(); ++oi)
+ {
+ std::string objLib = (*oi)->GetObjectLibrary();
+ if (!objLib.empty() && emitted.insert(objLib).second)
+ {
+ if(depender->GetType() != cmTarget::EXECUTABLE &&
+ depender->GetType() != cmTarget::STATIC_LIBRARY &&
+ depender->GetType() != cmTarget::SHARED_LIBRARY &&
+ depender->GetType() != cmTarget::MODULE_LIBRARY)
+ {
+ this->GlobalGenerator->GetCMakeInstance()
+ ->IssueMessage(cmake::FATAL_ERROR,
+ "Only executables and non-OBJECT libraries may "
+ "reference target objects.",
+ depender->GetBacktrace());
+ return;
+ }
+ const_cast<cmTarget*>(depender)->AddUtility(objLib);
+ }
+ }
std::vector<std::string> tlibs;
- depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender);
+ depender->GetDirectLinkLibraries(*it, tlibs, depender);
// A target should not depend on itself.
emitted.insert(depender->GetName());
@@ -245,8 +260,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Don't emit the same library twice for this target.
if(emitted.insert(*lib).second)
{
- this->AddTargetDepend(depender_index, lib->c_str(), true);
- this->AddInterfaceDepends(depender_index, lib->c_str(),
+ this->AddTargetDepend(depender_index, *lib, true);
+ this->AddInterfaceDepends(depender_index, *lib,
true, emitted);
}
}
@@ -255,17 +270,17 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Loop over all utility dependencies.
{
- std::set<cmStdString> const& tutils = depender->GetUtilities();
- std::set<cmStdString> emitted;
+ std::set<std::string> const& tutils = depender->GetUtilities();
+ std::set<std::string> emitted;
// A target should not depend on itself.
emitted.insert(depender->GetName());
- for(std::set<cmStdString>::const_iterator util = tutils.begin();
+ for(std::set<std::string>::const_iterator util = tutils.begin();
util != tutils.end(); ++util)
{
// Don't emit the same utility twice for this target.
if(emitted.insert(*util).second)
{
- this->AddTargetDepend(depender_index, util->c_str(), false);
+ this->AddTargetDepend(depender_index, *util, false);
}
}
}
@@ -274,8 +289,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
cmTarget const* dependee,
- const char *config,
- std::set<cmStdString> &emitted)
+ const std::string& config,
+ std::set<std::string> &emitted)
{
cmTarget const* depender = this->Targets[depender_index];
if(cmTarget::LinkInterface const* iface =
@@ -288,8 +303,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
// Don't emit the same library twice for this target.
if(emitted.insert(*lib).second)
{
- this->AddTargetDepend(depender_index, lib->c_str(), true);
- this->AddInterfaceDepends(depender_index, lib->c_str(),
+ this->AddTargetDepend(depender_index, *lib, true);
+ this->AddInterfaceDepends(depender_index, *lib,
true, emitted);
}
}
@@ -298,9 +313,9 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
- const char* dependee_name,
+ const std::string& dependee_name,
bool linking,
- std::set<cmStdString> &emitted)
+ std::set<std::string> &emitted)
{
cmTarget const* depender = this->Targets[depender_index];
cmTarget const* dependee =
@@ -317,7 +332,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
if(dependee)
{
- this->AddInterfaceDepends(depender_index, dependee, 0, emitted);
+ this->AddInterfaceDepends(depender_index, dependee, "", emitted);
std::vector<std::string> configs;
depender->GetMakefile()->GetConfigurations(configs);
for (std::vector<std::string>::const_iterator it = configs.begin();
@@ -326,14 +341,14 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
// A target should not depend on itself.
emitted.insert(depender->GetName());
this->AddInterfaceDepends(depender_index, dependee,
- it->c_str(), emitted);
+ *it, emitted);
}
}
}
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddTargetDepend(int depender_index,
- const char* dependee_name,
+ const std::string& dependee_name,
bool linking)
{
// Get the depender.
@@ -407,8 +422,8 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
if(dependee->IsImported())
{
// Skip imported targets but follow their utility dependencies.
- std::set<cmStdString> const& utils = dependee->GetUtilities();
- for(std::set<cmStdString>::const_iterator i = utils.begin();
+ std::set<std::string> const& utils = dependee->GetUtilities();
+ for(std::set<std::string>::const_iterator i = utils.begin();
i != utils.end(); ++i)
{
if(cmTarget const* transitive_dependee =
@@ -435,22 +450,23 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
//----------------------------------------------------------------------------
void
-cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
+cmComputeTargetDepends::DisplayGraph(Graph const& graph,
+ const std::string& name)
{
- fprintf(stderr, "The %s target dependency graph is:\n", name);
+ fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
int n = static_cast<int>(graph.size());
for(int depender_index = 0; depender_index < n; ++depender_index)
{
EdgeList const& nl = graph[depender_index];
cmTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n",
- depender_index, depender->GetName());
+ depender_index, depender->GetName().c_str());
for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
int dependee_index = *ni;
cmTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
- dependee->GetName(), ni->IsStrong()? "strong" : "weak");
+ dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
}
}
fprintf(stderr, "\n");
@@ -472,7 +488,7 @@ cmComputeTargetDepends
{
int i = *ni;
fprintf(stderr, " contains target %d [%s]\n",
- i, this->Targets[i]->GetName());
+ i, this->Targets[i]->GetName().c_str());
}
}
fprintf(stderr, "\n");