-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathTs.cmake
90 lines (84 loc) · 2.8 KB
/
Ts.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
# a small macro to create qm files out of ts's
MACRO(FIND_LRELEASE)
IF(NOT LRELEASE_EXECUTABLE AND NOT LRELEASE_NOT_FOUND)
SET(QT_EXE "$ENV{QTDIR}/bin")
MESSAGE(STATUS "Looking up lrelease (${QT_EXE})")
FIND_PROGRAM(LRELEASE_EXECUTABLE lrelease
PATHS ${QT_EXE}
/usr/lib/${QT_EXTENSION}/bin
/usr/bin
NO_DEFAULT_PATH
)
IF(LRELEASE_EXECUTABLE) # search again under the name lrelease-qt4
MESSAGE(STATUS "Found as (${LRELEASE_EXECUTABLE})")
ELSE()
FIND_PROGRAM(LRELEASE_EXECUTABLE lrelease-${QT_EXTENSION}
PATHS ${QT_EXE} /usr/bin/
NO_DEFAULT_PATH
)
IF(NOT LRELEASE_EXECUTABLE) # search again under the name lrelease-qt4
MESSAGE(FATAL_ERROR "lrelease executable not found - ts files can't be processed")
SET(LRELEASE_NOT_FOUND "1") # to avoid double checking in one cmake run
ENDIF() # search again under the name lrelease-qt4
ENDIF()
IF(LRELEASE_EXECUTABLE)
MESSAGE(STATUS "lrelease found as ${LRELEASE_EXECUTABLE}")
ENDIF()
ENDIF()
ENDMACRO()
#
#
#
MACRO(INSTALL_I18N)
IF(WIN32)
SET(i18dir "${CMAKE_INSTALL_PREFIX}/${BIN_DIR}/${QT_EXTENSION}/i18n")
ELSE()
SET(i18dir "${CMAKE_INSTALL_PREFIX}/share/avidemux6/${QT_EXTENSION}/i18n")
ENDIF()
INSTALL(FILES ${ARGN} DESTINATION "${i18dir}" COMPONENT runtime)
ENDMACRO()
#
#
FUNCTION(COMPILE_MASK_TS_FILES ts_subdir prefix mask_sources)
IF(LRELEASE_EXECUTABLE)
FILE(GLOB ts_files ${ts_subdir}/${prefix}_*.ts)
#MESSAGE(STATUS "While searching ${prefix} found ${ts_files}")
FOREACH(ts_input ${ts_files})
GET_FILENAME_COMPONENT(_in ${ts_input} ABSOLUTE)
GET_FILENAME_COMPONENT(_basename ${ts_input} NAME_WE)
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
GET_FILENAME_COMPONENT(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.qm ABSOLUTE)
ADD_CUSTOM_COMMAND(
OUTPUT ${_out}
COMMAND ${CMAKE_COMMAND}
-E echo
"Generating" ${_out} "from" ${_in}
COMMAND ${LRELEASE_EXECUTABLE}
${_in}
-qm ${_out}
DEPENDS ${_in}
)
SET(qm_files ${qm_files} ${_out})
ENDFOREACH()
INSTALL_I18N(${qm_files})
SET(${mask_sources} ${qm_files} PARENT_SCOPE)
ENDIF()
ENDFUNCTION()
#
#
#
FUNCTION(COMPILE_TS_FILES ts_subdir sources)
FIND_LRELEASE()
IF(QT5_FOUND OR QT6_FOUND)
SET(pfix "qtbase")
ELSE()
SET(pfix "qt")
ENDIF()
SET(adm_sources "")
COMPILE_MASK_TS_FILES(${ts_subdir} "avidemux" adm_sources)
#MESSAGE(STATUS "Result 1= ${adm_sources}")
SET(qt_sources "")
COMPILE_MASK_TS_FILES(${ts_subdir} "${pfix}" qt_sources)
#MESSAGE(STATUS "Result 2= ${qt_sources}")
SET(${sources} ${adm_sources} ${qt_sources} PARENT_SCOPE)
ENDFUNCTION()