MantisBT - CMake
View Issue Details
0005230CMakeModulespublic2007-06-24 06:542016-06-10 14:30
Isaac Clerencia 
Clinton Stimpson 
normalminoralways
closedmoved 
 
 
0005230: qt4_automoc generates .moc files in CMAKE_CURRENT_BINARY_DIR
I'm not sure if this is "by-design" but it's causing me problems.

I have a src/ dir with two class hierarchies in two subdirs src/event/ and src/action/ . Both event/ and action/ have a base.cc which must be moc'ed.

When running qt4_automoc over event/base.cc and action/base.cc both base.moc files are created in src/ which causes a name clash. I've modified the FindQt4.cmake file to generate the moc files inside the directories (just like the .o files are generated) and everything works ok now.

Any reason to not change that? In that case, any other workaround?
No tags attached.
Issue History
2007-08-23 14:02Alex NeundorfCategoryCMake => Modules
2008-10-13 19:21Alex NeundorfNote Added: 0013870
2008-10-13 19:21Alex NeundorfAssigned ToAlex Neundorf => Clinton Stimpson
2008-10-14 17:24Clinton StimpsonNote Added: 0013879
2012-08-13 23:25Clinton StimpsonStatusassigned => backlog
2016-06-10 14:27Kitware RobotNote Added: 0041373
2016-06-10 14:27Kitware RobotStatusbacklog => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0007949)
Isaac Clerencia   
2007-06-27 12:55   
My "fix" has been to change the inner loop in qt4_automoc to: GET_filename_component(_basename ${_current_MOC} NAME_WE)
SET(_header ${_abs_PATH}/${_basename}.h)
SET(_moc ${_abs_PATH}/${_basename}.moc)
ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
    COMMAND ${QT_MOC_EXECUTABLE}
    ARGS ${_moc_INCS} ${_header} -o ${_moc}
    DEPENDS ${_header}
)
(0008038)
Alex Neundorf   
2007-07-12 10:04   
With your change the moc files are generated in the source directory. This breaks out-of-source builds (you can have multiple out-of-source builds for one source tree).

You can exclude one of the two files from automoc by generating the moc file for it explicitely:

qt4_generate_moc(event/base.h ${CMAKE_CURRENT_BINARY_DIR}/moc_event_base.cpp)

and add this moc_event_base.cpp to the sources of your target.

Alex


(0008072)
Isaac Clerencia   
2007-07-15 10:20   
Ok, I'll use that.

Anyway, if I have sources in dir/ and more sources in dir/subdir/, and I add an executable in dir like:
add_executable(foo foo.c subdir/bar.c)
in the builddir I get a "CMakefiles/foo.dir/" which includes a "subdir/" directory where the bar.o object ends up.

Wouldn't make sense for qt4_automoc to behave the same way and use a subdir in the build directory?

Best regards
(0013870)
Alex Neundorf   
2008-10-13 19:21   
Assigning this to Clinton, since he is maintaining FindQt4.cmake

Alex
(0013879)
Clinton Stimpson   
2008-10-14 17:24   
Can you please post an example that demonstrates the problem?
(0041373)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.