이 페이지에서

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 을 명시적으로 설정할 수 있습니다. 이렇게 하면 moc 로 소스 파일을 스캔할 때 대상 속성 INCLUDE_DIRECTORIES 와 COMPILE_DEFINITIONS 도 함께 사용됩니다.

예시

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.