From 30fd8e603a52b7230e0b716d8120fc01551c8a4f Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 22 Nov 2011 19:19:31 +0100 Subject: automoc: add test for including the moc file from another header including moc_xyz.cpp in abc.cpp should run moc on xyz.h (and include the file in abc.cpp) Alex --- Tests/QtAutomoc/CMakeLists.txt | 2 +- Tests/QtAutomoc/abc.cpp | 4 ++++ Tests/QtAutomoc/main.cpp | 4 ++++ Tests/QtAutomoc/xyz.cpp | 28 ++++++++++++++++++++++++++++ Tests/QtAutomoc/xyz.h | 28 ++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Tests/QtAutomoc/xyz.cpp create mode 100644 Tests/QtAutomoc/xyz.h diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt index c81ac11..9f02618 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/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 abc.cpp) +add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp) set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) diff --git a/Tests/QtAutomoc/abc.cpp b/Tests/QtAutomoc/abc.cpp index f922615..25071cd 100644 --- a/Tests/QtAutomoc/abc.cpp +++ b/Tests/QtAutomoc/abc.cpp @@ -37,5 +37,9 @@ void Abc::doAbc() pa.print(); } +// check that including the moc file for the cpp file and the header works: #include "abc.moc" #include "moc_abc.cpp" + +// check that including a moc file from another header works: +#include "moc_xyz.cpp" diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp index 5414daf..7eb29a3 100644 --- a/Tests/QtAutomoc/main.cpp +++ b/Tests/QtAutomoc/main.cpp @@ -46,6 +46,7 @@ #include "blub.h" #include "sub/bar.h" #include "abc.h" +#include "xyz.h" int main(int argv, char **args) { @@ -70,5 +71,8 @@ int main(int argv, char **args) Abc abc; abc.doAbc(); + Xyz xyz; + xyz.doXyz(); + return app.exec(); } diff --git a/Tests/QtAutomoc/xyz.cpp b/Tests/QtAutomoc/xyz.cpp new file mode 100644 index 0000000..a3562a3 --- /dev/null +++ b/Tests/QtAutomoc/xyz.cpp @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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 "xyz.h" + +#include + +Xyz::Xyz() +:QObject() +{ +} + + +void Xyz::doXyz() +{ + printf("This is xyz !\n"); +} diff --git a/Tests/QtAutomoc/xyz.h b/Tests/QtAutomoc/xyz.h new file mode 100644 index 0000000..8175d37 --- /dev/null +++ b/Tests/QtAutomoc/xyz.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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 XYZ_H +#define XYZ_H + +#include + +class Xyz : public QObject +{ + Q_OBJECT + public: + Xyz(); + public slots: + void doXyz(); +}; + +#endif -- cgit v0.12