Browse Source

Changing Gettext ABI automatically.

master
Kolan Sh 3 years ago
parent
commit
a0b6683360
2 changed files with 42 additions and 0 deletions
  1. 41
    0
      FindGettextOverride.cmake
  2. 1
    0
      GettextLangRules.cmake

+ 41
- 0
FindGettextOverride.cmake View File

@@ -0,0 +1,41 @@
1
+function(GETTEXT_PROCESS_PO_FILES _lang)
2
+   set(_options ALL)
3
+   set(_oneValueArgs INSTALL_DESTINATION)
4
+   set(_multiValueArgs PO_FILES)
5
+   set(_gmoFiles)
6
+
7
+   CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
8
+
9
+   foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
10
+      get_filename_component(_name ${_current_PO_FILE} NAME)
11
+      string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
12
+      set(_basenameMAJOR ${_basename}-${MAJOR})
13
+      set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basenameMAJOR}.gmo)
14
+      add_custom_command(OUTPUT ${_gmoFile}
15
+            COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
16
+            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
17
+            DEPENDS ${_current_PO_FILE}
18
+         )
19
+
20
+      if(_parsedArguments_INSTALL_DESTINATION)
21
+         install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basenameMAJOR}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basenameMAJOR}.mo)
22
+      endif()
23
+      list(APPEND _gmoFiles ${_gmoFile})
24
+   endforeach()
25
+
26
+
27
+  if(NOT TARGET pofiles)
28
+     add_custom_target(pofiles)
29
+  endif()
30
+
31
+  _GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName)
32
+
33
+   if(_parsedArguments_ALL)
34
+      add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
35
+   else()
36
+      add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
37
+   endif()
38
+
39
+   add_dependencies(pofiles ${uniqueTargetName})
40
+
41
+endfunction()

+ 1
- 0
GettextLangRules.cmake View File

@@ -1,3 +1,4 @@
1
+INCLUDE (FindGettextOverride)
1 2
 FILE (GLOB _po_files *.po)
2 3
 GET_FILENAME_COMPONENT (LANG "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
3 4
 GETTEXT_PROCESS_PO_FILES ("${LANG}" ALL INSTALL_DESTINATION ${LOCALEDIR} PO_FILES ${_po_files} )

Loading…
Cancel
Save