开发者

cmake doesn't generate Qt moc files using QT4_automoc

I'm trying to compile a little test application basic layout example in Qt using the Visual Studio 2010 compiler on Windows 7.

I'm using cmake (2.8.4) and nmake to build the example, but it fails to generate moc files. This leads to a compilation error:

Cannot open include file: 'dialog.moc': No such file or directory.

The rules in my CMakeLists.txt which should enable generation of the moc files are:

set(all_SOURCES main开发者_开发问答.cpp dialog.cpp)
QT4_AUTOMOC(${all_SOURCES})

Any ideas why no moc files are generated or tips to solve this issue?

Thanks!


Collect all the headers you need a moc of pass those headers to qt4_wrap_cpp and than add out those files to your library/executable.

FIND_PACKAGE(Qt4 REQUIRED)
include(${QT_USE_FILE})
set (FOO_MOC_HEADERS foo.h)
qt4_wrap_cpp (FOO_MOC_OUTFILES ${FOO_MOC_HEADERS})
add_library (foo SHARED ${FOO_SOURCE_FILES} ${FOO_MOC_OUTFILES})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