-
Notifications
You must be signed in to change notification settings - Fork 460
/
SlicerMacroTranslation.cmake
119 lines (101 loc) · 4.31 KB
/
SlicerMacroTranslation.cmake
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
################################################################################
#
# Program: 3D Slicer
#
# Copyright (c) 2010 Kitware Inc.
#
# See COPYRIGHT.txt
# or http://www.slicer.org/copyright/copyright.txt for details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
# and was partially funded by NIH grant 3P41RR013218-12S1
#
################################################################################
#SLicerMacroTranslation
#Parameters :
#
# SRCS ..................: All sources witch need to be translated
#
# UI_SRCS ...............: All ui_sources witch need to be translated
#
# TS_DIR.................: Path to the TS files
#
# TS_BASEFILENAME........: Name of the librairi
#
# TS_LANGUAGES...........: Variable with all the languages
#
# QM_OUTPUT_DIR_VAR .....: Translation's dirs generated by the macro
#
# QM_OUTPUT_FILES_VAR....: Translation's files generated by the macro
#
macro(SlicerMacroTranslation)
set(options)
set(oneValueArgs QM_OUTPUT_DIR_VAR TS_DIR TS_BASEFILENAME)
set(multiValueArgs SRCS UI_SRCS TS_LANGUAGES QM_OUTPUT_FILES_VAR)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# ---------------------------------------------------------------------------------
# Sanity Checks
# ---------------------------------------------------------------------------------
#set(expected_nonempty_vars SRCS UI_SRCS TS_INPUT)
#add TS_LANGUAGES also
set(expected_nonempty_vars SRCS TS_DIR TS_BASEFILENAME )
foreach(var ${expected_nonempty_vars})
if("${MY_${var}}" STREQUAL "")
message(FATAL_ERROR "error : ${var} Cmake varianle is empty !")
endif()
endforeach()
# ---------------------------------------------------------------------------------
# Set File to translate
# ---------------------------------------------------------------------------------
set(FILES_TO_TRANSLATE
${MY_SRCS}
${MY_UI_SRCS}
)
# ---------------------------------------------------------------------------------
# Set TS_FILES
# ---------------------------------------------------------------------------------
foreach(language ${MY_TS_LANGUAGES})
set(TS_FILES
${TS_FILES}
"${MY_TS_DIR}${MY_TS_BASEFILENAME}_${language}.ts"
)
endforeach()
# ---------------------------------------------------------------------------------
# UPDATE or ADD translation
# ---------------------------------------------------------------------------------
if(Slicer_UPDATE_TRANSLATION)
QT4_CREATE_TRANSLATION(QM_OUTPUT_FILES ${FILES_TO_TRANSLATE} ${TS_FILES})
else()
QT4_ADD_TRANSLATION(QM_OUTPUT_FILES ${TS_FILES})
endif()
# ---------------------------------------------------------------------------------
# Set the variable MY_QM_OUTPUT_DIR_VAR
# ---------------------------------------------------------------------------------
# Extract the path associated with the first file of the list QM_OUTPUT_FILES
# -> QM_OUTPUT_DIR
list(GET QM_OUTPUT_FILES 0 QM_OUTPUT_FIRST_FILE)
get_filename_component(${MY_QM_OUTPUT_DIR_VAR} "${QM_OUTPUT_FIRST_FILE}" PATH)
# ---------------------------------------------------------------------------------
# Set the variable MY_QM_OUTPUT_FILES_VAR
# ---------------------------------------------------------------------------------
set(${MY_QM_OUTPUT_FILES_VAR} ${QM_OUTPUT_FILES})
# ---------------------------------------------------------------------------------
# Install language
# ---------------------------------------------------------------------------------
install(
FILES ${QM_OUTPUT_FILES}
DESTINATION ${Slicer_INSTALL_QM_DIR}
COMPONENT Runtime
)
# ---------------------------------------------------------------------------------
# ADD custom command and target
# ---------------------------------------------------------------------------------
#add_custom_command(OUTPUT ${TS_FILES} DEPENDS ${FILES_TO_TRANSLATE} APPEND)
#add_custom_target(TS_TRANSLATE DEPENDS ${MY_QM_FILES})
endmacro()