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 _firstPoFileArg)
22 # make it a real variable, so we can modify it here
23 SET(_firstPoFile "${_firstPoFileArg}")
26 GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
27 GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
30 IF(${_firstPoFile} STREQUAL "ALL")
33 ENDIF(${_firstPoFile} STREQUAL "ALL")
35 FOREACH (_currentPoFile ${_firstPoFile} ${ARGN})
36 GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE)
37 GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH)
38 GET_FILENAME_COMPONENT(_lang ${_absFile} NAME_WE)
39 SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
43 COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
44 COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
45 DEPENDS ${_absPotFile} ${_absFile}
48 INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
49 SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
51 ENDFOREACH (_currentPoFile )
53 ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
55 ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
57 IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
58 SET(GETTEXT_FOUND TRUE)
59 ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
60 SET(GETTEXT_FOUND FALSE)
62 MESSAGE(FATAL_ERROR "GetText not found")
63 ENDIF (GetText_REQUIRED)
64 ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )