W3cubDocs

/Qt 5.15

qt5_generate_moc

Synopsis

qt5_generate_moc(src_file dest_file
                 [TARGET target])

Description

Creates a rule to call the Meta-Object Compiler (moc) on src_file and store the output in dest_file.

Note: This is a low-level macro. See the CMake AUTOMOC Documentation for a more convenient way to let source files be processed with moc. qt5_wrap_cpp is also similar, but automatically generates a temporary file path for you.

Note: For compatibility with Qt 6, the command is also available under the name qt_generate_moc.

Arguments

You can set an explicit TARGET. This will make sure that the target properties INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS are also used when scanning the source files with moc.

Examples

qt5_generate_moc(main.cpp main.moc TARGET myapp)

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/qtcore-cmake-qt5-generate-moc.html