Do not crash when an imported target depends on a missing target

Commit e01cce28 (Allow add_dependencies() on imported targets,
2010-11-19) forgot to check if the dependee exists before using it.
This commit is contained in:
Brad King 2011-08-04 15:35:59 -04:00
parent e01cce2869
commit 8ee9bbbd0c
1 changed files with 5 additions and 3 deletions

View File

@ -276,11 +276,13 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
for(std::set<cmStdString>::const_iterator i = utils.begin(); for(std::set<cmStdString>::const_iterator i = utils.begin();
i != utils.end(); ++i) i != utils.end(); ++i)
{ {
cmTarget* transitive_dependee = if(cmTarget* transitive_dependee =
dependee->GetMakefile()->FindTargetToUse(i->c_str()); dependee->GetMakefile()->FindTargetToUse(i->c_str()))
{
this->AddTargetDepend(depender_index, transitive_dependee, false); this->AddTargetDepend(depender_index, transitive_dependee, false);
} }
} }
}
else else
{ {
// Lookup the index for this target. All targets should be known by // Lookup the index for this target. All targets should be known by