epubgrep/translations/CMakeLists.txt

38 lines
1.2 KiB
CMake

set(potfile "${PROJECT_SOURCE_DIR}/translations/${PROJECT_NAME}.pot")
file(GLOB po_src_files "../src/*pp")
file(GLOB po_src_files_relative RELATIVE "${PROJECT_SOURCE_DIR}" "../src/*pp")
add_custom_command(OUTPUT ${potfile}
COMMAND "${XGETTEXT_CMD}"
"--language=C++"
"--keyword=translate:1,1t"
"--keyword=translate:1c,2,2t"
"--keyword=translate:1,2,3t"
"--keyword=translate:1c,2,3,4t"
"--package-name=${PROJECT_NAME}"
"--package-version=${PROJECT_VERSION}"
"--from-code=utf-8"
"--foreign-user"
"--output=${potfile}"
${po_src_files_relative}
DEPENDS "${po_src_files}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
COMMENT "Extract translatable messages to ${potfile}")
add_custom_target(${PROJECT_NAME}_pot
ALL DEPENDS ${potfile})
unset(po_src_files)
unset(po_src_files_relative)
file(GLOB po_files "*.po")
# Hack to prevent GETTEXT_CREATE_TRANSLATIONS from updating the .po files.
set(backup_GETTEXT_MSGMERGE_EXECUTABLE ${GETTEXT_MSGMERGE_EXECUTABLE})
set(GETTEXT_MSGMERGE_EXECUTABLE "echo")
# Creates install target automatically.
GETTEXT_CREATE_TRANSLATIONS(${potfile} ALL ${po_files})
set(GETTEXT_MSGMERGE_EXECUTABLE ${backup_GETTEXT_MSGMERGE_EXECUTABLE})
unset(po_files)
unset(potfile)