I want to port a quite large qmake project to CMake. I reduced my problem to two libraries of the same project, lets call them lib1 and lib2. Lib2 depends on lib1. Both have source files using Q_OBJECT. So for both libraries I want to use the AUTOMOC.
For both libraries AUTOMOC is switched on like this:
set_target_properties(${target} PROPERTIES AUTOMOC ON)
The problem is that during processing of lib2 all the moc files that have been generated for lib1 already are being generated again. In detail inside the build folder I have src/lib1/lib1_autogen/mocs_compilation.cpp
with some files and I have src/lib2/lib2_autogen/mocs_compilation.cpp
with the content of that from lib1 plus some additional moc files from lib2.
I have a similar problem with AUTOUIC, this also re-generates all already created ui_*.h.
If the AUTOMOC goes through the header files of lib1 it will find includes of lib1 headers which then will include other headers with Q_OBJECT. But I think AUTOMOC should be clever enough to check this and not building it again? In a minimal sample it behaved that smart but unfortunately not for my project.
Any ideas what to check?