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 ${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} --no-location --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
42 COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
43 DEPENDS ${_absPotFile} ${_absFile}
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})
50 ENDFOREACH (_currentPoFile )
52 ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
54 ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
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)
61 MESSAGE(FATAL_ERROR "GetText not found")
62 ENDIF (GetText_REQUIRED)
63 ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )