diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2024-02-29 16:35:52 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2024-02-29 16:37:19 +0200 |
commit | 4cd1042ee752d61370c685d0d8b20c1e935672f7 (patch) | |
tree | d3cf205e816d60d5a3dfcd4be2af1173147de2d3 | |
parent | xz: Add comments. (diff) | |
download | xz-4cd1042ee752d61370c685d0d8b20c1e935672f7.tar.xz |
CMake: Warn if gettext tools and pre-created .gmo files are missing.
It's only done with CMake >= 3.20 and if library support
for translation was already found.
Sort of fixes: https://github.com/tukaani-project/xz/issues/82
-rw-r--r-- | CMakeLists.txt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d2b1af7a..035cbec5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,9 +278,34 @@ endif() if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20") find_package(Intl) find_package(Gettext) + if(Intl_FOUND) option(ENABLE_NLS "Native Language Support (translated messages)" ON) + # If translation support is enabled but neither gettext tools or + # pre-generated .gmo files exist, translation support cannot be + # enabled. + # + # The detection of pre-generated .gmo files is done by only + # checking for the existence of a single .gmo file; Ukrainian + # is one of many translations that gets regular updates. + if(ENABLE_NLS AND NOT GETTEXT_FOUND AND + NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/po/uk.gmo") + # This only sets the variable, not the cache variable! + set(ENABLE_NLS OFF) + + # This message is shown only when new enough CMake is used and + # library support for translations was found. The assumptions is + # that in this situation the user might have interest in the + # translations. This also keeps this code simpler. + message(WARNING "Native language support (NLS) has been disabled. " + "NLS support requires either gettext tools or " + "pre-generated .gmo files. The latter are only " + "available in distribution tarballs. " + "To avoid this warning, NLS can be explicitly " + "disabled by passing -DENABLE_NLS=OFF to cmake.") + endif() + # The *installed* name of the translation files is "xz.mo". set(TRANSLATION_DOMAIN "xz") endif() |