[CMake] [PATCH] FindQt4.cmake qt4_automoc improvements

Alexander Neundorf a.neundorf-work at gmx.net
Sun May 18 18:43:54 EDT 2008


On Saturday 17 May 2008, Tanguy Krotoff wrote:
> Hello
>
> I've noticed some lake of features inside FindQt4.cmake qt4_automoc macro
> This patch intend to fix this.
> (patch against CMake 2.6.0)
>
> How current qt4_automoc works:
> Looks for files that contain string: #include "*.moc"
>
>
> Issues:
>
> - With QMake, it is possible to specify also #include "moc_*.cpp"
> Current qt4_automoc does not handle this.
> Here the fix:
> -            STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match
> "${_contents}")
> +            STRING(REGEX MATCHALL "#include +([^
> ]+\\.moc[\">])|(\"moc_+[^ ]+\\.cpp[\">])" _match "${_contents}")
>
>
> - Current qt4_automoc doesn't check if the .h corresponding to the
> *.moc file exists.
> Sometimes the Q_OBJECT macro is directly inside the .cpp file and
> there is no .h file
> Here the fix:
> +                  IF(NOT EXISTS ${_header})
> +                     SET(_header ${_abs_PATH}/${_basename}.cpp)
> +                  ENDIF(NOT EXISTS ${_header})
> As you see .cpp extension is hardcoded but I don't think there is the
> need for using CMAKE_CXX_SOURCE_FILE_EXTENSIONS as QMake probably
> don't support it.
>
> Test:
> I managed to compile Phonon library that relies exclusively on
> #include "moc_*.cpp" and #include "*.moc" feature

qt4_automoc() doesn't support all the fancy automoc features of qmake or KDE4s 
automoc and I don't feel like adding it.
Phonon is about to move to kdesupport (i.e. outside KDE), and or that to work 
it will use the new KDE-independent automoc4 (also in kdesupport since two 
weeks), which supports all automoc features. We (KDE) will do a reparate 
release of automoc4 in the foreseeable future, so it can be used by non-KDE 
projects.
http://websvn.kde.org/trunk/kdesupport/

Alex


More information about the CMake mailing list