diff options
author | Brad King <brad.king@kitware.com> | 2010-11-19 18:36:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-11-19 22:19:21 (GMT) |
commit | e01cce28694201342adc97825982ed66fc52af65 (patch) | |
tree | ef4573c4112650f78df2ebb66665185118a8bcd6 /Source/cmComputeTargetDepends.cxx | |
parent | bc7395c096be40f8a0fecbab4aa7539c05898ef2 (diff) | |
download | CMake-e01cce28694201342adc97825982ed66fc52af65.zip CMake-e01cce28694201342adc97825982ed66fc52af65.tar.gz CMake-e01cce28694201342adc97825982ed66fc52af65.tar.bz2 |
Allow add_dependencies() on imported targets (#10395)
Imported targets do not themselves build, but we can follow dependencies
through them to find real targets. This allows imported targets to
depend on custom targets that provide the underlying files at build
time.
Diffstat (limited to 'Source/cmComputeTargetDepends.cxx')
-rw-r--r-- | Source/cmComputeTargetDepends.cxx | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 3f9c7ec..a4ca363 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)); + } } //---------------------------------------------------------------------------- |