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
This commit is contained in:
Alex Neundorf 2011-11-22 19:19:31 +01:00
parent 80dfbc99f4
commit 30fd8e603a
5 changed files with 65 additions and 1 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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();
}

28
Tests/QtAutomoc/xyz.cpp Normal file
View File

@ -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 <stdio.h>
Xyz::Xyz()
:QObject()
{
}
void Xyz::doXyz()
{
printf("This is xyz !\n");
}

28
Tests/QtAutomoc/xyz.h Normal file
View File

@ -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 <QObject>
class Xyz : public QObject
{
Q_OBJECT
public:
Xyz();
public slots:
void doXyz();
};
#endif