summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-09-15 12:41:07 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-10-24 10:30:41 (GMT)
commit9c87d9cc3e7a046f79ff62eda81203ef424e4a14 (patch)
treeda7af3604feb5e81e122aaabbc8a84345ba90440 /Tests/QtAutogen
parent84218e1870ab075c9e2be1f2947358702c849fed (diff)
downloadCMake-9c87d9cc3e7a046f79ff62eda81203ef424e4a14.zip
CMake-9c87d9cc3e7a046f79ff62eda81203ef424e4a14.tar.gz
CMake-9c87d9cc3e7a046f79ff62eda81203ef424e4a14.tar.bz2
Add automatic rcc invocation for Qt.
This replaces the need to invoke qt4_add_resources by allowing adding the source .qrc file directly to the target sources.
Diffstat (limited to 'Tests/QtAutogen')
-rw-r--r--Tests/QtAutogen/CMakeLists.txt5
-rw-r--r--Tests/QtAutogen/main.cpp16
-rw-r--r--Tests/QtAutogen/resourcetester.cpp21
-rw-r--r--Tests/QtAutogen/resourcetester.h17
-rw-r--r--Tests/QtAutogen/test.qrc5
5 files changed, 55 insertions, 9 deletions
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index e194b94..7991c4e 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -36,6 +36,7 @@ add_definitions(-DFOO -DSomeDefine="Barx")
set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
# create an executable and two library targets, each requiring automoc:
add_library(codeeditorLib STATIC codeeditor.cpp)
@@ -43,7 +44,9 @@ add_library(codeeditorLib STATIC codeeditor.cpp)
add_library(privateSlot OBJECT private_slot.cpp)
add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
- xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>)
+ xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
+ test.qrc resourcetester.cpp
+)
set_target_properties(QtAutogen codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
diff --git a/Tests/QtAutogen/main.cpp b/Tests/QtAutogen/main.cpp
index 39597ba..c8a036e 100644
--- a/Tests/QtAutogen/main.cpp
+++ b/Tests/QtAutogen/main.cpp
@@ -38,7 +38,8 @@
**
****************************************************************************/
-#include <QApplication>
+#include <QCoreApplication>
+#include <QTimer>
#include "codeeditor.h"
#include "calwidget.h"
@@ -49,16 +50,11 @@
#include "xyz.h"
#include "yaf.h"
#include "libC.h"
+#include "resourcetester.h"
int main(int argv, char **args)
{
- QApplication app(argv, args);
-
- CodeEditor editor;
- editor.setWindowTitle(QObject::tr("Code Editor Example"));
-
- Window w;
- w.setWindowTitle(QObject::tr("Window Example"));
+ QCoreApplication app(argv, args);
Foo foo;
foo.doFoo();
@@ -81,5 +77,9 @@ int main(int argv, char **args)
LibC lc;
lc.foo();
+ ResourceTester rt;
+
+ QTimer::singleShot(0, &rt, SLOT(doTest()));
+
return app.exec();
}
diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp
new file mode 100644
index 0000000..43314e1
--- /dev/null
+++ b/Tests/QtAutogen/resourcetester.cpp
@@ -0,0 +1,21 @@
+
+#include "resourcetester.h"
+
+#include <QDebug>
+#include <QApplication>
+#include <QFile>
+#include <QTimer>
+
+ResourceTester::ResourceTester(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+void ResourceTester::doTest()
+{
+ if (!QFile::exists(":/CMakeLists.txt"))
+ qApp->exit(EXIT_FAILURE);
+
+ QTimer::singleShot(0, qApp, SLOT(quit()));
+}
diff --git a/Tests/QtAutogen/resourcetester.h b/Tests/QtAutogen/resourcetester.h
new file mode 100644
index 0000000..b02cb4e
--- /dev/null
+++ b/Tests/QtAutogen/resourcetester.h
@@ -0,0 +1,17 @@
+
+#ifndef RESOURCE_TESTER_H
+#define RESOURCE_TESTER_H
+
+#include <QObject>
+
+class ResourceTester : public QObject
+{
+ Q_OBJECT
+public:
+ explicit ResourceTester(QObject *parent = 0);
+
+private slots:
+ void doTest();
+};
+
+#endif
diff --git a/Tests/QtAutogen/test.qrc b/Tests/QtAutogen/test.qrc
new file mode 100644
index 0000000..c3d4e3c
--- /dev/null
+++ b/Tests/QtAutogen/test.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>CMakeLists.txt</file>
+</qresource>
+</RCC>