From 02c69a7933a9a00e9c4fb4eafc45731ec1c02e0e Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 27 Feb 2018 22:21:00 +0100 Subject: [PATCH] Handle situation where gettext 0.19.6 is not available By default we require gettext 0.19.6 as this is needed to generate a translated version of gnucash.desktop and gnucash.appdata.xml. However this version is not available on some platforms (most notably our own ubuntu 14.04LTS travis instance). By setting ALLOW_OLD_GETTEXT=ON, the build configuration falls back to generating untranslated versions of said files instead. --- CMakeLists.txt | 23 +++++++++++++---- gnucash/gnome/CMakeLists.txt | 45 +++++++++++++++++++++++---------- po/CMakeLists.txt | 4 ++- util/ci/arch-testscript | 2 ++ util/ci/commonbuild | 4 +-- util/ci/ubuntu-14.04-testscript | 2 ++ 6 files changed, 58 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 295c40f655..81b6c13ab5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ OPTION (DISABLE_NLS "do not use Native Language Support" OFF) OPTION (DISABLE_DEPRECATED_GLIB "don't use deprecated glib functions" OFF) OPTION (DISABLE_DEPRECATED_GTK "don't use deprecated gtk, gdk or gdk-pixbuf functions" OFF) OPTION (DISABLE_DEPRECATED_GNOME "don't use deprecated gnome functions" OFF) +OPTION (ALLOW_OLD_GETTEXT "allow to configure build with a gettext version older than 0.19.6. Some files will not be translated!" OFF) # ############################################################ # These are also settable from the command line in a similar way. @@ -248,15 +249,27 @@ ENDIF() FIND_PROGRAM(GLIB_COMPILE_SCHEMAS glib-compile-schemas HINTS ${CMAKE_PREFIX_PATH}/gnome/bin) -FIND_PROGRAM(MSGFMT msgfmt) - IF (NOT GLIB_COMPILE_SCHEMAS) MESSAGE(SEND_ERROR "Can't find glib-compile-schemas program. Please set GLIB_COMPILE_SCHEMAS.") ENDIF(NOT GLIB_COMPILE_SCHEMAS) -IF (NOT MSGFMT) - MESSAGE(SEND_ERROR "Can't find msgfmt program. Please set MSGFMT.") -ENDIF(NOT MSGFMT) +if (ALLOW_OLD_GETTEXT) + find_package (Gettext REQUIRED) +else (ALLOW_OLD_GETTEXT) + find_package (Gettext 0.19.6) + if (NOT GETTEXT_FOUND) + message (FATAL_ERROR "Note the build can be configured with an older version of gnucash by setting ALLOW_OLD_GETTEXT=ON but then some files will not be translated: + - gnucash.desktop (requires at least gettext 0.19) + - gnucash.appdata.xml (requires at least gettext 0.19.6)") + endif (NOT GETTEXT_FOUND) +endif (ALLOW_OLD_GETTEXT) + +if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19) + message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19 in order to handle translation of the gnucash.desktop file. The build will be configured with an untranslated gnucash.desktop file.") +endif () +if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6) + message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19.6 in order to handle translation of the gnucash.appdata file. The build will be configured with an untranslated gnucash.appdata file.") +endif () FIND_PATH (REGEX_INCLUDE_PATH NAMES regex.h PATHS /usr/include /opt/gnome/include) diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index be1ceb7b33..fc5f1e28dc 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -167,15 +167,24 @@ IF (${CMAKE_VERSION} VERSION_GREATER 3.1) SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) ENDIF() -ADD_CUSTOM_COMMAND( - OUTPUT gnucash.appdata.xml - COMMAND ${CMAKE_COMMAND_TMP} - LC_ALL=C - ${MSGFMT} --xml --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in + +if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6) + # Gettext is too old to be able to merge an appdata file. + # Fall back to providing an unmerged (and hence untranslated) appdata file. + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in + ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml COPYONLY) +else() + add_custom_command ( + OUTPUT gnucash.appdata.xml + COMMAND ${CMAKE_COMMAND_TMP} + LC_ALL=C + ${GETTEXT_MSGFMT_EXECUTABLE} + --xml --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in -d ${CMAKE_SOURCE_DIR}/po -o gnucash.appdata.xml - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in -) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in + ) +endif() ADD_CUSTOM_TARGET(gnucash-appdata ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml) @@ -185,15 +194,23 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION ${CMA configure_file(gnucash.desktop.in.in gnucash.desktop.in) -ADD_CUSTOM_COMMAND( - OUTPUT gnucash.desktop - COMMAND ${CMAKE_COMMAND_TMP} - LC_ALL=C - ${MSGFMT} --desktop --template gnucash.desktop.in +if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19) + # Gettext is too old to be able to merge a desktop file. + # Fall back to providing an unmerged (and hence untranslated) desktop file. + configure_file (${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in + ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop COPYONLY) +else() + add_custom_command ( + OUTPUT gnucash.desktop + COMMAND ${CMAKE_COMMAND_TMP} + LC_ALL=C + ${GETTEXT_MSGFMT_EXECUTABLE} + --desktop --template gnucash.desktop.in -d ${CMAKE_SOURCE_DIR}/po -o gnucash.desktop - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in -) + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in + ) +endif() ADD_CUSTOM_TARGET(gnucash-desktop ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop) diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 389606096d..2e83767d3d 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -35,7 +35,9 @@ FOREACH(lingua ${ALL_LINGUAS}) LIST(APPEND CATALOGS ${_OUTPUT_FILE}) ADD_CUSTOM_COMMAND( OUTPUT ${_OUTPUT_FILE} - COMMAND ${CMAKE_COMMAND_TMP} ${MSGFMT} -o ${_OUTPUT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${lingua}.po + COMMAND ${CMAKE_COMMAND_TMP} + ${GETTEXT_MSGFMT_EXECUTABLE} + -o ${_OUTPUT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${lingua}.po ) SET(_BUILD_FILE_DIR ${DATADIR_BUILD}/locale/${lingua}/LC_MESSAGES) MAKE_DIRECTORY(${_BUILD_FILE_DIR}) diff --git a/util/ci/arch-testscript b/util/ci/arch-testscript index 45f541a0d7..bf59cb43a8 100644 --- a/util/ci/arch-testscript +++ b/util/ci/arch-testscript @@ -12,7 +12,9 @@ mkdir ourpython_bin ln -s /usr/bin/python2 ourpython_bin/python export PATH=/ourpython_bin:"$PATH" +export PLATFORM_CMAKE_OPTS= echo path is "$PATH" echo python version is "$(python --version)" +echo PLATFORM_CMAKE_OPTS= "$PLATFORM_CMAKE_OPTS" ../commonbuild diff --git a/util/ci/commonbuild b/util/ci/commonbuild index 8fb3f00ebd..9b1875d55e 100644 --- a/util/ci/commonbuild +++ b/util/ci/commonbuild @@ -7,11 +7,11 @@ cd build export TZ="America/Los_Angeles" if [[ "$BUILDTYPE" == "cmake-make" ]]; then - cmake ../gnucash + cmake ../gnucash $PLATFORM_CMAKE_OPTS make -j 4 make check || ../afterfailure elif [[ "$BUILDTYPE" == "cmake-ninja" ]]; then - cmake ../gnucash -DWITH_PYTHON=ON -DCMAKE_BUILD_TYPE=debug -G Ninja + cmake ../gnucash -DWITH_PYTHON=ON -DCMAKE_BUILD_TYPE=debug -G Ninja $PLATFORM_CMAKE_OPTS ninja ninja check || ../afterfailure; else diff --git a/util/ci/ubuntu-14.04-testscript b/util/ci/ubuntu-14.04-testscript index 15826881f9..a187801b80 100644 --- a/util/ci/ubuntu-14.04-testscript +++ b/util/ci/ubuntu-14.04-testscript @@ -4,5 +4,7 @@ # exit immediately. export GTEST_ROOT=/gtest/googletest GMOCK_ROOT=/gtest/googlemock +export PLATFORM_CMAKE_OPTS="-DALLOW_OLD_GETTEXT=ON" +echo PLATFORM_CMAKE_OPTS= "$PLATFORM_CMAKE_OPTS" ../commonbuild