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.
This commit is contained in:
Geert Janssens
2018-02-27 22:21:00 +01:00
parent ba799feb2a
commit 02c69a7933
6 changed files with 58 additions and 22 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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})

View File

@@ -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

View File

@@ -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

View File

@@ -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