summaryrefslogtreecommitdiff
path: root/Tests/QtAutomoc
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/QtAutomoc')
-rw-r--r--Tests/QtAutomoc/Adir/CMakeLists.txt2
-rw-r--r--Tests/QtAutomoc/CMakeLists.txt26
-rw-r--r--Tests/QtAutomoc/calwidget.cpp17
-rw-r--r--Tests/QtAutomoc/defines_test/CMakeLists.txt6
-rw-r--r--Tests/QtAutomoc/defines_test/defines_test.cpp38
-rw-r--r--Tests/QtAutomoc/foo.h5
-rw-r--r--Tests/QtAutomoc/main.cpp2
7 files changed, 86 insertions, 10 deletions
diff --git a/Tests/QtAutomoc/Adir/CMakeLists.txt b/Tests/QtAutomoc/Adir/CMakeLists.txt
index 171222319..a1c36ffce 100644
--- a/Tests/QtAutomoc/Adir/CMakeLists.txt
+++ b/Tests/QtAutomoc/Adir/CMakeLists.txt
@@ -4,5 +4,5 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
add_library(libA SHARED libA.cpp)
-target_link_libraries(libA LINK_PUBLIC Qt4::QtCore)
+target_link_libraries(libA LINK_PUBLIC ${QT_QTCORE_TARGET})
generate_export_header(libA)
diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt
index fd624c803..69e52ac5d 100644
--- a/Tests/QtAutomoc/CMakeLists.txt
+++ b/Tests/QtAutomoc/CMakeLists.txt
@@ -2,9 +2,31 @@ cmake_minimum_required(VERSION 2.8)
project(QtAutomoc)
-find_package(Qt4 REQUIRED)
+if (QT_TEST_VERSION STREQUAL 4)
+ find_package(Qt4 REQUIRED)
+
+ # Include this directory before using the UseQt4 file.
+ add_subdirectory(defines_test)
+
+ include(UseQt4)
+
+ set(QT_QTCORE_TARGET Qt4::QtCore)
+else()
+ if (NOT QT_TEST_VERSION STREQUAL 5)
+ message(SEND_ERROR "Invalid Qt version specified.")
+ endif()
+ find_package(Qt5Widgets REQUIRED)
+
+ set(QT_QTCORE_TARGET Qt5::Core)
+
+ include_directories(${Qt5Widgets_INCLUDE_DIRS})
+ set(QT_LIBRARIES Qt5::Widgets)
+
+ if(Qt5_POSITION_INDEPENDENT_CODE)
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+ endif()
+endif()
-include(UseQt4)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/Tests/QtAutomoc/calwidget.cpp b/Tests/QtAutomoc/calwidget.cpp
index 24f3b4efe..cbfa5a8a6 100644
--- a/Tests/QtAutomoc/calwidget.cpp
+++ b/Tests/QtAutomoc/calwidget.cpp
@@ -38,7 +38,14 @@
**
****************************************************************************/
- #include <QtGui>
+ #include <QComboBox>
+ #include <QGridLayout>
+ #include <QLabel>
+ #include <QGroupBox>
+ #include <QCheckBox>
+ #include <QDateEdit>
+ #include <QCalendarWidget>
+ #include <QTextCharFormat>
#include "calwidget.h"
@@ -414,10 +421,10 @@
QComboBox *Window::createColorComboBox()
{
QComboBox *comboBox = new QComboBox;
- comboBox->addItem(tr("Red"), Qt::red);
- comboBox->addItem(tr("Blue"), Qt::blue);
- comboBox->addItem(tr("Black"), Qt::black);
- comboBox->addItem(tr("Magenta"), Qt::magenta);
+ comboBox->addItem(tr("Red"), QColor(Qt::red));
+ comboBox->addItem(tr("Blue"), QColor(Qt::blue));
+ comboBox->addItem(tr("Black"), QColor(Qt::black));
+ comboBox->addItem(tr("Magenta"), QColor(Qt::magenta));
return comboBox;
}
diff --git a/Tests/QtAutomoc/defines_test/CMakeLists.txt b/Tests/QtAutomoc/defines_test/CMakeLists.txt
new file mode 100644
index 000000000..ad4e684cb
--- /dev/null
+++ b/Tests/QtAutomoc/defines_test/CMakeLists.txt
@@ -0,0 +1,6 @@
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+add_executable(defines_test defines_test.cpp)
+set_target_properties(defines_test PROPERTIES AUTOMOC TRUE)
+target_link_libraries(defines_test Qt4::QtGui)
diff --git a/Tests/QtAutomoc/defines_test/defines_test.cpp b/Tests/QtAutomoc/defines_test/defines_test.cpp
new file mode 100644
index 000000000..2836d357b
--- /dev/null
+++ b/Tests/QtAutomoc/defines_test/defines_test.cpp
@@ -0,0 +1,38 @@
+
+#include <QObject>
+
+#ifdef QT_GUI_LIB
+#include <QTextDocument>
+
+class SomeDocument : public QTextDocument
+{
+ Q_OBJECT
+
+Q_SIGNALS:
+ void someSig();
+};
+#endif
+
+#ifdef QT_CORE_LIB
+class SomeObject : public QObject
+{
+ Q_OBJECT
+
+Q_SIGNALS:
+ void someSig();
+};
+#endif
+
+int main(int argc, char **argv)
+{
+#ifdef QT_CORE_LIB
+ QMetaObject sosmo = SomeObject::staticMetaObject;
+#endif
+#ifdef QT_GUI_LIB
+ QMetaObject sdsmo = SomeDocument::staticMetaObject;
+#endif
+
+ return 0;
+}
+
+#include "defines_test.moc"
diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutomoc/foo.h
index 32d4c8d8f..f23ec0739 100644
--- a/Tests/QtAutomoc/foo.h
+++ b/Tests/QtAutomoc/foo.h
@@ -16,7 +16,10 @@
#include <QObject>
-class Foo : public QObject
+class Foo
+#ifdef FOO
+ : public QObject
+#endif
{
Q_OBJECT
public:
diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp
index d952171b5..bd80180bf 100644
--- a/Tests/QtAutomoc/main.cpp
+++ b/Tests/QtAutomoc/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QApplication>
#include "codeeditor.h"
#include "calwidget.h"