diff --git a/CMakeLists.txt b/CMakeLists.txt index 07b71d945d..fe7a38b8b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,6 @@ 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. @@ -269,26 +268,27 @@ find_path (REGEX_INCLUDE_PATH NAMES regex.h find_library (REGEX_LIBRARY NAMES regex) # I18N -if (ALLOW_OLD_GETTEXT) - find_package (Gettext REQUIRED) -else() - find_package (Gettext 0.20) - if (NOT GETTEXT_FOUND) - message (FATAL_ERROR "Note the build can be configured with an older version of gettext 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) - - tag developer_name from gnucash.appdata.xml (requires at least gettext 0.20)") - endif() -endif() +# Potfile generation will only be enabled if building from a git worktree +set (BUILD_GNUCASH_POT ${BUILDING_FROM_VCS}) +set (TRANSLATE_GNUCASH_APPDATA ON) +set (TRANSLATE_GNUCASH_DESKTOP ON) -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.") +find_package (Gettext 0.18.1 REQUIRED) +if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20) + message (WARNING "Gettext version 0.20 or more recent is required to translate the 'developer_name' tag in gnucash.appdata.xml. All but that tag will be translated in the generated file.") + if(BUILD_GNUCASH_POT) + # Only emit warning if potfile generation was enabled otherwise + message (WARNING "Gettext version 0.20 or more recent is required to extract all translatable strings. Potfile generation will be disabled.") + endif() + set (BUILD_GNUCASH_POT OFF) 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.") + set (TRANSLATE_GNUCASH_APPDATA OFF) + message (WARNING "Gettext version 0.19.6 or more recent is required to translate gnucash.appdata.xml. The build will be configured to generate an untranslated gnucash.appdata.xml.") endif() -if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20) - message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.20 in order to handle the translation of 'GnuCash Project' from the gnucash.appdata file. That message will be missing in gnucash.pot.") +if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19) + set (TRANSLATE_GNUCASH_DESKTOP OFF) + message (WARNING "Gettext version 0.19 or more recent is required to translate gnucash.desktop. The build will be configured to generate an untranslated gnucash.desktop.") endif() find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index 727f91df6a..7a05b38b09 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -161,18 +161,7 @@ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in ${VCS_INFO_FILE} -D SRC_DIR=${CMAKE_SOURCE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/configure-appdata.cmake) -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. - add_custom_command ( - OUTPUT gnucash.appdata.xml - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in - ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml - - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE} - ) -else() +if (TRANSLATE_GNUCASH_APPDATA) # FIXME: where does LC_ALL=C come from? add_custom_command ( OUTPUT gnucash.appdata.xml @@ -182,8 +171,17 @@ else() --xml --template ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in -d ${CMAKE_SOURCE_DIR}/po -o gnucash.appdata.xml - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE} - ) + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE}) +else() + # Gettext is too old to be able to merge an appdata file. + # Fall back to providing an unmerged (and hence untranslated) appdata file. + add_custom_command ( + OUTPUT gnucash.appdata.xml + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in + ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE}) endif() add_custom_target(gnucash-appdata ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml) @@ -194,12 +192,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION ${CMA configure_file(gnucash.desktop.in.in 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() +if (TRANSLATE_GNUCASH_DESKTOP) add_custom_command ( OUTPUT gnucash.desktop COMMAND ${CMAKE_COMMAND} -E env @@ -208,8 +201,12 @@ else() --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) +else() + # 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) 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 25aa9a6a8b..47092ce071 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -132,7 +132,7 @@ function(make_gnucash_potfiles) set(gnucash_pot_depends ${POTFILE_DEPS} CACHE INTERNAL "List of files with translatable strings. If any of these change, gnucash.pot should be regenerated") endfunction() -if(BUILDING_FROM_VCS) +if(BUILD_GNUCASH_POT) make_gnucash_potfiles()