aboutsummaryrefslogtreecommitdiff
path: root/cmake/UseGettext.cmake
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-04-07 11:09:47 +0200
committerfiaxh <git@mx.ax.lt>2017-04-10 15:47:21 +0200
commit9bc83539d124f9645dc92e9e39001cb0192dae61 (patch)
treea4b22a8ea3e10b6d0050c2e5669729919a1cb477 /cmake/UseGettext.cmake
parentd8881c4b16a1cd376dd69304c44444aee581da32 (diff)
downloaddino-9bc83539d124f9645dc92e9e39001cb0192dae61.tar.gz
dino-9bc83539d124f9645dc92e9e39001cb0192dae61.zip
Gettext support
Diffstat (limited to 'cmake/UseGettext.cmake')
-rw-r--r--cmake/UseGettext.cmake28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmake/UseGettext.cmake b/cmake/UseGettext.cmake
new file mode 100644
index 00000000..3abf418e
--- /dev/null
+++ b/cmake/UseGettext.cmake
@@ -0,0 +1,28 @@
+function(_gettext_mkdir_for_file file)
+ get_filename_component(dir "${file}" DIRECTORY)
+ file(MAKE_DIRECTORY "${dir}")
+endfunction()
+
+function(gettext_compile project_name)
+ cmake_parse_arguments(ARGS "" "MO_FILES_NAME;TARGET_NAME;SOURCE_DIR;PROJECT_NAME" "" ${ARGN})
+
+ if(NOT ARGS_SOURCE_DIR)
+ set(ARGS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ endif(NOT ARGS_SOURCE_DIR)
+ file(STRINGS "${ARGS_SOURCE_DIR}/LINGUAS" LINGUAS)
+ set(target_files)
+ foreach(lang ${LINGUAS})
+ set(source_file ${ARGS_SOURCE_DIR}/${lang}.po)
+ set(target_file ${CMAKE_BINARY_DIR}/locale/${lang}/LC_MESSAGES/${project_name}.mo)
+ _gettext_mkdir_for_file(${target_file})
+ list(APPEND target_files ${target_file})
+ add_custom_command(OUTPUT ${target_file} COMMAND ${MSGFMT_EXECUTABLE} -o ${target_file} ${source_file} DEPENDS ${source_file})
+ install(FILES ${target_file} DESTINATION ${LOCALE_INSTALL_DIR}/${lang}/LC_MESSAGES)
+ endforeach(lang)
+ if(ARGS_MO_FILES_NAME)
+ set(${ARGS_MO_FILES_NAME} ${target_files} PARENT_SCOPE)
+ endif(ARGS_MO_FILES_NAME)
+ if(ARGS_TARGET_NAME)
+ add_custom_target(${ARGS_TARGET_NAME} DEPENDS ${target_files})
+ endif(ARGS_TARGET_NAME)
+endfunction(gettext_compile) \ No newline at end of file