이 페이지에서

qt_collect_translation_source_targets

번역 대상에 해당하는 항목을 수집합니다.

이 명령어는 Qt6 패키지의 LinguistTools 구성 요소에 정의되어 있습니다. 다음 명령어로 패키지를 불러오십시오:

find_package(Qt6 REQUIRED COMPONENTS LinguistTools)

이 명령어는 Qt 6.7에서 도입되었습니다.

개요

qt_collect_translation_source_targets(out_var [DIRECTORY path])

버전 정보가 없는 명령어가 비활성화된 경우, 대신 ` qt6_collect_translation_source_targets() `을 사용하십시오. 이 명령어와 동일한 인자 세트를 지원합니다.

설명

지정된 ` DIRECTORY ` 및 모든 하위 디렉터리에서 번역 대상인 타깃을 수집합니다. ` DIRECTORY `이 지정되지 않은 경우, ` CMAKE_CURRENT_SOURCE_DIR`에서 타깃 수집을 시작합니다.

이 명령어는 첫 번째 인수로 지정된 변수에 대상 목록을 저장합니다.

번역 대상에서 타겟 제외

기본적으로, 임포트되지 않은 모든 실행 파일 및 라이브러리 타깃은 번역 대상입니다.

타깃 속성 QT_EXCLUDE_FROM_TRANSLATION을 설정하여 개별 타깃을 제외할 수 있습니다.

디렉터리 속성 QT_EXCLUDE_FROM_TRANSLATION을 설정하여 특정 디렉터리 아래의 타깃을 제외할 수 있습니다.

이 명령을 호출하는 경우

qt_collect_translation_source_targets 명령어는 BUILDSYSTEM_TARGETS 디렉터리 속성을 읽습니다. 그 결과, 이미 생성된 타깃만 수집합니다. qt_collect_translation_source_targets 가 호출된 후에 생성된 타깃은 수집되지 않습니다.

빌드 시스템의 모든 타깃을 수집하려면 최상위 CMakeLists.txt 의 마지막에서 qt_collect_translation_source_targets 를 호출하거나, 최상위 디렉터리 범위 끝에서 cmake_language(DEFER CALL) 를 사용하여 i18n을 설정하십시오.

예시

qt_collect_translation_source_targets 의 결과를 qt_add_lupdate 의 입력으로 사용합니다.

add_subdirectory(src)         # The actual application is defined here.

# All targets that have been defined up to this point will be in i18n_targets.
qt_collect_translation_source_targets(i18n_targets)
qt_add_lupdate(SOURCE_TARGETS ${i18n_targets})

# No targets from this directory are in i18n_targets.
add_subdirectory(tests)       # Unit tests - we don't want to translate those.

CMake 3.19 이상에서는 디렉터리 범위 끝에서 소스 타깃을 수집할 수 있습니다. 이렇게 하면 모든 타깃이 정의되기 전에 qt_collect_translation_source_targets 를 호출할 수 있습니다. 단, 디렉터리 속성 QT_EXCLUDE_FROM_TRANSLATION을 ON 로 설정하여 테스트를 제외해야 합니다.

function(set_up_translations)
    qt_collect_translation_source_targets(i18n_targets)
    qt_add_lupdate(SOURCE_TARGETS ${i18n_targets})
endfunction()

cmake_language(DEFER CALL set_up_translations)

add_subdirectory(src)         # The actual application is defined here.
add_subdirectory(tests)       # Unit tests - we don't want to translate those.
set_property(DIRECTORY tests PROPERTY QT_EXCLUDE_FROM_TRANSLATION ON)

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