임포트된 타깃

로드되는 각 Qt 모듈은 CMake 라이브러리 타겟을 정의합니다. 대상 이름은 Qt6:: 로 시작하고 그 뒤에 모듈 이름이 옵니다. 예를 들어 Qt6::Core, Qt6::Gui. 해당 라이브러리를 사용하려면 target_link_libraries 에 라이브러리 타겟 이름을 전달합니다.

참고: 타깃은 Qt:: 접두사로도 사용할 수 있습니다: Qt::Core, Qt::Gui 등. Qt 5 및 Qt 6 호환성을 참조하세요.

가져온 대상은 Qt를 구성할 때와 동일한 구성으로 생성됩니다. 즉:

  • Qt가 -debug 스위치를 사용하여 구성된 경우 DEBUG 구성으로 임포트된 타겟이 생성됩니다.
  • Qt가 -release 스위치로 구성되었다면 RELEASE 구성으로 임포트된 타겟이 생성됩니다.
  • Qt가 -debug-and-release 스위치로 구성된 경우, 임포트된 타겟은 RELEASE 및 DEBUG 구성 모두로 생성됩니다.

프로젝트에 사용자 지정 CMake 빌드 구성이 있는 경우, 사용자 지정 구성을 디버그 또는 릴리스 Qt 구성에 매핑해야 합니다.

find_package(Qt6 REQUIRED COMPONENTS Core)

set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")

# set up a mapping so that the Release configuration for the Qt imported target is
# used in the COVERAGE CMake configuration.
set_target_properties(Qt6::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")

© 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.