make KDE4_AUTOMOC compatible to qmake
Thiago Macieira
thiago at kde.org
Fri Jun 8 11:50:33 CEST 2007
Matthias Kretz said:
> On Friday 08 June 2007, Thiago Macieira wrote:
>> Alexander Neundorf said:
>> > IOW we have to stay with a non-source-file extension.
>>
>> Yep:
>>
>> *.moc for anything #included (this includes moc_*.moc, if needed)
>> moc_*.cpp for anything that isn't #included (but has a Q_OBJECT
>> nonetheless)
>
> But KDE4_AUTOMOC will not run the moc unless you include a file ending
> in .moc.
> QT4_GENERATE_MOC can be used to explicitly create a moc file from a header
> file, though it also uses OBJECT_DEPENDS (why is it allowed here and not
> in
> KDE4_AUTOMOC?). QT4_AUTOMOC also uses OBJECT_DEPENDS...
I didn't mean this was the actual behaviour. Sorry for not making that
explicit.
The way I see it, the ideal "automoc" behaviour would be to:
For each "foo.cpp"
if it contains Q_OBJECT:
// this case is common in QtTest-based unit tests
it must #include "foo.moc"
add command: moc -o foo.moc foo.cpp
For each "foo.h"
if it contains Q_OBJECT:
if "foo.cpp" contains #include "foo.moc":
add command: moc -o foo.moc foo.h
else if "foo.cpp" contains #include "moc_foo.moc":
add command: moc -o moc_foo.moc foo.h
else if it is in the form "foo_p.h" and
"foo.cpp" contains #include "foo_p.moc":
add command: moc -o foo_p.moc foo_p.h
else:
add command: moc -o moc_foo.cpp foo.h
add "moc_foo.cpp" to the to-be-compiled list
A foo.h and its foo.cpp cannot both contain Q_OBJECT. If a given .cpp
requires public and private QObject classes, it must have a separate _p.h
header and include both .mocs.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
More information about the Kde-buildsystem
mailing list