[Cmake-commits] CMake branch, next, updated. v2.8.6-1485-ga48ebb5

Stephen Kelly steveire at gmail.com
Tue Oct 4 22:11:56 EDT 2011


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  a48ebb532a36bd81f14298ec135304fe7e7f1dda (commit)
       via  1f9a5957b5a48e3c1ef95287d4534081f50d5fb7 (commit)
       via  649935c3f1177d6224f73d3a80dd473efcc5ee11 (commit)
       via  fa243d83a01c4ca5522329ab4eeaf4bbc5e94c3a (commit)
       via  ac4dd41bcc3818f010fc19e28b2e76e2407d2a09 (commit)
      from  17cb6c7b042a9bfe681bc51e959eada9c6ea680d (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=a48ebb532a36bd81f14298ec135304fe7e7f1dda
commit a48ebb532a36bd81f14298ec135304fe7e7f1dda
Merge: 17cb6c7 1f9a595
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Oct 4 22:11:54 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Oct 4 22:11:54 2011 -0400

    Merge topic 'cmake-link-interface-libraries' into next
    
    1f9a595 Run the tests with the rest of the cmake tests.
    649935c Remove unused cpp file.
    fa243d8 Add more documentation about this feature.
    ac4dd41 Make it possible to clear LINK_INTERFACE_LIBRARIES for all targets.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f9a5957b5a48e3c1ef95287d4534081f50d5fb7
commit 1f9a5957b5a48e3c1ef95287d4534081f50d5fb7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 1 15:00:27 2011 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Oct 1 15:00:27 2011 +0200

    Run the tests with the rest of the cmake tests.
    
    Need a dummy executable to use the cmake test macro.

diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index 52379d7..8a06cf0 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -195,3 +195,14 @@ expect_pass(True True
   LIBS
     libC
 )
+
+file(WRITE
+  "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
+  "int main() { return 0; }
+"
+)
+
+add_executable(
+  target_link_libraries
+  "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
+)
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 78db39d..44ed2f5 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1574,6 +1574,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
     -P "${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command/RunCMake.cmake"
   )
 
+  ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
+
   CONFIGURE_FILE(
     "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"
     "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake"

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=649935c3f1177d6224f73d3a80dd473efcc5ee11
commit 649935c3f1177d6224f73d3a80dd473efcc5ee11
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 1 14:50:58 2011 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Oct 1 14:50:58 2011 +0200

    Remove unused cpp file.

diff --git a/Tests/CMakeCommands/target_link_libraries/src/main.cpp b/Tests/CMakeCommands/target_link_libraries/src/main.cpp
deleted file mode 100644
index 82e9c05..0000000
--- a/Tests/CMakeCommands/target_link_libraries/src/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#include "classA.h"
-#include "classB.h"
-#include "classC.h"
-#include "classD.h"
-
-int main(int, char **) {
-
-  classA a;
-  classB b;
-  classC c;
-  classD d;
-
-  return 0;
-}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fa243d83a01c4ca5522329ab4eeaf4bbc5e94c3a
commit fa243d83a01c4ca5522329ab4eeaf4bbc5e94c3a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 1 12:29:28 2011 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Oct 1 12:29:28 2011 +0200

    Add more documentation about this feature.

diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index f2b01f1..f4d4e7c 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -1219,7 +1219,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
      "Therefore a specific build configuration must be chosen even "
      "if the generated build system supports multiple configurations.",false,
      "Variables that Control the Build");
-
+  cm->DefineProperty
+    ("CMAKE_LINK_INTERFACE_LIBRARIES", cmProperty::VARIABLE,
+     "Default value for LINK_INTERFACE_LIBRARIES of targets.",
+     "This variable is used to initialize the "
+     "LINK_INTERFACE_LIBRARIES property on all the targets. "
+     "See that target property for additional information.",
+     false,
+     "Variables that Control the Build");
 
 //   Variables defined when the a language is enabled These variables will
 // also be defined whenever CMake has loaded its support for compiling (LANG)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac4dd41bcc3818f010fc19e28b2e76e2407d2a09
commit ac4dd41bcc3818f010fc19e28b2e76e2407d2a09
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 1 12:23:56 2011 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Oct 1 12:25:40 2011 +0200

    Make it possible to clear LINK_INTERFACE_LIBRARIES for all targets.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index fb92016..96a9646 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -619,7 +619,10 @@ void cmTarget::DefineProperties(cmake *cm)
      "If the list is empty then no transitive link dependencies will be "
      "incorporated when this target is linked into another target even if "
      "the default set is non-empty.  "
