RFC: automoc changes

Alexander Neundorf neundorf at kde.org
Sun Nov 5 13:48:46 CET 2006


Hi,

currently we have in KDE4Macros.cmake the KDE4_AUTOMOC(src1 ... srcN) macro, 
which has to be used on the files you want to have automoced.
Now this has the disadvantages that
-it happens at cmake time, i.e. when you add an include-moc line in a source 
file this isn't detected by the buildsystem without touching one of the cmake 
files
-during cmake time all source files will be parsed for the include-moc lines, 
which takes some time (mainly with cold caches)

Since two weeks or something like that the internal handling of moc files has 
changed so that they are generated more reliably, now the target depends on 
them, not only the source files which include them. This is nice and all, but 
has the side effect that now automoc works only if you use the 
kde4_add_library/executable/plugin/kdeinit_executable() functions. 
Before this change it was possible to use 

kde4_automoc(src1 ... srcN)
add_executable(kblub src1 ... srcN)

and it should have worked (didn't try for a long time).
Now this doesn't work anymore, you have to use the kde4_add_* equivalents.
I have a different automoc implementation lying around on my local harddisk, 
which 
-moves the complete automoc functionality to 
kde4_add_library/executable/plugin/kdeinit_executable()
-thereby removes the need for the kde4_automoc
-parses the source files at buildtime, not cmake time and notices new 
include-mocs without rerunning cmake
-speeds up cmake time a bit
BUT you now have to use the kde4_add_* functions.

So if you do 

set(mySrcs main.cpp widget.cpp ...)
kde4_add_executable(kblub ${mySrcs})

these files will be automoced.
But since this still takes some time and may not always be wanted, there must 
be a way to enable/disable it.

I see three options:
1) disabled by default and require the argument AUTOMOC:
kde4_add_executable(kblub AUTOMOC ${mySrcs} )   # with automoc
kde4_add_executable(kblah ${myOtherSrcs} )      # no automoc

pro: cmake will only do what it's explicitely told
con: all kde4_add_*() calls have to be adjusted

2) enabled by default and require NO_AUTOMOC for disabling it:
kde4_add_executable(kblub ${mySrcs} )                 # with automoc
kde4_add_executable(kblah NO_AUTMOC ${myOtherSrcs} )  # no automoc
pro: no need to modify all kde4_add_*() calls
con: cmake will do something implicitely, which I don't really like

3) use a variable which will decide whether the functions will use automoc or 
not:
set(KDE4_AUTOMOC TRUE)
kde4_add_executable(kblub ${mySrcs} )                 # with automoc
set(KDE4_AUTOMOC FALSE)
kde4_add_executable(kblah ${mySrcs} )                 # no automoc

pro: 
-no need to modify all kde4_add_*() calls
-slightly faster at cmake time than 1) and 2)
con:
-using an explicite argument instead of a global variable to influence the 
behaviour is easier to document and understand

So, any opinions on this ?

Bye
Alex

Btw. can we please archive this mailing list on lists.kde.org ?
-- 
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-buildsystem mailing list