summaryrefslogtreecommitdiff
path: root/Tests/Qt4And5Automoc
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-05-27 17:58:57 +0200
committerStephen Kelly <steveire@gmail.com>2013-05-28 01:19:37 +0200
commitfa55751f83dc5d5bd5f80d12c3076ec703262edb (patch)
tree7420d760cbeaad79622325d3b285a1b53d2c743f /Tests/Qt4And5Automoc
parentf77631672168b1e3b5fad93c2bb83db65cb67e7b (diff)
downloadcmake-fa55751f83dc5d5bd5f80d12c3076ec703262edb.tar.gz
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.
Diffstat (limited to 'Tests/Qt4And5Automoc')
-rw-r--r--Tests/Qt4And5Automoc/CMakeLists.txt13
-rw-r--r--Tests/Qt4And5Automoc/main.cpp18
-rw-r--r--Tests/Qt4And5Automoc/main_qt4.cpp4
-rw-r--r--Tests/Qt4And5Automoc/main_qt5.cpp4
4 files changed, 39 insertions, 0 deletions
diff --git a/Tests/Qt4And5Automoc/CMakeLists.txt b/Tests/Qt4And5Automoc/CMakeLists.txt
new file mode 100644
index 0000000000..0cc80fe73f
--- /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 0000000000..00fd641535
--- /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 0000000000..a84ce897fd
--- /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 0000000000..287b261372
--- /dev/null
+++ b/Tests/Qt4And5Automoc/main_qt5.cpp
@@ -0,0 +1,4 @@
+
+#include "main.cpp"
+
+#include "main_qt5.moc"