diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-12-26 09:58:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-01-03 18:31:50 (GMT) |
commit | 30962029325b2126b0b986db0c5ce8e0660428a0 (patch) | |
tree | 1c3d146023bb26dd8ce6959f21bc76605f24c803 /Source | |
parent | 00deb127be64cf8934d92c1593c8ea4a5f0f2061 (diff) | |
download | CMake-30962029325b2126b0b986db0c5ce8e0660428a0.zip CMake-30962029325b2126b0b986db0c5ce8e0660428a0.tar.gz CMake-30962029325b2126b0b986db0c5ce8e0660428a0.tar.bz2 |
Make targets depend on the link interface of their dependees.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmComputeTargetDepends.cxx | 59 | ||||
-rw-r--r-- | Source/cmComputeTargetDepends.h | 6 |
2 files changed, 64 insertions, 1 deletions
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ab77c6b..3b15ec1 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -214,6 +214,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) if(emitted.insert(lib->first).second) { this->AddTargetDepend(depender_index, lib->first.c_str(), true); + this->AddInterfaceDepends(depender_index, lib->first.c_str(), + true, emitted); } } } @@ -237,6 +239,63 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } //---------------------------------------------------------------------------- +void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, + cmTarget* dependee, + const char *config, + std::set<cmStdString> &emitted) +{ + if(cmTarget::LinkInterface const* iface = + dependee->GetLinkInterface(config)) + { + for(std::vector<std::string>::const_iterator + lib = iface->Libraries.begin(); + lib != iface->Libraries.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); + } + } + } +} + +//---------------------------------------------------------------------------- +void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, + const char* dependee_name, + bool linking, + std::set<cmStdString> &emitted) +{ + cmTarget* depender = this->Targets[depender_index]; + cmTarget* dependee = + 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 + // within the project. + if(linking && dependee && + dependee->GetType() == cmTarget::EXECUTABLE && + !dependee->IsExecutableWithExports()) + { + dependee = 0; + } + + if(dependee) + { + this->AddInterfaceDepends(depender_index, dependee, 0, emitted); + std::vector<std::string> configs; + depender->GetMakefile()->GetConfigurations(configs); + for (std::vector<std::string>::const_iterator it = configs.begin(); + it != configs.end(); ++it) + { + // A target should not depend on itself. + emitted.insert(depender->GetName()); + this->AddInterfaceDepends(depender_index, dependee, + it->c_str(), emitted); + } + } +} + +//---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, const char* dependee_name, bool linking) diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 67bce72..d6131cf 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -48,7 +48,11 @@ private: bool linking); void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); - + void AddInterfaceDepends(int depender_index, const char* dependee_name, + bool linking, std::set<cmStdString> &emitted); + void AddInterfaceDepends(int depender_index, cmTarget* dependee, + const char *config, + std::set<cmStdString> &emitted); cmGlobalGenerator* GlobalGenerator; bool DebugMode; bool NoCycles; |