summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-01-03 18:53:15 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-01-03 18:53:15 (GMT)
commitde53c4c695604bbe00a2dca86d2ac6f2971e2bdd (patch)
tree06a610284776e872e18d3c07cd3f7cb77cbc8dfa /Source
parent690d6baece0e5187f2bd57f8e6ff58f2ab4a57a5 (diff)
parent30962029325b2126b0b986db0c5ce8e0660428a0 (diff)
downloadCMake-de53c4c695604bbe00a2dca86d2ac6f2971e2bdd.zip
CMake-de53c4c695604bbe00a2dca86d2ac6f2971e2bdd.tar.gz
CMake-de53c4c695604bbe00a2dca86d2ac6f2971e2bdd.tar.bz2
Merge topic 'iface-depends'
3096202 Make targets depend on the link interface of their dependees.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmComputeTargetDepends.cxx59
-rw-r--r--Source/cmComputeTargetDepends.h6
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;