View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007102CMakeCMakepublic2008-05-27 04:432008-06-10 17:52
ReporterAndrey Rahmatullin 
Assigned ToAlex Neundorf 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0007102: QT4_GENERATE_MOC doesn't generate any rules
DescriptionTest 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.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0012304)
Alex Neundorf (developer)
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

 Issue History
Date Modified Username Field Change
2008-05-27 04:43 Andrey Rahmatullin New Issue
2008-05-27 09:00 Bill Hoffman Status new => assigned
2008-05-27 09:00 Bill Hoffman Assigned To => Alex Neundorf
2008-06-10 17:52 Alex Neundorf Note Added: 0012304
2008-06-10 17:52 Alex Neundorf Status assigned => closed
2008-06-10 17:52 Alex Neundorf Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team