ソースを参照

automoc: add a test for including both abc.moc and moc_abc.cpp

Alex
Alex Neundorf 14 年 前
コミット
80dfbc99f4

+ 1 - 1
Tests/QtAutomoc/CMakeLists.txt

@@ -13,7 +13,7 @@ add_definitions(-DFOO)
 # create an executable and a library target, both requiring automoc:
 add_library(codeeditorLib STATIC codeeditor.cpp)
 
-add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp)
+add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp)
 
 set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE)
 

+ 41 - 0
Tests/QtAutomoc/abc.cpp

@@ -0,0 +1,41 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2011 Kitware, Inc.
+  Copyright 2011 Alexander Neundorf ([email protected])
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+
+#include "abc.h"
+
+#include <stdio.h>
+
+class PrintAbc : public QObject
+{
+  Q_OBJECT
+  public:
+    PrintAbc():QObject() {}
+  public slots:
+    void print() const { printf("abc\n"); }
+};
+
+Abc::Abc()
+:QObject()
+{
+}
+
+
+void Abc::doAbc()
+{
+  PrintAbc pa;
+  pa.print();
+}
+
+#include "abc.moc"
+#include "moc_abc.cpp"

+ 28 - 0
Tests/QtAutomoc/abc.h

@@ -0,0 +1,28 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2011 Kitware, Inc.
+  Copyright 2011 Alexander Neundorf ([email protected])
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef ABC_H
+#define ABC_H
+
+#include <QObject>
+
+class Abc : public QObject
+{
+  Q_OBJECT
+  public:
+    Abc();
+  public slots:
+    void doAbc();
+};
+
+#endif

+ 4 - 0
Tests/QtAutomoc/main.cpp

@@ -45,6 +45,7 @@
 #include "foo.h"
 #include "blub.h"
 #include "sub/bar.h"
+#include "abc.h"
 
 int main(int argv, char **args)
 {
@@ -66,5 +67,8 @@ int main(int argv, char **args)
   Bar bar;
   bar.doBar();
 
+  Abc abc;
+  abc.doAbc();
+
   return app.exec();
 }