]> git.saurik.com Git - apt.git/blobdiff - CMake/Translations.cmake
This is 2016 and APT already requires use of mmap.
[apt.git] / CMake / Translations.cmake
index 7bdcab6abecab451d6eb8cdfa17903f0b91301ee..79f2633a79534ef001484dd5ba3b8c9a96e8d55f 100644 (file)
@@ -11,6 +11,7 @@ function(apt_add_translation_domain)
     set(abs_files "")
     set(scripts "")
     set(abs_scripts "")
+    set(mofiles)
     set(targets ${NLS_TARGETS})
     set(domain ${NLS_DOMAIN})
     set(xgettext_params
@@ -21,13 +22,7 @@ function(apt_add_translation_domain)
         --msgid-bugs-address=${PACKAGE_MAIL}
     )
     foreach(source ${NLS_SCRIPTS})
-            string(SUBSTRING ${source} 0 1 init_char)
-            string(COMPARE EQUAL ${init_char} "/" is_absolute)
-            if (${is_absolute})
-                set(file "${source}")
-            else()
-                set(file "${CMAKE_CURRENT_SOURCE_DIR}/${source}")
-            endif()
+            path_join(file "${CMAKE_CURRENT_SOURCE_DIR}" "${source}")
             file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file})
             list(APPEND scripts ${relfile})
             list(APPEND abs_scripts ${file})
@@ -36,13 +31,7 @@ function(apt_add_translation_domain)
         get_target_property(source_dir ${target} SOURCE_DIR)
         get_target_property(sources ${target} SOURCES)
         foreach(source ${sources})
-            string(SUBSTRING ${source} 0 1 init_char)
-            string(COMPARE EQUAL ${init_char} "/" is_absolute)
-            if (${is_absolute})
-                set(file "${source}")
-            else()
-                set(file "${source_dir}/${source}")
-            endif()
+            path_join(file "${source_dir}" "${source}")
             file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file})
             set(files ${files} ${relfile})
             set(abs_files ${abs_files} ${file})
@@ -79,16 +68,19 @@ function(apt_add_translation_domain)
     # build a ${domain.pot}-tmp as a byproduct. The msgfmt command than depend
     # on the byproduct while their target depends on the output, so that msgfmt
     # does not have to be rerun if nothing in the template changed.
+    #
+    # Make sure the .pot-tmp has no line numbers, to avoid useless rebuilding
+    # of .mo files.
     add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot
         BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp
-        COMMAND msgcomm --more-than=0 --sort-by-file
+        COMMAND msgcomm --more-than=0 --omit-header --sort-by-file --add-location=file
                          ${sh_pot}
                          ${CMAKE_CURRENT_BINARY_DIR}/${domain}.c.pot
-                         --output=${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot
-        COMMAND msgcomm --more-than=0 --omit-header --sort-by-file
+                         --output=${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp0
+        COMMAND msgcomm --more-than=0 --sort-by-file
                          ${sh_pot}
                          ${CMAKE_CURRENT_BINARY_DIR}/${domain}.c.pot
-                         --output=${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp0
+                         --output=${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot
         COMMAND cmake -E copy_if_different
                          ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp0
                          ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp
@@ -158,7 +150,7 @@ function(apt_add_update_po)
                 continue()
             endif()
             add_custom_target(update-po-${langcode}
-                COMMAND msgmerge -q --update --backup=none ${translation} ${output}
+                COMMAND msgmerge -q --previous --update --backup=none ${translation} ${output}
                 DEPENDS nls-${master_name}
             )
             add_dependencies(update-po update-po-${langcode})