Debian Codegraph @

tests/auto/cmake/linguist/test_i18n_source_language/CMakeLists.txt

raw
1 # Copyright (C) 2023 The Qt Company Ltd.
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 cmake_minimum_required(VERSION 3.16)
5 project(test_i18n_source_language)
6
7 # Set up the project structure.
8 find_package(Qt6 REQUIRED COMPONENTS Core Gui LinguistTools)
9 qt_standard_project_setup()
10 set(native_ts_files "")
11
12 function(my_add_library target)
13 add_library("${target}" STATIC lib.cpp)
14 target_link_libraries("${target}" PRIVATE Qt6::Core)
15 endfunction()
16
17 # qt_add_lupdate with just the native translation.
18 my_add_library(lib1 STATIC lib.cpp)
19 qt_add_lupdate(
20 SOURCE_TARGETS lib1
21 PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib1_en.ts"
22 )
23
24 # qt_add_lupdate with just the native translation which has already been translated.
25 # check_ts_files.cmake checks that the numerus translations are preserved.
26 my_add_library(lib2 STATIC lib.cpp)
27 configure_file(lib2_en.ts.in lib2_en.ts COPYONLY)
28 qt_add_lupdate(
29 SOURCE_TARGETS lib2
30 PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib2_en.ts"
31 )
32
33 # qt_add_lupdate with regular translations and the native translation.
34 my_add_library(lib3 STATIC lib.cpp)
35 qt_add_lupdate(
36 SOURCE_TARGETS lib3
37 TS_FILES "${CMAKE_CURRENT_BINARY_DIR}/lib3_hi.ts" "${CMAKE_CURRENT_BINARY_DIR}/lib3_ho.ts"
38 PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib3_en.ts"
39 )
40
41 # qt_add_translations with just the native translation.
42 my_add_library(lib4 STATIC lib.cpp)
43 qt_add_translations(
44 TARGETS lib4
45 SOURCE_TARGETS lib4
46 PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib4_en.ts"
47 )
48
49 # qt_add_translations with regular translations and the native translation.
50 my_add_library(lib5 STATIC lib.cpp)
51 qt_add_translations(
52 TARGETS lib5
53 SOURCE_TARGETS lib5
54 TS_FILES "${CMAKE_CURRENT_BINARY_DIR}/lib5_hi.ts" "${CMAKE_CURRENT_BINARY_DIR}/lib5_ho.ts"
55 PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib5_en.ts"
56 )
57
58 # Find out how many targets we created above.
59 get_directory_property(targets BUILDSYSTEM_TARGETS)
60 list(FILTER targets INCLUDE REGEX "^lib[0-9]+$")
61 list(LENGTH targets targets_length)
62
63 # Write the .ts file names to a file that's read by post_build_check.cmake.
64 set(ts_files "")
65 foreach(i RANGE 1 ${targets_length})
66 list(APPEND ts_files "lib${i}_en.ts")
67 endforeach()
68 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ts_files.txt" "${ts_files}")