summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddDependenciesCommand.cxx6
-rw-r--r--Source/cmAddDependenciesCommand.h2
-rw-r--r--Source/cmComputeTargetDepends.cxx57
-rw-r--r--Source/cmComputeTargetDepends.h1
4 files changed, 38 insertions, 28 deletions
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 1205f0741b..a77140d611 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -24,11 +24,7 @@ bool cmAddDependenciesCommand
}
std::string target_name = args[0];
-
- cmTarget* target =
- this->GetMakefile()->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget(0, target_name.c_str());
- if(target)
+ if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str()))
{
std::vector<std::string>::const_iterator s = args.begin();
++s; // skip over target_name
diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h
index 6a981c36e5..fee011c226 100644
--- a/Source/cmAddDependenciesCommand.h
+++ b/Source/cmAddDependenciesCommand.h
@@ -62,6 +62,8 @@ public:
"top-level target is one created by ADD_EXECUTABLE, ADD_LIBRARY, "
"or ADD_CUSTOM_TARGET. Adding dependencies with this command "
"can be used to make sure one target is built before another target. "
+ "Dependencies added to an IMPORTED target are followed transitively "
+ "in its place since the target itself does not build. "
"See the DEPENDS option of ADD_CUSTOM_TARGET "
"and ADD_CUSTOM_COMMAND for adding file-level dependencies in custom "
"rules. See the OBJECT_DEPENDS option in "
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 3f9c7ece4f..a4ca363a87 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -246,13 +246,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
// Check the target's makefile first.
cmTarget* dependee =
- depender->GetMakefile()->FindTarget(dependee_name);
-
- // Then search globally.
- if(!dependee)
- {
- dependee = this->GlobalGenerator->FindTarget(0, dependee_name);
- }
+ depender->GetMakefile()->FindTargetToUse(dependee_name);
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
@@ -264,25 +258,42 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
dependee = 0;
}
- // If not found then skip then the dependee.
- if(!dependee)
+ if(dependee)
{
- return;
+ this->AddTargetDepend(depender_index, dependee, linking);
}
+}
- // No imported targets should have been found.
- assert(!dependee->IsImported());
-
- // Lookup the index for this target. All targets should be known by
- // this point.
- std::map<cmTarget*, int>::const_iterator tii =
- this->TargetIndex.find(dependee);
- assert(tii != this->TargetIndex.end());
- int dependee_index = tii->second;
-
- // Add this entry to the dependency graph.
- this->InitialGraph[depender_index].push_back(
- cmGraphEdge(dependee_index, !linking));
+//----------------------------------------------------------------------------
+void cmComputeTargetDepends::AddTargetDepend(int depender_index,
+ cmTarget* dependee,
+ bool linking)
+{
+ 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();
+ i != utils.end(); ++i)
+ {
+ cmTarget* transitive_dependee =
+ dependee->GetMakefile()->FindTargetToUse(i->c_str());
+ this->AddTargetDepend(depender_index, transitive_dependee, false);
+ }
+ }
+ else
+ {
+ // Lookup the index for this target. All targets should be known by
+ // this point.
+ std::map<cmTarget*, int>::const_iterator tii =
+ this->TargetIndex.find(dependee);
+ assert(tii != this->TargetIndex.end());
+ int dependee_index = tii->second;
+
+ // Add this entry to the dependency graph.
+ this->InitialGraph[depender_index].push_back(
+ cmGraphEdge(dependee_index, !linking));
+ }
}
//----------------------------------------------------------------------------
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index 36e533fd54..67bce72d9d 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -46,6 +46,7 @@ private:
void CollectTargetDepends(int depender_index);
void AddTargetDepend(int depender_index, const char* dependee_name,
bool linking);
+ void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
cmGlobalGenerator* GlobalGenerator;