[Cmake-commits] CMake branch, next, updated. v2.8.11-2233-gdbe762e

Stephen Kelly steveire at gmail.com
Mon May 27 19:21:05 EDT 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  dbe762ed85efd857a6b9d64d1556247f2a899ee7 (commit)
       via  fa55751f83dc5d5bd5f80d12c3076ec703262edb (commit)
       via  f77631672168b1e3b5fad93c2bb83db65cb67e7b (commit)
       via  ab7cd03cea8651fa1aea9c109fabc69b4e247062 (commit)
       via  fe1584f276f208ebf4d932c91ff4f4ad5c96507f (commit)
       via  a3a82b5ed7f1407fe89f4e92d32446f4e354c171 (commit)
      from  3a94f2eae9c71f9890f8013404d2c389e84a3bb2 (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=dbe762ed85efd857a6b9d64d1556247f2a899ee7
commit dbe762ed85efd857a6b9d64d1556247f2a899ee7
Merge: 3a94f2e fa55751
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon May 27 19:20:59 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon May 27 19:20:59 2013 -0400

    Merge topic 'qt4-qt5-CMAKE_AUTOMOC' into next
    
    fa55751 QtAutomoc: Get the Qt version through the target link interface
    f776316 Use the qt5::moc imported target instead of a variable.
    ab7cd03 CMake Nightly Date Stamp
    fe1584f CMake Nightly Date Stamp
    a3a82b5 CMake Nightly Date Stamp


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fa55751f83dc5d5bd5f80d12c3076ec703262edb
commit fa55751f83dc5d5bd5f80d12c3076ec703262edb
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon May 27 17:58:57 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue May 28 01:19:37 2013 +0200

    QtAutomoc: Get the Qt version through the target link interface
    
    In Qt 5.1, Qt5::Core has a INTERFACE_QT_MAJOR_VERSION property
    of '5', and since CMake 2.8.11, Qt4::QtCore has an
    INTERFACE_QT_MAJOR_VERSION of '4'. This was introduced in
    commit 4aa10cd6 (FindQt4: Set the INTERFACE_QT_MAJOR_VERSION for
    Qt4::QtCore, 2013-03-16), to produce an error if Qt 4 and Qt 5
    are erroneously used by the same target. This can also be used
    however to determine the Qt major version, and therefore the
    particular moc executable to use during automoc steps. This means
    that targets in a single buildsystem can use a selection of Qt 4
    and Qt 5, and still take advantage of the CMAKE_AUTOMOC feature
    without conflicting.

diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in
index e5bee86..9cff735 100644
--- a/Modules/AutomocInfo.cmake.in
+++ b/Modules/AutomocInfo.cmake.in
@@ -9,7 +9,6 @@ set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/")
 set(AM_QT_MOC_EXECUTABLE "@_qt_moc_executable@")
 set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
 set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
-set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" )
-set(AM_Qt5Core_VERSION_MAJOR "@Qt5Core_VERSION_MAJOR@" )
+set(AM_QT_VERSION_MAJOR "@_target_qt_version@")
 set(AM_TARGET_NAME @_moc_target_name@)
 set(AM_RELAXED_MODE "@_moc_relaxed_mode@")
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 9d14fc2..350b462 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -309,7 +309,27 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
           cmLocalGenerator::EscapeForCMake(_moc_headers.c_str()).c_str());
   makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
 
-  if (makefile->GetDefinition("Qt5Core_VERSION_MAJOR"))
+  const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
+  if (!qtVersion)
+    {
+    qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
+    }
+  if (const char *targetQtVersion =
+      target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0))
+    {
+    qtVersion = targetQtVersion;
+    }
+  if (qtVersion)
+    {
+    makefile->AddDefinition("_target_qt_version", qtVersion);
+    }
+
+  {
+  const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE");
+  makefile->AddDefinition("_qt_moc_executable", qtMoc);
+  }
+
+  if (strcmp(qtVersion, "5") == 0)
     {
     cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc");
     if (!qt5Moc)
@@ -322,8 +342,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
     }
   else
     {
-    const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE");
-    makefile->AddDefinition("_qt_moc_executable", qtMoc);
+    if (strcmp(qtVersion, "4") != 0)
+      {
+      cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and "
+                          "Qt 5 ", automocTargetName.c_str());
+      }
     }
 
   const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 0b221e8..230f776 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1044,6 +1044,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
       --test-command ${CMAKE_CTEST_COMMAND} -V
       )
     list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets")
+
+    if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0)
+      add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND}
+        --build-and-test
+        "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
+        "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
+        ${build_generator_args}
+        --build-project Qt4And5Automoc
+        --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
+        --force-new-ctest-process
+        --test-command ${CMAKE_CTEST_COMMAND} -V
+        )
+      list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc")
+    endif()
   endif()
 
   add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
