MantisBT - CMake
View Issue Details
0012533CMakeCMakepublic2011-10-21 22:072011-10-22 14:31
Jason Haslam 
Alex Neundorf 
normalminoralways
closedfixed 
Mac OS X Lion
CMake 2.8.6 
 
0012533: AUTOMOC property doesn't moc header when the source file #includes *.moc
Given the following:

A.h:
class A {
  Q_OBJECT
}

A.cpp:
#include "A.h"
class B {
  Q_OBJECT
}
...
#include "A.moc"

The new AUTOMOC property correctly generates A.moc for class B defined in the source file, but fails to generate moc_A.cpp (and #include it in target_automoc.cpp) for class A defined in the header. I can force moc to run on the header by #including moc_A.cpp as well. IMHO the header should be scanned for classes containing Q_OBJECT even if the source file #includes *.moc.
No tags attached.
Issue History
2011-10-21 22:07Jason HaslamNew Issue
2011-10-22 11:08Alex NeundorfAssigned To => Alex Neundorf
2011-10-22 11:08Alex NeundorfStatusnew => assigned
2011-10-22 12:07Alex NeundorfNote Added: 0027618
2011-10-22 12:10Alex NeundorfNote Added: 0027619
2011-10-22 13:47Alex NeundorfNote Added: 0027620
2011-10-22 13:47Alex NeundorfStatusassigned => closed
2011-10-22 13:47Alex NeundorfResolutionopen => fixed
2011-10-22 14:07Jason HaslamNote Added: 0027621
2011-10-22 14:07Jason HaslamStatusclosed => feedback
2011-10-22 14:07Jason HaslamResolutionfixed => reopened
2011-10-22 14:11Jason HaslamNote Added: 0027622
2011-10-22 14:11Jason HaslamStatusfeedback => assigned
2011-10-22 14:31Alex NeundorfNote Added: 0027624
2011-10-22 14:31Alex NeundorfStatusassigned => closed
2011-10-22 14:31Alex NeundorfResolutionreopened => fixed

Notes
(0027618)
Alex Neundorf   
2011-10-22 12:07   
I see.
It only automatically scans the header file if it has found neither a *.moc nor a moc_*.cpp include.
(0027619)
Alex Neundorf   
2011-10-22 12:10   
Does adding the A.h to the list of source files for the target also make it work for you ?
(without inserting an #include "moc_A.cpp" into A.cpp)

Alex
(0027620)
Alex Neundorf   
2011-10-22 13:47   
This should be working now in the AutomocFindQ_OBJECTAlwaysInHeader branch on cmake stage, and I also already merged it into cmake next.
I also extended the automoc test to test for this case.
(0027621)
Jason Haslam   
2011-10-22 14:07   
Yes, adding the header file to the list of source files works. That's a better workaround. Thanks for addressing this so quickly!
(0027622)
Jason Haslam   
2011-10-22 14:11   
Ugh, didn't really mean to reopen this bug. I just wanted to add a note. I guess I'm not allowed to close it now. Sorry about that.
(0027624)
Alex Neundorf   
2011-10-22 14:31   
Yes, adding notes is only possible after reopening.
No problem.

Alex