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
.
注意: 為兼容 Qt 6,命令還可用於名稱 qt_wrap_cpp .
可以明確設置
TARGET
. This will make sure that the target properties
INCLUDE_DIRECTORIES
and
COMPILE_DEFINITIONS
are also used when scanning the source files with
moc
.
可以設置額外
選項
應該被添加到
moc
調用。可以查找可能的選項在
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
文件使用
Q_PLUGIN_METADATA
() 宏。
set(SOURCES myapp.cpp main.cpp)
qt5_wrap_cpp(SOURCES myapp.h)
add_executable(myapp ${SOURCES})