[Cmake-commits] CMake branch, next, updated. v2.8.10.2-1347-g2a00390
Brad King
brad.king at kitware.com
Thu Jan 3 13:32:35 EST 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 2a00390e5357979020c18a7bff5d7c19436bd59c (commit)
via 30962029325b2126b0b986db0c5ce8e0660428a0 (commit)
from 018d733b0b379035dbd077c3dd260e5067602624 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2a00390e5357979020c18a7bff5d7c19436bd59c
commit 2a00390e5357979020c18a7bff5d7c19436bd59c
Merge: 018d733 3096202
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jan 3 13:32:33 2013 -0500
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Jan 3 13:32:33 2013 -0500
Merge topic 'iface-depends' into next
3096202 Make targets depend on the link interface of their dependees.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=30962029325b2126b0b986db0c5ce8e0660428a0
commit 30962029325b2126b0b986db0c5ce8e0660428a0
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Dec 26 10:58:21 2012 +0100
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Jan 3 13:31:50 2013 -0500
Make targets depend on the link interface of their dependees.
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;
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index 1faa888..60b36fc 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -56,3 +56,10 @@ assert_property(targetA LINK_INTERFACE_LIBRARIES "")
target_link_libraries(targetA depB depC)
assert_property(targetA LINK_INTERFACE_LIBRARIES "")
+
+# Exclude depIfaceOnly from ALL so that it will only be built if something
+# depends on it. As it is in the link interface of depB, targetA
+# will depend on it. That dependency is what is being tested here.
+add_library(depIfaceOnly SHARED EXCLUDE_FROM_ALL depIfaceOnly.cpp)
+generate_export_header(depIfaceOnly)
+set_property(TARGET depB APPEND PROPERTY LINK_INTERFACE_LIBRARIES depIfaceOnly)
diff --git a/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.cpp b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.cpp
new file mode 100644
index 0000000..3b90af0
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.cpp
@@ -0,0 +1,7 @@
+
+#include "depIfaceOnly.h"
+
+int DepIfaceOnly::foo()
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.h b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.h
new file mode 100644
index 0000000..dddf6a5
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.h
@@ -0,0 +1,7 @@
+
+#include "depifaceonly_export.h"
+
+struct DEPIFACEONLY_EXPORT DepIfaceOnly
+{
+ int foo();
+};
diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp
index 3c6472e..6ff65b1 100644
--- a/Tests/CMakeCommands/target_link_libraries/targetA.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp
@@ -1,6 +1,7 @@
#include "depB.h"
#include "depC.h"
+#include "depIfaceOnly.h"
int main(int argc, char **argv)
{
@@ -8,5 +9,7 @@ int main(int argc, char **argv)
DepB b;
DepC c;
- return a.foo() + b.foo() + c.foo();
+ DepIfaceOnly iface_only;
+
+ return a.foo() + b.foo() + c.foo() + iface_only.foo();
}
-----------------------------------------------------------------------
Summary of changes:
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list