qt_wrap_cpp
Synopsis
qt_wrap_cpp(<VAR> src_file1 [src_file2 ...] [TARGET target] [OPTIONS ...] [DEPENDS ...]) qt6_wrap_cpp(<VAR> src_file1 [src_file2 ...] [TARGET target] [OPTIONS ...] [DEPENDS ...])
Description
Creates rules for calling the Meta-Object Compiler (moc) on the given source files. For each input file, an output file is generated in the build directory. The paths of the generated files are added to <VAR>
.
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
.
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
.
You can set additional OPTIONS
that should be added to the moc
calls. You can find possible options in the moc documentation.
DEPENDS
allows you to add additional dependencies for recreation of the generated files. This is useful when the sources have implicit dependencies, like code for a Qt plugin that includes a .json
file using the Q_PLUGIN_METADATA() macro.
Examples
set(SOURCES myapp.cpp main.cpp) qt_wrap_cpp(SOURCES myapp.h) add_executable(myapp ${SOURCES})
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.