MantisBT - CMake
View Issue Details
0007102CMakeCMakepublic2008-05-27 04:432008-06-10 17:52
Andrey Rahmatullin 
Alex Neundorf 
normalminoralways
closedno change required 
CMake-2-6 
 
0007102: QT4_GENERATE_MOC doesn't generate any rules
Test project:

foo.cpp:
#include <QObject>
#include "foo.moc"

class Foo: public QObject
{
        Q_OBJECT
};

CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
                     ${QT_INCLUDES} )
QT4_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/foo.cpp foo.moc)
ADD_EXECUTABLE( foo foo.cpp )
TARGET_LINK_LIBRARIES( foo ${QT_LIBRARIES} )

Make complains about foo.moc not found. That's correct, foo.moc generating rule wasn't added.
No tags attached.
Issue History
2008-05-27 04:43Andrey RahmatullinNew Issue
2008-05-27 09:00Bill HoffmanStatusnew => assigned
2008-05-27 09:00Bill HoffmanAssigned To => Alex Neundorf
2008-06-10 17:52Alex NeundorfNote Added: 0012304
2008-06-10 17:52Alex NeundorfStatusassigned => closed
2008-06-10 17:52Alex NeundorfResolutionopen => no change required

Notes
(0012304)
Alex Neundorf   
2008-06-10 17:52   
The rule is not generated because the generated foo.moc is not used anywhere (from the cmake POV).
Add foo.moc to the list of source files (and use the full path):

SET(FOO_MOC_FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.moc")
....

ADD_EXECUTABLE( foo foo.cpp ${FOO_MOC_FILE})

This should make it work.
If it doesn't, please reopen the bug report.

Alex