[cmake-developers] Automoc in cmake
Alexander Neundorf
neundorf at kde.org
Mon Aug 15 19:44:55 EDT 2011
On Saturday 04 June 2011, Alexander Neundorf wrote:
> Hi,
>
> one feature which all KDE developers are used to and which is also used by
> qmake when building Qt is "automoc".
>
> This means that you don't have to write
> qt4_wrap_cpp(srcs ${filesToBeMoced})
>
> but instead you simply do
> kde4_add_executable(hello ${srcs})
> and everything including moc is handled automatically.
>
> This is done so that in your foo.cpp file you include the moc-file e.g. at
> the end:
>
> -------------------
>
> Foo::Foo()
>
> :QObject()
>
> {
> }
> ...
>
> void Foo::doSomething()
> {
> }
>
> #include "foo.moc"
There is now a branch AutomocForQt on the cmake stage.
Docs and a test are still missing.
To enable automoc, set the target property AUTOMOC to TRUE.
As discussed, this is now handled in cmGlobalGenerator::Generate().
There was one more feature which I didn't actually know about:
even without a #include "foo.moc", automoc still parses the source files for
"Q_OBJECT", and if it finds some, it runs moc and includes all generates moc
files (which are not used anywhere else) in a generated foo_automoc.cpp file.
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20110816/fa1d6134/attachment.html>
More information about the cmake-developers
mailing list