File: CreateTranslations.cmake

package info (click to toggle)
veyon 4.7.5%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,912 kB
  • sloc: cpp: 47,553; ansic: 7,236; makefile: 230; python: 219; sh: 47
file content (37 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# CreateTranslations.cmake - Copyright (c) 2020-2022 Tobias Junghans
#
# description: create Qt translation files
# usage: create_translations(<TS FILES> <SOURCE FILES>)

function(create_translations name ts_files source_files)

	if(NOT WITH_TRANSLATIONS)
		add_custom_target("${name}-translations")
		return()
	endif()

	set(qm_targets "")
	foreach(ts_file ${ts_files})
		string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" ts_filename "${ts_file}")
		string(REPLACE ".ts" "" basename "${ts_filename}")
		set(ts_target "${basename}_ts")
		set(qm_target "${basename}_qm")
		set(qm_file "${CMAKE_CURRENT_BINARY_DIR}/${basename}.qm")
		add_custom_command(OUTPUT ${ts_file}
			COMMAND Qt${QT_MAJOR_VERSION}::lupdate -locations none -no-obsolete ${source_files} -ts ${ts_file}
			DEPENDS ${source_files})
		add_custom_target(${ts_target} DEPENDS ${ts_file})
		# add command and target for generating/updating QM file if TS file is newer or no QM file exists yet
		add_custom_command(OUTPUT ${qm_file}
			COMMAND Qt${QT_MAJOR_VERSION}::lrelease ${ts_file} -qm ${qm_file}
			DEPENDS ${ts_file})
		add_custom_target(${qm_target} DEPENDS ${qm_file})

		list(APPEND qm_targets "${qm_target}")

		install(FILES ${qm_file} DESTINATION ${VEYON_INSTALL_DATA_DIR}/translations)
	endforeach()

	add_custom_target("${name}-translations" ALL DEPENDS "${qm_targets}")

endfunction()