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)

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