qt5_wrap_cpp

概要

qt5_wrap_cpp(<VAR> src_file1 [src_file2 ...]
             [TARGET target]
             [OPTIONS ...]
             [DEPENDS ...])
					

描述

Creates rules for calling the 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> .

注意: This is a low-level macro. See the CMake AUTOMOC Documentation for a more convenient way to let source files be processed with moc .

注意: For compatibility with Qt 6, the command is also available under the name qt_wrap_cpp .

自变量

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 .

可以设置额外 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 () 宏。

范例

set(SOURCES myapp.cpp main.cpp)
qt5_wrap_cpp(SOURCES myapp.h)
add_executable(myapp ${SOURCES})