[cmake-developers] Automoc in cmake

Clinton Stimpson clinton at elemtech.com
Wed Jun 8 15:33:01 EDT 2011


On Wednesday, June 08, 2011 12:59:36 pm Alexander Neundorf wrote:
> On Monday, June 06, 2011 03:37:16 PM Brad King wrote:
> > On 06/06/2011 03:56 AM, Alexander Neundorf wrote:
> > > On Saturday, June 04, 2011 10:24:52 AM 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.
> > 
> > I agree with Nico's response that this is too specific to integrate into
> > CMake itself.  That level of automagic processing puts too much inside
> > the add_executable and add_library commands.  This kind of customization
> > belongs in macros.
> > 
> > > Yesterday we finished porting our automoc away from Qt to pure
> > > STL/cmsys. It is now a small executable of 300kb and linking to
> > > nothing special. It is also BSD-licensed.
> > 
> > Great!  I suggest you package this in a distribution that provides the
> 
> > executable and CMake macros to use it:
> That's already the current state, and developers are not happy with it.
> They don't know about it or adding yet another dependency to the build is a
> problem for them, e.g. due to strict policies at work.
> 
> I do not make this up, people come to me and complain that cmake doesn't do
> it.
> Everybody I talked to who is used to automoc from KDE or from qmake wants
> to have it available directly in cmake.
> 
> Even the one Gnome guy who was in Randa was not happy with cmake for some
> Qt projects he had because it didn't do automoc. So he felt cmake is too
> complicated and stayed with qmake.
> The same for about every KDE developer, i.e. hundreds.
> 
> We (me, you, Bill, Matthias Kretz,  Andreas Hartmetz) talked about this
> before, in march 2008. In a mail from March 18, 2008, you write:
> 
> --------------8<----------------8<------------------8<---------------------
> 
> Alexander Neundorf wrote:
> > in kdelibs we have a tool "automoc", which is used to handle the moc
> > files of  Qt automatically, i.e. it parses the source files for Q_OBJECT
> > etc. and runs moc as required.
> > It is written using Qt 4 (QtCore only AFAIK).
> > In order to make this usable also for Qt-only applications we (KDE) would
> > like to move automoc out of kdelibs, the first step would be a separate
> > svn module, or ideally directly into cmake.
> 
> Adding automoc would be a great motivation for people to use CMake for
> Qt-based stuff.
> 
> ...
> 
> > If those two things were met, would you accept it in cmake cvs as an
> > additional tool or maybe also as a built-in command line command (as -E
> > copy etc.) ?
> 
> If it is not too much code I'm not against accepting it.  Bill?
> ...
> 
> -Brad
> --------------8<----------------8<------------------8<---------------------
> 
> The "two things" are
> - BSD licensing,  we did that 3 years ago:
> http://quickgit.kde.org/?p=automoc.git&a=commit&h=78fdba1e2d96bc45512531748
> ffb770cb1124798 -and porting to STL+cmsys, we did that now
> 
> Beside that, I didn't ask explicitely, but I'm sure without automoc cmake
> is out of the game for becoming the buildsystem for Qt5 (because in Qt4
> they do automoc in qmake).
> 

What if this was a generic tool that could scan code to handle custom 
dependencies, with the ability to do two things: (re)generated dependent files 
or (re)generate the file with dependencies (sounds like a make tool ;) ).  
Don't some Visual Studio users do this type of custom build 
phases/steps/thingy by creating an Add-In?

Would that be an automoc equivalent if there was a macro that gave it the 
rules for generating the dependencies?

Also, (a long outstanding bug), a Qt .qrc file has dependencies specified in 
xml, which should be handled at build time.  Right now, the best we can do is 
handle it at configure time, so we end up missing the regeneration of the 
source file from the .qrc file sometimes or the build rules becomes invalidated 
with source changes.

It seems an extra tool is needed at build time to handle qrc files correctly, 
and I'm wondering if a generic tool could handle both this and the autmoc.

-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com



More information about the cmake-developers mailing list