[cmake-developers] Automoc in cmake

Alexander Neundorf neundorf at kde.org
Thu Jun 9 04:12:22 EDT 2011


On Thursday 09 June 2011, Rolf Eike Beer wrote:
> > Right now this is done by adding an extra target <targetname>_automoc to
> > every target.
> > If I added a custom command for every source file, which would create
> > basically a timestamp file, and run automoc just on this source file, I
> > would get the mocs generated, and automoc only rerun if the source file
> > changed, but
> > since the source file depends on the moc files which come from a rule
> > 
> > which depends on the source file, I would get a cyclic dependency I think:

> Wouldn't it be enough to just say the target depends on the source file?
> "make" does this sort of dependency checking anyway, so let them do this
> sort of stuff.

Hmm, not sure.

Dependencies to generated files, so that the custom command is executed, 
should be expressed by adding the generated files to the target.
Ok so far.

But would this make sure that moc_foo.cpp has already been created when 
foo.cpp is compiled ?
AFAIK depending on generated files via the #include does not work/is not 
reliable (that's why generated files need to be added to the target).
When we switched KDE to cmake, in the beginning it was done that way, but we 
found that it was unreliable, and the official recommended way is to do it via 
the targets.

Otherwise, this would be a simpler solution.

Alex



More information about the cmake-developers mailing list