qt_generate_moc

調用輸入文件中的 MOC (元對象編譯器)。

命令的定義在 Core 組件對於 Qt6 包,可以像這樣加載:

find_package(Qt6 REQUIRED COMPONENTS Core)
					

該命令在 Qt 5.0 引入。

概要

qt_generate_moc(src_file dest_file
                [TARGET target])
					

無版本命令 被禁用,使用 qt6_generate_moc() 代替。它支持如此命令的一組相同自變量。

描述

創建規則以調用 MOC (元對象編譯器) on src_file 並將輸齣存儲在 dest_file .

注意: 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_wrap_cpp is also similar, but automatically generates a temporary file path for you.

自變量

可以明確設置 TARGET . This will make sure that the target properties INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS are also used when scanning the source files with moc .

範例

qt_generate_moc(main.cpp main.moc TARGET myapp)