moc files not generated in kdewidgets anymore

Alexander Neundorf neundorf at
Thu Jun 14 21:00:29 UTC 2012

On Thursday 14 June 2012, David Faure wrote:
> In the frameworks branch of kdelibs, cmake is not creating the moc files in
> kdewidgets/ anymore.
> Testcase: build kdelibs-frameworks (qt4, full build) from scratch, or just
> delete the moc files in your existing build.
> Error message:
> [100%] Automoc for target kdewidgets
> [100%] Built target kdewidgets_automoc
> [100%] Generating kdewidgets.cpp
> [100%] Building CXX object
> kdewidgets/CMakeFiles/kdewidgets.dir/kdewidgets.cpp.o
> /d/kde/build/5/kdelibs-frameworks/kdewidgets/kdewidgets.cpp:2584:71: fatal
> error: /d/kde/build/5/kdelibs-frameworks/kdewidgets/kdewidgets.moc: No
> such file or directory
> CMakeLists.txt extract:
>   # get the name of the generated wrapper script (which sets up
> makekdewidgets WRAPPER_SCRIPT)
>   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kdewidgets.cpp
> ${CMAKE_CURRENT_BINARY_DIR}/kdewidgets.cpp
> DEPENDS makekdewidgets)
>   set(kdewidgets_PART_SRCS
>      classpreviews.cpp
>      ${CMAKE_CURRENT_BINARY_DIR}/kdewidgets.cpp
>   )
>   qt4_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/kdewidgets.cpp
> ${CMAKE_CURRENT_BINARY_DIR}/kdewidgets.moc)
> Possible fix:
>  adding the moc file for the list of sources, to force it to be generated,
> seems to work. Shall I do that?

For now, yes, please.

Not quite sure why it was building for me, probably the moc files were already 

The reason is that this now uses FindQt4.cmake from cmake, and KDEs version 
and the one in cmake were not kept completely in sync.

The difference here is that qt4_generate_moc() from KDE calls 
macro_add_file_dependency() to make the cpp file depend on the generated moc 
file, so the moc is created. The one coming with cmake doesn't do this, so 
this dependency is not there and the file is not created.

I can remember that using OBJECT_DEPENDS (as is done in KDEs version) is not 
recommended. I'll check on the cmake list what the recommended use of 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Kde-buildsystem mailing list