]> git.sesse.net Git - kdenlive/blob - cmake/modules/FindGettext.cmake
Fix crash with copied clips
[kdenlive] / cmake / modules / FindGettext.cmake
1 # - Find GNU gettext tools
2 # This module looks for the GNU gettext tools. This module defines the
3 # following values:
4 #  GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
5 #  GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
6 #  GETTEXT_FOUND: True if gettext has been found.
7 #
8 # Additionally it provides the following macros:
9 # GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
10 #    This will create a target "translations" which will convert the
11 #    given input po files into the binary output mo file. If the
12 #    ALL option is used, the translations will also be created when
13 #    building the default target.
14
15
16
17 FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
18
19 FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
20
21 MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFile)
22
23    SET(_gmoFiles)
24    GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
25    GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
26
27    SET(_addToAll)
28    IF(${_firstPoFile} STREQUAL "ALL")
29       SET(_addToAll "ALL")
30       SET(_firstPoFile)
31    ENDIF(${_firstPoFile} STREQUAL "ALL")
32
33    FOREACH (_currentPoFile ${ARGN})
34       GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE)
35       GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH)
36       GET_FILENAME_COMPONENT(_lang ${_absFile} NAME_WE)
37       SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
38
39       ADD_CUSTOM_COMMAND(
40          OUTPUT ${_gmoFile}
41          COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --no-location --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
42          COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
43          DEPENDS ${_absPotFile} ${_absFile}
44       )
45
46       # (THE, 2007-05-22, install into KDE3_LOCALEDIR instead of usr/share)
47       INSTALL(FILES ${_gmoFile} DESTINATION ${KDE3_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
48       SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
49
50    ENDFOREACH (_currentPoFile )
51
52    ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
53
54 ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
55
56 IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
57    SET(GETTEXT_FOUND TRUE)
58 ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
59    SET(GETTEXT_FOUND FALSE)
60    IF (GetText_REQUIRED)
61       MESSAGE(FATAL_ERROR "GetText not found")
62    ENDIF (GetText_REQUIRED)
63 ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
64
65
66