1 # - Find GNU gettext tools
2 # This module looks for the GNU gettext tools. This module defines the
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.
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.
17 FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
19 FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
21 MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFile)
24 GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
25 GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
28 IF(${_firstPoFile} STREQUAL "ALL")
31 ENDIF(${_firstPoFile} STREQUAL "ALL")
33 FOREACH (_currentPoFile ${_firstPoFile} ${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)
41 COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
42 COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
43 DEPENDS ${_absPotFile} ${_absFile}
46 INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
47 SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
49 ENDFOREACH (_currentPoFile )
51 ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
53 ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
55 IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
56 SET(GETTEXT_FOUND TRUE)
57 ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
58 SET(GETTEXT_FOUND FALSE)
60 MESSAGE(FATAL_ERROR "GetText not found")
61 ENDIF (GetText_REQUIRED)
62 ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )