qt_generate_moc
入力ファイルに対してmocを呼び出す。
このコマンドはQt6
パッケージのCore
コンポーネントで定義されています:
find_package(Qt6 REQUIRED COMPONENTS Core)
このコマンドはQt 5.0で導入されました。
概要
qt_generate_moc(src_file dest_file [TARGET target])
バージョンレスコマンドが無効になっている場合は、代わりにqt6_generate_moc()
を使用してください。このコマンドと同じ引数セットをサポートしています。
説明
src_file
でMeta-Object Compiler (moc)を呼び出し、その出力をdest_file
に格納するルールを作成します。
注意: これは低レベルのマクロです。ソースファイルをmoc
で処理させるより便利な方法については、CMake AUTOMOC ドキュメントを参照してください。qt_wrap_cppも似ていますが、自動的にテンポラリファイルのパスを生成します。
引数
明示的にTARGET
を設定することができます。これにより、INCLUDE_DIRECTORIES
とCOMPILE_DEFINITIONS
のターゲット・プロパティが、moc
でソース・ファイルをスキャンする際にも使用されるようになります。
例
qt_generate_moc(main.cpp main.moc TARGET myapp)
© 2025 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.