summaryrefslogtreecommitdiff
path: root/Tests/QtAutomoc
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/QtAutomoc')
-rw-r--r--Tests/QtAutomoc/Adir/CMakeLists.txt8
-rw-r--r--Tests/QtAutomoc/Adir/libA.cpp13
-rw-r--r--Tests/QtAutomoc/Adir/libA.h18
-rw-r--r--Tests/QtAutomoc/Bdir/CMakeLists.txt10
-rw-r--r--Tests/QtAutomoc/Bdir/libB.cpp13
-rw-r--r--Tests/QtAutomoc/Bdir/libB.h21
-rw-r--r--Tests/QtAutomoc/CMakeLists.txt35
-rw-r--r--Tests/QtAutomoc/empty.cpp1
-rw-r--r--Tests/QtAutomoc/empty.h9
-rw-r--r--Tests/QtAutomoc/libC.cpp13
-rw-r--r--Tests/QtAutomoc/libC.h22
-rw-r--r--Tests/QtAutomoc/main.cpp4
12 files changed, 161 insertions, 6 deletions
diff --git a/Tests/QtAutomoc/Adir/CMakeLists.txt b/Tests/QtAutomoc/Adir/CMakeLists.txt
new file mode 100644
index 000000000..171222319
--- /dev/null
+++ b/Tests/QtAutomoc/Adir/CMakeLists.txt
@@ -0,0 +1,8 @@
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+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)
+generate_export_header(libA)
diff --git a/Tests/QtAutomoc/Adir/libA.cpp b/Tests/QtAutomoc/Adir/libA.cpp
new file mode 100644
index 000000000..3968c4415
--- /dev/null
+++ b/Tests/QtAutomoc/Adir/libA.cpp
@@ -0,0 +1,13 @@
+
+#include "libA.h"
+
+LibA::LibA(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+int LibA::foo()
+{
+ return 0;
+}
diff --git a/Tests/QtAutomoc/Adir/libA.h b/Tests/QtAutomoc/Adir/libA.h
new file mode 100644
index 000000000..03ad1e006
--- /dev/null
+++ b/Tests/QtAutomoc/Adir/libA.h
@@ -0,0 +1,18 @@
+
+#ifndef LIBA_H
+#define LIBA_H
+
+#include "liba_export.h"
+
+#include <QObject>
+
+class LIBA_EXPORT LibA : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LibA(QObject *parent = 0);
+
+ int foo();
+};
+
+#endif
diff --git a/Tests/QtAutomoc/Bdir/CMakeLists.txt b/Tests/QtAutomoc/Bdir/CMakeLists.txt
new file mode 100644
index 000000000..d9d4aa7fa
--- /dev/null
+++ b/Tests/QtAutomoc/Bdir/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
+
+add_library(libB SHARED libB.cpp)
+generate_export_header(libB)
+
+# set_property(TARGET libB APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
+target_link_libraries(libB LINK_PUBLIC libA)
diff --git a/Tests/QtAutomoc/Bdir/libB.cpp b/Tests/QtAutomoc/Bdir/libB.cpp
new file mode 100644
index 000000000..72f2cfae9
--- /dev/null
+++ b/Tests/QtAutomoc/Bdir/libB.cpp
@@ -0,0 +1,13 @@
+
+#include "libB.h"
+
+LibB::LibB(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+int LibB::foo()
+{
+ return a.foo();
+}
diff --git a/Tests/QtAutomoc/Bdir/libB.h b/Tests/QtAutomoc/Bdir/libB.h
new file mode 100644
index 000000000..510c17f8f
--- /dev/null
+++ b/Tests/QtAutomoc/Bdir/libB.h
@@ -0,0 +1,21 @@
+
+#ifndef LIBB_H
+#define LIBB_H
+
+#include "libb_export.h"
+
+#include <QObject>
+#include "libA.h"
+
+class LIBB_EXPORT LibB : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LibB(QObject *parent = 0);
+
+ int foo();
+private:
+ LibA a;
+};
+
+#endif
diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt
index 5e3686dbc..fd624c803 100644
--- a/Tests/QtAutomoc/CMakeLists.txt
+++ b/Tests/QtAutomoc/CMakeLists.txt
@@ -13,11 +13,34 @@ add_definitions(-DFOO -DSomeDefine="Barx")
# enable relaxed mode so automoc can handle all the special cases:
set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
-# create an executable and a library target, both requiring automoc:
+# create an executable and two library targets, each requiring automoc:
add_library(codeeditorLib STATIC codeeditor.cpp)
-add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp private_slot.cpp)
-
-set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE)
-
-target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} )
+add_library(privateSlot OBJECT private_slot.cpp)
+
+add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
+ xyz.cpp yaf.cpp $<TARGET_OBJECTS:privateSlot>)
+
+set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
+
+include(GenerateExportHeader)
+# The order is relevant here. B depends on A, and B headers depend on A
+# headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we
+# test that CMAKE_AUTOMOC successfully reads the include directories
+# for the build interface from those targets. There has previously been
+# a bug where caching of the include directories happened before
+# extracting the includes to pass to moc.
+add_subdirectory(Bdir)
+add_subdirectory(Adir)
+add_library(libC SHARED libC.cpp)
+set_target_properties(libC PROPERTIES AUTOMOC TRUE)
+generate_export_header(libC)
+target_link_libraries(libC LINK_PUBLIC libB)
+
+target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} libC)
+
+add_library(empty STATIC empty.cpp)
+set_target_properties(empty PROPERTIES AUTOMOC TRUE)
+target_link_libraries(empty no_link_language)
+add_library(no_link_language STATIC empty.h)
+set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE)
diff --git a/Tests/QtAutomoc/empty.cpp b/Tests/QtAutomoc/empty.cpp
new file mode 100644
index 000000000..ab32cf6c8
--- /dev/null
+++ b/Tests/QtAutomoc/empty.cpp
@@ -0,0 +1 @@
+// No content
diff --git a/Tests/QtAutomoc/empty.h b/Tests/QtAutomoc/empty.h
new file mode 100644
index 000000000..4566142c1
--- /dev/null
+++ b/Tests/QtAutomoc/empty.h
@@ -0,0 +1,9 @@
+
+#include <QObject>
+
+class Empty : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Empty(QObject *parent = 0) {}
+};
diff --git a/Tests/QtAutomoc/libC.cpp b/Tests/QtAutomoc/libC.cpp
new file mode 100644
index 000000000..8d61cb1bf
--- /dev/null
+++ b/Tests/QtAutomoc/libC.cpp
@@ -0,0 +1,13 @@
+
+#include "libC.h"
+
+LibC::LibC(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+int LibC::foo()
+{
+ return b.foo();
+}
diff --git a/Tests/QtAutomoc/libC.h b/Tests/QtAutomoc/libC.h
new file mode 100644
index 000000000..4fb4a2cf4
--- /dev/null
+++ b/Tests/QtAutomoc/libC.h
@@ -0,0 +1,22 @@
+
+#ifndef LIBC_H
+#define LIBC_H
+
+#include "libc_export.h"
+
+#include <QObject>
+#include "libB.h"
+
+class LIBC_EXPORT LibC : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LibC(QObject *parent = 0);
+
+
+ int foo();
+private:
+ LibB b;
+};
+
+#endif
diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp
index 738f67720..d952171b5 100644
--- a/Tests/QtAutomoc/main.cpp
+++ b/Tests/QtAutomoc/main.cpp
@@ -48,6 +48,7 @@
#include "abc.h"
#include "xyz.h"
#include "yaf.h"
+#include "libC.h"
int main(int argv, char **args)
{
@@ -78,5 +79,8 @@ int main(int argv, char **args)
Yaf yaf;
yaf.doYaf();
+ LibC lc;
+ lc.foo();
+
return app.exec();
}