qt_generate_moc
Llama a moc sobre un archivo de entrada.
El comando está definido en el componente « Core » del paquete « Qt6 », que se puede cargar de la siguiente manera:
find_package(Qt6 REQUIRED COMPONENTS Core)Este comando se introdujo en Qt 5.0.
Sinopsis
qt_generate_moc(src_file dest_file
[TARGET target])Si los comandos sin versión están desactivados, utiliza en su lugar qt6_generate_moc(). Admite el mismo conjunto de argumentos que este comando.
Descripción
Crea una regla para llamar a Meta-Object Compiler (moc) sobre src_file y almacenar el resultado en dest_file.
Nota: Se trata de una macro de bajo nivel. Consulte la documentación de CMake sobre AUTOMOC para conocer una forma más cómoda de procesar los archivos fuente con moc. qt_wrap_cpp() es similar, pero genera automáticamente una ruta de archivo temporal.
Argumentos
Puedes establecer un ` TARGET` explícito. Esto garantizará que las propiedades del objetivo ` INCLUDE_DIRECTORIES ` y ` COMPILE_DEFINITIONS ` también se utilicen al escanear los archivos fuente con ` moc`.
Ejemplos
qt_generate_moc(main.cpp main.moc TARGET myapp)© 2026 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.