RFC: new way to handle MOC files ?

Alexander Neundorf neundorf at kde.org
Mon Feb 24 21:31:51 GMT 2003


On Monday 24 February 2003 11:10, Stephan Kulow wrote:
> Am Sunday 23 February 2003 23:07 schrieb Alexander Neundorf:
> > On Friday 21 February 2003 20:55, Michael Schuerig wrote:
> > > On Friday 21 February 2003 18:51, Alexander Neundorf wrote:
> > > > It works the following way: a moc file is required if a source or
> > > > header contains the Q_OBJECT macro. The create_global_moc script
> > > > parses all files given on its command line and searches checks which
> > > > files contain "Q_OBJECT". These files are remembered (e.g. foo.cpp)
> > > > and a new file "mocs.cpp" is created which will include all required
> > > > moc files (e.g. foo.cpp.moc).
> > >
> > > This means all moc files have to be recompiled when any header/source
> > > containing Q_OBJECT changes. Is that a good idea?
> > >
> > > Michael
> >
> > I don't think that this would be a big problem.
> >
> > But it would give two big advantages:
> >
> > -possibility to explicitely recreate all moc files if something is fucked
> > up in the build tree: I can remember that once when I tried to compile
> > KDE 3.0 the Makefiles were not able to rebuild the moc files, I could
> > touch all *.h files and still they were not rebuild, when I deleted the
> > moc files, they were not recreated, make force-reedit (which some said
> > would help in this case) never worked here, and I'm not the only one
> > experiencing such problems from time to time, see various mails on these
> > mailinglists
> >
> > -it enables you to write Makefiles for small Qt/KDE projects by hand
> > without handcoding all the moc file rules (e.g. if you want to try
> > something out and don't want to mess around with the automake/conf/etc
> > stuff, but quickly hack something together)
> >
> > And I think it would make the build process a little bit easier to
> > understand. You don't have to do *anything* in your sources to have the
> > moc files created.
>
> You don't need anything in your sources with am_edit either. 

Well, you have to "include <blah.moc>" and (I think) then a moc file will be 
generated from the header. Does it actually also work if I declare a class 
with signals and stuff only in the cpp file ?

And I can remember that when I updated  the first time again some weeks before 
KDE 3.0 all my moc files were unsuable ("created with a wrong version of 
moc") and there was no way to have them recreated. Deleting the mocs (the 
makefile complained then about the missing files but didn't create them), 
touching the headers, Make force-reedit, nothing worked. 
Finally I deleted the whole cvs tree and checked it out again.
I think I'm not the only person who experienced such problems already.

> It's just
> fastens the compilation, so we run includemocs once in a while. There is
> really little to understand about it. I'm fine with your script floating
> around, so little Makefiles can be hacked together easily for those not
> liking the bloat kapptemplate would generate for these projects, that often
> aren't supposed to be distributed (I for one generate subdirs in kdetoys
> for such projects, but that's me :). But please don't change anything in
> CVS to use it.

I wouldn't dare to touch this stuff ;-)

Bye
Alex
-- 
Work: alexander.neundorf at jenoptik.com - http://www.jenoptik-los.de
Home: neundorf at kde.org                - http://www.kde.org
      alex at neundorf.net               - http://www.neundorf.net





More information about the kde-core-devel mailing list