[Cmake-commits] CMake branch, next, updated. v3.1.0-rc1-454-g5e10724

Brad King brad.king at kitware.com
Mon Nov 10 09:11:40 EST 2014


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  5e10724b877305a5a3c563f375d25937789935bd (commit)
       via  a4716b6be3027aefa1d539d6f8077137269e30e2 (commit)
       via  3c3589e1146a91d21fdaeab342886a1701647626 (commit)
      from  2790ea0e0a6cc4db94497d2e27af32c6d41b2f04 (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=5e10724b877305a5a3c563f375d25937789935bd
commit 5e10724b877305a5a3c563f375d25937789935bd
Merge: 2790ea0 a4716b6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Nov 10 09:11:38 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Nov 10 09:11:38 2014 -0500

    Merge topic 'fix_link-line-dedup_regression' into next
    
    a4716b6b Test linking to a shared lib needed only through a static lib
    3c3589e1 Fix link line order when shared libraries are de-duplicated

diff --cc Tests/CMakeLists.txt
index ab83d41,fe2b335..5c1c2e6
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@@ -1500,8 -1500,18 +1500,18 @@@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=de
    set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
    set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
  
+   add_test(LinkMixed  ${CMAKE_CTEST_COMMAND}
+     --build-and-test
+     "${CMake_SOURCE_DIR}/Tests/LinkMixed"
+     "${CMake_BINARY_DIR}/Tests/LinkMixed"
+     ${build_generator_args}
+     --build-project LinkMixed
+     --build-options ${build_options}
+     --test-command exec
+   )
+ 
    # Test static linking on toolchains known to support it.
 -  if("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$"
 +  if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
        AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
        AND EXISTS "/usr/lib/libm.a")
      add_test(LinkStatic  ${CMAKE_CTEST_COMMAND}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4716b6be3027aefa1d539d6f8077137269e30e2
commit a4716b6be3027aefa1d539d6f8077137269e30e2
Author:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Sun Nov 9 17:51:18 2014 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Nov 10 08:59:29 2014 -0500

    Test linking to a shared lib needed only through a static lib

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 25cc846..fe2b335 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1500,6 +1500,16 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
   set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
   set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
 
+  add_test(LinkMixed  ${CMAKE_CTEST_COMMAND}
+    --build-and-test
+    "${CMake_SOURCE_DIR}/Tests/LinkMixed"
+    "${CMake_BINARY_DIR}/Tests/LinkMixed"
+    ${build_generator_args}
+    --build-project LinkMixed
+    --build-options ${build_options}
+    --test-command exec
+  )
+
   # Test static linking on toolchains known to support it.
   if("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$"
       AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
diff --git a/Tests/LinkMixed/CMakeLists.txt b/Tests/LinkMixed/CMakeLists.txt
new file mode 100644
index 0000000..6f83dcd
--- /dev/null
+++ b/Tests/LinkMixed/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 2.8.9)
+project(Test)
+
+include_directories(${CMAKE_SOURCE_DIR})
+
+add_library(lib1 SHARED lib1.cpp lib1.h)
+
+add_library(lib2 STATIC lib2.cpp lib2.h)
+target_link_libraries(lib2 lib1)
+
+add_executable(exec main.cpp)
+target_link_libraries(exec lib1)
+target_link_libraries(exec lib2)
diff --git a/Tests/LinkMixed/lib1.cpp b/Tests/LinkMixed/lib1.cpp
new file mode 100644
index 0000000..772d227
--- /dev/null
+++ b/Tests/LinkMixed/lib1.cpp
@@ -0,0 +1,8 @@
+#include "lib1.h"
+
+#include <iostream>
+
+void lib1::L1::foo()
+{
+    std::cout << "lib1::L1::foo()" << std::endl;
+}
diff --git a/Tests/LinkMixed/lib1.h b/Tests/LinkMixed/lib1.h
new file mode 100644
index 0000000..6998d1a
--- /dev/null
+++ b/Tests/LinkMixed/lib1.h
@@ -0,0 +1,8 @@
+namespace lib1
+{
+class L1
+{
+public:
+    void foo();
+};
+} // namespace lib1
diff --git a/Tests/LinkMixed/lib2.cpp b/Tests/LinkMixed/lib2.cpp
new file mode 100644
index 0000000..379447b
--- /dev/null
+++ b/Tests/LinkMixed/lib2.cpp
@@ -0,0 +1,11 @@
+#include "lib2.h"
+
+#include <lib1.h>
+#include <iostream>
+
+void lib2::L2::bar()
+{
+    lib1::L1 l1;
+    l1.foo();
+    std::cout << "lib2::L2::bar()" << std::endl;
+}
diff --git a/Tests/LinkMixed/lib2.h b/Tests/LinkMixed/lib2.h
new file mode 100644
index 0000000..ba83e5f
--- /dev/null
+++ b/Tests/LinkMixed/lib2.h
@@ -0,0 +1,8 @@
+namespace lib2
+{
+class L2
+{
+public:
+    void bar();
+};
+} // namespace lib2
diff --git a/Tests/LinkMixed/main.cpp b/Tests/LinkMixed/main.cpp
new file mode 100644
index 0000000..cd52974
--- /dev/null
+++ b/Tests/LinkMixed/main.cpp
@@ -0,0 +1,8 @@
+#include <lib1.h>
+#include <lib2.h>
+
+int main(int argc, char *argv[])
+{
+    lib2::L2 l2;
+    l2.bar();
+}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c3589e1146a91d21fdaeab342886a1701647626
commit 3c3589e1146a91d21fdaeab342886a1701647626
Author:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Sun Nov 9 17:35:20 2014 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Nov 10 08:58:22 2014 -0500

    Fix link line order when shared libraries are de-duplicated
    
    Since commit v3.1.0-rc1~227^2~1 (De-duplicate shared library targets in
    generated link lines, 2014-07-30) we de-duplicate shared library targets
    on the link line.  However, some toolchains will fail linking if an
    executable is linking to a shared library that is not used directly and
    a static library that depends on the shared one.  The linker may not
    keep the reference to the shared library the first time and then the
    symbols needed by the static library may not be found.
    
    Fix this by reversing the direction of the for loop that removes the
    duplicate shared libraries, in order to ensure that the last occurrence
    of the library is left instead of the first one.
    
    Co-Author: Brad King <brad.king at kitware.com>

diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index b13a125..f38b9bb 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -263,21 +263,25 @@ cmComputeLinkDepends::Compute()
   this->OrderLinkEntires();
 
   // Compute the final set of link entries.
+  // Iterate in reverse order so we can keep only the last occurrence
+  // of a shared library.
   std::set<int> emmitted;
-  for(std::vector<int>::const_iterator li = this->FinalLinkOrder.begin();
-      li != this->FinalLinkOrder.end(); ++li)
+  for(std::vector<int>::const_reverse_iterator li =
+        this->FinalLinkOrder.rbegin();
+      li != this->FinalLinkOrder.rend(); ++li)
     {
     int i = *li;
     LinkEntry const& e = this->EntryList[i];
     cmTarget const* t = e.Target;
-    // Entries that we know the linker will re-use for symbols
-    // needed by later entries do not need to be repeated.
+    // Entries that we know the linker will re-use do not need to be repeated.
     bool uniquify = t && t->GetType() == cmTarget::SHARED_LIBRARY;
     if(!uniquify || emmitted.insert(i).second)
       {
       this->FinalLinkEntries.push_back(e);
       }
     }
+  // Reverse the resulting order since we iterated in reverse.
+  std::reverse(this->FinalLinkEntries.begin(), this->FinalLinkEntries.end());
 
   // Display the final set.
   if(this->DebugMode)

-----------------------------------------------------------------------

Summary of changes:
 Source/cmComputeLinkDepends.cxx |   12 ++++++++----
 Tests/CMakeLists.txt            |   10 ++++++++++
 Tests/LinkMixed/CMakeLists.txt  |   13 +++++++++++++
 Tests/LinkMixed/lib1.cpp        |    8 ++++++++
 Tests/LinkMixed/lib1.h          |    8 ++++++++
 Tests/LinkMixed/lib2.cpp        |   11 +++++++++++
 Tests/LinkMixed/lib2.h          |    8 ++++++++
 Tests/LinkMixed/main.cpp        |    8 ++++++++
 8 files changed, 74 insertions(+), 4 deletions(-)
 create mode 100644 Tests/LinkMixed/CMakeLists.txt
 create mode 100644 Tests/LinkMixed/lib1.cpp
 create mode 100644 Tests/LinkMixed/lib1.h
 create mode 100644 Tests/LinkMixed/lib2.cpp
 create mode 100644 Tests/LinkMixed/lib2.h
 create mode 100644 Tests/LinkMixed/main.cpp


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list