-     "This property is ignored for STATIC libraries.");
+     "This property is ignored for STATIC libraries.  "
+     "This property is initialized by the value of the variable "
+     "CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is "
+     "created.");
 
   cm->DefineProperty
     ("LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET,
@@ -1153,6 +1156,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
   this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
   this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
   this->SetPropertyDefault("AUTOMOC", 0);
+  this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);
 
   // Collect the set of configuration types.
   std::vector<std::string> configNames;
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
new file mode 100644
index 0000000..52379d7
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -0,0 +1,197 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(target_link_libraries_test)
+
+set (COUNT 0)
+macro(_do_build CLEAR_LINK_INTERFACE_LIBRARIES SPECIFY_LINK_INTERFACE_LIBRARIES)
+  math(EXPR COUNT "${COUNT} + 1" )
+
+  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}")
+
+  if (${CLEAR_LINK_INTERFACE_LIBRARIES})
+    file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+      "set(CMAKE_LINK_INTERFACE_LIBRARIES \"\")\n"
+    )
+  endif()
+
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/main.cpp"
+    ""
+  )
+
+  foreach(klass ${ARGN})
+    if (klass STREQUAL "LIBS")
+      break()
+    endif()
+    file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/main.cpp"
+      "#include \"${klass}.h\"\n"
+    )
+  endforeach()
+
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/main.cpp"
+    "int main(int, char **) {"
+  )
+
+  foreach(klass ${ARGN})
+    if (klass STREQUAL "LIBS")
+      break()
+    endif()
+    file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/main.cpp"
+      "${klass} ${klass}_;\n"
+    )
+  endforeach()
+
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/main.cpp"
+    "return 0;"
+    "}\n"
+  )
+
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+
+    "add_library(libA SHARED classA.cpp)\n"
+    "add_library(libB SHARED classB.cpp)\n"
+    "add_library(libC SHARED classC.cpp)\n"
+
+    "add_executable(exec \"${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/main.cpp\")\n"
+  )
+
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+    "target_link_libraries(libB libA)\n"
+    "target_link_libraries(libC libA libB)\n"
+  )
+
+  if (${SPECIFY_LINK_INTERFACE_LIBRARIES})
+    file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+      "target_link_libraries(libB LINK_INTERFACE_LIBRARIES libA)\n"
+      "target_link_libraries(libC LINK_INTERFACE_LIBRARIES libA)\n"
+    )
+  endif()
+
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+    "target_link_libraries(exec "
+  )
+
+  set(continue True)
+  foreach(klass ${ARGN})
+    if (klass STREQUAL "LIBS")
+      # CMake has no continue() command
+      set(continue False)
+    endif()
+    if (NOT continue AND NOT klass STREQUAL "LIBS")
+      file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+        "${klass} "
+      )
+    endif()
+  endforeach()
+
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+    ")\n"
+  )
+
+  try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT}
+    ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}
+    src
+    OUTPUT_VARIABLE Out
+  )
+endmacro()
+
+macro(EXPECT_PASS)
+  _do_build(${ARGN})
+  if (NOT ${Result})
+    message(SEND_ERROR "Failed! \n\n${Out}")
+  endif()
+endmacro()
+
+macro(EXPECT_FAIL)
+  _do_build(${ARGN})
+  if (${Result})
+    message(SEND_ERROR "Failed! \n\n${Out} -- ${COUNT}")
+  endif()
+endmacro()
+
+macro(all_pass)
+  expect_pass(False False ${ARGN})
+  expect_pass(True False ${ARGN})
+  expect_pass(False True ${ARGN})
+  expect_pass(True True ${ARGN})
+endmacro()
+
+# If we specify all libs to the executable, it will always pass
+all_pass(
+    classA
+  LIBS
+    libA
+)
+
+all_pass(
+    classA classB
+  LIBS
+    libA libB
+)
+
+all_pass(
+    classA classC
+  LIBS
+    libA libC
+)
+
+all_pass(
+    classA classB classC
+  LIBS
+    libA libB libC
+)
+
+# If we don't set the CMAKE_LINK_INTERFACE_LIBRARIES to empty and we don't explicitly
+# specify the LINK_INTERFACE_LIBRARIES, the executable can use all classes if linked
+# indirectly to them
+expect_pass(False False
+    classA classB
+  LIBS
+    libB
+)
+
+# Although libC is linked to libA, libA is not part of the link interface of libC.
+# Because we don't clear the CMAKE_LINK_INTERFACE_LIBRARIES it still works.
+expect_pass(False False
+    classA classC
+  LIBS
+    libC
+)
+
+# However, if we do clear it and don't explicitly link the executable to it, it fails,
+# whether we specify the link_interface_libraries properly or not.
+expect_fail(True False
+    classB classC
+  LIBS
+    libC
+)
+expect_fail(True True
+    classB classC
+  LIBS
+    libC
+)
+
+# Then we can still link the executable to libA directly of course to pass
+expect_pass(True False
+    classA classC
+  LIBS
+    libC libA
+)
+expect_pass(True True
+    classA classC
+  LIBS
+    libC libA
+)
+
+# Also, if we clear and specify the link interface, we can use classes defined in
+# that interface without linking to the library directly
+expect_pass(True True
+    classA classB
+  LIBS
+    libB
+)
+
+expect_pass(True True
+    classA classC
+  LIBS
+    libC
+)
diff --git a/Tests/CMakeCommands/target_link_libraries/src/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/src/CMakeLists.txt
new file mode 100644
index 0000000..17c8844
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(src)
+
+set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/Tests/CMakeCommands/target_link_libraries/src/classA.cpp b/Tests/CMakeCommands/target_link_libraries/src/classA.cpp
new file mode 100644
index 0000000..f5e7106
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/classA.cpp
@@ -0,0 +1,7 @@
+
+#include "classA.h"
+
+classA::classA()
+{
+
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/src/classA.h b/Tests/CMakeCommands/target_link_libraries/src/classA.h
new file mode 100644
index 0000000..d485489
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/classA.h
@@ -0,0 +1,11 @@
+
+#ifndef CLASS_A_H
+#define CLASS_A_H
+
+class classA
+{
+public:
+  classA();
+};
+
+#endif
\ No newline at end of file
diff --git a/Tests/CMakeCommands/target_link_libraries/src/classB.cpp b/Tests/CMakeCommands/target_link_libraries/src/classB.cpp
new file mode 100644
index 0000000..86308a5
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/classB.cpp
@@ -0,0 +1,13 @@
+
+#include "classB.h"
+
+#include "classA.h"
+
+classB::classB()
+{
+}
+
+classA* classB::a() const
+{
+  return new classA();
+}
\ No newline at end of file
diff --git a/Tests/CMakeCommands/target_link_libraries/src/classB.h b/Tests/CMakeCommands/target_link_libraries/src/classB.h
new file mode 100644
index 0000000..7c2ad47
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/classB.h
@@ -0,0 +1,15 @@
+
+#ifndef CLASS_B_H
+#define CLASS_B_H
+
+class classA;
+
+class classB
+{
+public:
+  classB();
+
+  classA* a() const;
+};
+
+#endif
\ No newline at end of file
diff --git a/Tests/CMakeCommands/target_link_libraries/src/classC.cpp b/Tests/CMakeCommands/target_link_libraries/src/classC.cpp
new file mode 100644
index 0000000..55ab9fc
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/classC.cpp
@@ -0,0 +1,15 @@
+
+#include "classC.h"
+
+#include "classA.h"
+#include "classB.h"
+
+classC::classC()
+{
+  classB b;
+}
+
+classA* classC::a() const
+{
+  return new classA();
+}
\ No newline at end of file
diff --git a/Tests/CMakeCommands/target_link_libraries/src/classC.h b/Tests/CMakeCommands/target_link_libraries/src/classC.h
new file mode 100644
index 0000000..5d8a931
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/classC.h
@@ -0,0 +1,15 @@
+
+#ifndef CLASS_C_H
+#define CLASS_C_H
+
+class classA;
+
+class classC
+{
+public:
+  classC();
+
+  classA* a() const;
+};
+
+#endif
\ No newline at end of file
diff --git a/Tests/CMakeCommands/target_link_libraries/src/main.cpp b/Tests/CMakeCommands/target_link_libraries/src/main.cpp
new file mode 100644
index 0000000..82e9c05
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/src/main.cpp
@@ -0,0 +1,15 @@
+
+#include "classA.h"
+#include "classB.h"
+#include "classC.h"
+#include "classD.h"
+
+int main(int, char **) {
+
+  classA a;
+  classB b;
+  classC c;
+  classD d;
+
+  return 0;
+}

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

Summary of changes:
 Source/cmDocumentVariables.cxx                     |    9 +-
 Source/cmTarget.cxx                                |    6 +-
 .../target_link_libraries/CMakeLists.txt           |  208 ++++++++++++++++++++
 .../target_link_libraries/src/CMakeLists.txt       |    6 +
 .../target_link_libraries/src/classA.cpp           |    7 +
 .../target_link_libraries/src/classA.h             |   11 +
 .../target_link_libraries/src/classB.cpp           |   13 ++
 .../target_link_libraries/src/classB.h             |   15 ++
 .../target_link_libraries/src/classC.cpp           |   15 ++
 .../target_link_libraries/src/classC.h             |   15 ++
 Tests/CMakeLists.txt                               |    2 +
 11 files changed, 305 insertions(+), 2 deletions(-)
 create mode 100644 Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
 create mode 100644 Tests/CMakeCommands/target_link_libraries/src/CMakeLists.txt
 create mode 100644 Tests/CMakeCommands/target_link_libraries/src/classA.cpp
 create mode 100644 Tests/CMakeCommands/target_link_libraries/src/classA.h
 create mode 100644 Tests/CMakeCommands/target_link_libraries/src/classB.cpp
 create mode 100644 Tests/CMakeCommands/target_link_libraries/src/classB.h
 create mode 100644 Tests/CMakeCommands/target_link_libraries/src/classC.cpp
 create mode 100644 Tests/CMakeCommands/target_link_libraries/src/classC.h


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list