[CMake] Problem with a macro
Leopold Palomo Avellaneda
leo at alaxarxa.net
Wed Sep 24 11:31:20 EDT 2008
Hi,
I'm trying to develop a macro to create gmo files (binarys from .po) for a
project that uses gettext. This macro gets some parameters,
The idea is that you have program: foo
a template with the strings: foo.pot (the potfile)
several languages to translate: ca en es de (the langs var)
and a place to put the translations: INSTALLDIR
to have a mo file, for each language to must:
msgmerge foo_LANG.po foo.pot
msgfmt foo_LANG.po -o foo_LANG.gmo
the last command generates the output.
The macro, creates a custom target: foo_pos
with all the needed files.
This target is a dependency of another target (translations) because I can
have several groups (domains) in my project, and with make translations I
would like to create all.
My problem is that is doesn't work, doesn't do the job and I don't know what's
is happening.
Please, could some one look on it? I need that two different eyes look this.
Regards,
Leo
# GETTEXT_CREATE_TRANSLATIONS potFile INSTALLDIR langs)
#
# potFile with a potfile
#
# INSTALLDIR where to install the translations
# in this way ${INSTALLDIR}/${_lang} RENAME ${_potBasename}.mo)
# if is empty install it on:
# share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
#
# langs a list of languages to process
# it checks for
# ${CMAKE_CURRENT_SOURCE_DIR}/${_potBasename}_${_lang})
# if the file potFile_lang doesn't exist create it in
#
macro(GETTEXT_CREATE_TRANSLATIONS potFile INSTALLDIR langs)
set(_gmoFiles)
get_filename_component(_potBasename ${potFile} NAME_WE)
get_filename_component(_absPotFile ${potFile} ABSOLUTE)
foreach(_lang ${${langs}})
set(_absPoFile ${CMAKE_CURRENT_SOURCE_DIR}/${_potBasename}_${_lang}.po)
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_potBasename}_${_lang}.gmo)
get_filename_component(_gmoBasename ${_gmoFile} NAME)
if(NOT EXISTS ${_absPoFile})
file(WRITE ${_absPoFile} "")
endif(NOT EXISTS ${_absPoFile})
add_custom_command(
OUTPUT ${_potBasename}_${_lang}.gmo
COMMAND
${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s
${_absPoFile} ${_absPotFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absPoFile}
DEPENDS ${_absPotFile} ${_absPoFile}
)
if(INSTALLDIR)
install (FILES ${_gmoFile} DESTINATION ${INSTALLDIR}/${_lang}/ RENAME
${_potBasename}.mo)
else(INSTALLDIR)
install (FILES ${_gmoFile} DESTINATION
share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
endif(INSTALLDIR)
list (APPEND _gmoFiles ${_gmoFile})
endforeach (_lang ${${langs}})
add_custom_target( ${_potBasename}_pos DEPENDS ${_gmoFiles})
add_dependencies(translations ${_gmoFile})
endmacro(GETTEXT_CREATE_TRANSLATIONS )
--
--
Linux User 152692
PGP: 0xF944807E
Catalonia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080924/060f6ae0/attachment.pgp>
More information about the CMake
mailing list