]> source.dussan.org Git - tigervnc.git/commitdiff
Add fallbacks for translating .desktop file
authorPierre Ossman <ossman@cendio.se>
Fri, 21 Jul 2017 12:07:15 +0000 (14:07 +0200)
committerPierre Ossman <ossman@cendio.se>
Fri, 21 Jul 2017 12:07:15 +0000 (14:07 +0200)
Only fairly recent versions of gettext can translate .desktop files.
So fall back to the older intltool on older systems, or just a plain
copy if intltool is also missing.

vncviewer/CMakeLists.txt

index 282ed9dac515f8ea23e1f652f52046bd18765c5f..e04e335ac20cd2ddaae94305ba4b95d2e669acba 100644 (file)
@@ -59,15 +59,36 @@ endif()
 install(TARGETS vncviewer DESTINATION ${BIN_DIR})
 if(UNIX)
   install(FILES vncviewer.man DESTINATION ${MAN_DIR}/man1 RENAME vncviewer.1)
+
   configure_file(vncviewer.desktop.in.in vncviewer.desktop.in)
-  add_custom_command(OUTPUT vncviewer.desktop
-    COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
-              --desktop --template vncviewer.desktop.in
-              -d ${CMAKE_SOURCE_DIR}/po -o vncviewer.desktop
-    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/vncviewer.desktop.in
-  )
+  find_program(INTLTOOL_MERGE_EXECUTABLE intltool-merge)
+  if("${GETTEXT_VERSION_STRING}" VERSION_GREATER 0.17.99)
+    add_custom_command(OUTPUT vncviewer.desktop
+      COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
+                --desktop --template vncviewer.desktop.in
+                -d ${CMAKE_SOURCE_DIR}/po -o vncviewer.desktop
+      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/vncviewer.desktop.in
+    )
+  elseif(INTLTOOL_MERGE_EXECUTABLE)
+    add_custom_command(OUTPUT vncviewer.desktop
+      COMMAND sed -e 's/^Name/_Name/'
+                -e 's/^GenericName/_GenericName/'
+                -e 's/^Comment/_Comment/'
+                vncviewer.desktop.in > vncviewer.desktop.intl
+      COMMAND ${INTLTOOL_MERGE_EXECUTABLE}
+                -d ${CMAKE_SOURCE_DIR}/po
+                vncviewer.desktop.intl vncviewer.desktop
+      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/vncviewer.desktop.in
+    )
+  else()
+    add_custom_command(OUTPUT vncviewer.desktop
+      COMMAND cp vncviewer.desktop.in vncviewer.desktop
+      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/vncviewer.desktop.in
+    )
+  endif()
   add_custom_target(desktop ALL DEPENDS vncviewer.desktop)
   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/vncviewer.desktop DESTINATION ${DATA_DIR}/applications)
+
   foreach(res 16 22 24 32 48)
     install(FILES ../media/icons/tigervnc_${res}.png DESTINATION ${DATA_DIR}/icons/hicolor/${res}x${res}/apps RENAME tigervnc.png)
   endforeach()