[Cmake-commits] CMake branch, next, updated. v2.8.10.2-1317-g68c0aac

Stephen Kelly steveire at gmail.com
Wed Dec 26 05:05:31 EST 2012


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  68c0aac9094a032b6a834ce8a546924d8eae2ddf (commit)
       via  d604660e1d8ae632e7d66701af4f45a871218950 (commit)
       via  00deb127be64cf8934d92c1593c8ea4a5f0f2061 (commit)
       via  c95a13ecb9db33d4c74b0ab67b67baba1f9599ac (commit)
      from  1be4b803705b3350511b850261d3ee5159409030 (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=68c0aac9094a032b6a834ce8a546924d8eae2ddf
commit 68c0aac9094a032b6a834ce8a546924d8eae2ddf
Merge: 1be4b80 d604660
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Dec 26 05:05:29 2012 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Dec 26 05:05:29 2012 -0500

    Merge topic 'iface-depends' into next
    
    d604660 Make targets depend on the link interface of their dependees.
    00deb12 CMake Nightly Date Stamp
    c95a13e CMake Nightly Date Stamp


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d604660e1d8ae632e7d66701af4f45a871218950
commit d604660e1d8ae632e7d66701af4f45a871218950
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Dec 26 10:58:21 2012 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Dec 26 10:59:46 2012 +0100

    Make targets depend on the link interface of their dependees.

diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index ab77c6b..d40a887 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,62 @@ 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:
 Source/CMakeVersion.cmake                          |    2 +-
 Source/cmComputeTargetDepends.cxx                  |   58 ++++++++++++++++++++
 Source/cmComputeTargetDepends.h                    |    6 ++-
 .../target_link_libraries/CMakeLists.txt           |    7 +++
 .../target_link_libraries/depIfaceOnly.cpp         |    7 +++
 .../target_link_libraries/depIfaceOnly.h           |    7 +++
 .../target_link_libraries/targetA.cpp              |    5 ++-
 7 files changed, 89 insertions(+), 3 deletions(-)
 create mode 100644 Tests/CMakeCommands/target_link_libraries/depIfaceOnly.cpp
 create mode 100644 Tests/CMakeCommands/target_link_libraries/depIfaceOnly.h


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list