diff --git a/Tests/Qt4And5Automoc/CMakeLists.txt b/Tests/Qt4And5Automoc/CMakeLists.txt
new file mode 100644
index 0000000..0cc80fe
--- /dev/null
+++ b/Tests/Qt4And5Automoc/CMakeLists.txt
@@ -0,0 +1,13 @@
+
+project(Qt4And5Automoc)
+
+find_package(Qt4 REQUIRED)
+find_package(Qt5Core REQUIRED)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+add_executable(qt4_exe main_qt4.cpp)
+target_link_libraries(qt4_exe Qt4::QtCore)
+add_executable(qt5_exe main_qt5.cpp)
+target_link_libraries(qt5_exe Qt5::Core)
diff --git a/Tests/Qt4And5Automoc/main.cpp b/Tests/Qt4And5Automoc/main.cpp
new file mode 100644
index 0000000..00fd641
--- /dev/null
+++ b/Tests/Qt4And5Automoc/main.cpp
@@ -0,0 +1,18 @@
+
+#include <QObject>
+
+class SomeObject : public QObject
+{
+  Q_OBJECT
+public:
+  explicit SomeObject(QObject *parent = 0)
+    : QObject(parent)
+  {
+
+  }
+};
+
+int main(int argc, char **argv)
+{
+  return 0;
+}
diff --git a/Tests/Qt4And5Automoc/main_qt4.cpp b/Tests/Qt4And5Automoc/main_qt4.cpp
new file mode 100644
index 0000000..a84ce89
--- /dev/null
+++ b/Tests/Qt4And5Automoc/main_qt4.cpp
@@ -0,0 +1,4 @@
+
+#include "main.cpp"
+
+#include "main_qt4.moc"
diff --git a/Tests/Qt4And5Automoc/main_qt5.cpp b/Tests/Qt4And5Automoc/main_qt5.cpp
new file mode 100644
index 0000000..287b261
--- /dev/null
+++ b/Tests/Qt4And5Automoc/main_qt5.cpp
@@ -0,0 +1,4 @@
+
+#include "main.cpp"
+
+#include "main_qt5.moc"

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f77631672168b1e3b5fad93c2bb83db65cb67e7b
commit f77631672168b1e3b5fad93c2bb83db65cb67e7b
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon May 27 20:53:51 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon May 27 20:56:07 2013 +0200

    Use the qt5::moc imported target instead of a variable.
    
    The variable is provided in the Qt5 config files only for compatibility
    with this automoc feature, so use the more-future-proof method instead.

diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in
index 640bf70..e5bee86 100644
--- a/Modules/AutomocInfo.cmake.in
+++ b/Modules/AutomocInfo.cmake.in
@@ -6,7 +6,7 @@ set(AM_MOC_OPTIONS @_moc_options@)
 set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@")
 set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/")
 set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/")
-set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@")
+set(AM_QT_MOC_EXECUTABLE "@_qt_moc_executable@")
 set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
 set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
 set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" )
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index a468fa7..9d14fc2 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -309,6 +309,23 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
           cmLocalGenerator::EscapeForCMake(_moc_headers.c_str()).c_str());
   makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
 
+  if (makefile->GetDefinition("Qt5Core_VERSION_MAJOR"))
+    {
+    cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc");
+    if (!qt5Moc)
+      {
+      cmSystemTools::Error("Qt5::moc target not found ",
+                          automocTargetName.c_str());
+      return;
+      }
+    makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0));
+    }
+  else
+    {
+    const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE");
+    makefile->AddDefinition("_qt_moc_executable", qtMoc);
+    }
+
   const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
   std::string inputFile = cmakeRoot;
   inputFile += "/Modules/AutomocInfo.cmake.in";

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

Summary of changes:
 Modules/AutomocInfo.cmake.in        |    5 +--
 Source/CMakeVersion.cmake           |    2 +-
 Source/cmQtAutomoc.cxx              |   40 +++++++++++++++++++++++++++++++++++
 Tests/CMakeLists.txt                |   14 ++++++++++++
 Tests/Qt4And5Automoc/CMakeLists.txt |   13 +++++++++++
 Tests/Qt4And5Automoc/main.cpp       |   18 +++++++++++++++
 Tests/Qt4And5Automoc/main_qt4.cpp   |    4 +++
 Tests/Qt4And5Automoc/main_qt5.cpp   |    4 +++
 8 files changed, 96 insertions(+), 4 deletions(-)
 create mode 100644 Tests/Qt4And5Automoc/CMakeLists.txt
 create mode 100644 Tests/Qt4And5Automoc/main.cpp
 create mode 100644 Tests/Qt4And5Automoc/main_qt4.cpp
 create mode 100644 Tests/Qt4And5Automoc/main_qt5.cpp


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list