1 ###############################################################################
3 ##############################################################################
4 MESSAGE ( STATUS "<Locating Gettext>" )
5 FIND_PACKAGE ( Gettext REQUIRED )
6 INCLUDE_DIRECTORIES ( ${GETTEXT_INCLUDE_DIR} )
7 SET ( DOMAIN "tuxanci" )
8 ###############################################################################
9 # CREATE .MO FOR EACH .PO
10 ###############################################################################
11 # How are languages installed:
12 # Check if there is env variable LINGUAS
13 # if it is unset, install all languages
14 # if it is empty, dont install any language
15 # if it is set to some value, install those
16 # cmake cant differ between empty and unset enviroment variable, so installing
17 # all linguas when linguas is emtpy
18 ###############################################################################
19 SET ( lingua "$ENV{LINGUAS}" )
20 string(REGEX REPLACE "[ \t]+" \; output "${lingua}")
21 SET ( lingua_list ${output} )
22 IF ( "${lingua}" STREQUAL "" )
24 FILE ( GLOB _po_files *.po )
25 ELSE ( "${lingua}" STREQUAL "" )
26 # only specified languages
29 FOREACH ( _lang ${lingua_list} )
30 FILE ( GLOB _po_file ${_lang}*.po )
31 LIST ( APPEND _po_files ${_po_file} )
33 ENDIF ( "${lingua}" STREQUAL "" )
35 SET ( STORE_DIR "${CMAKE_BINARY_DIR}/po" )
36 FOREACH ( _current_PO_FILE ${_po_files} )
37 IF ( EXISTS ${_current_PO_FILE} )
38 GET_FILENAME_COMPONENT ( _lang ${_current_PO_FILE} NAME_WE )
39 SET ( _gmoFile "${_lang}.mo" )
40 ADD_CUSTOM_COMMAND ( OUTPUT ${_gmoFile}
41 COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
42 WORKING_DIRECTORY "${STORE_DIR}"
43 DEPENDS ${_current_PO_FILE}
45 INSTALL ( FILES "${STORE_DIR}/${_gmoFile}"
46 DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${_lang}/LC_MESSAGES/" RENAME ${DOMAIN}.mo )
47 LIST ( APPEND _gmoFiles "${STORE_DIR}/${_gmoFile}" )
48 ENDIF ( EXISTS ${_current_PO_FILE} )
49 ENDFOREACH ( _current_PO_FILE )
50 ADD_CUSTOM_TARGET ( pofiles ALL DEPENDS ${_gmoFiles} )
51 ###############################################################################