1 # - Slightly modified 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.
15 FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
17 FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
19 MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFile)
22 GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
23 GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
26 IF(${_firstPoFile} STREQUAL "ALL")
29 ENDIF(${_firstPoFile} STREQUAL "ALL")
31 FOREACH (_currentPoFile ${ARGN})
32 GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE)
33 GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH)
34 GET_FILENAME_COMPONENT(_lang ${_absFile} NAME_WE)
35 SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
39 COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
40 COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
41 DEPENDS ${_absPotFile} ${_absFile}
44 INSTALL(FILES ${_gmoFile} DESTINATION ${LYX_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
45 SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
47 ENDFOREACH (_currentPoFile )
49 ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
51 ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
53 IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
54 SET(GETTEXT_FOUND TRUE)
55 ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
56 SET(GETTEXT_FOUND FALSE)
58 MESSAGE(FATAL_ERROR "GetText not found")
59 ENDIF (GetText_REQUIRED)
60 ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )