From 27c95454ba2be0db52c314860b04a621ad593000 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 29 Jan 2024 16:03:43 +0000 Subject: [PATCH] Provide a manual cmake flag to turn off libintl. This is likely to be useful for people building out-of-tree clients of libtarmac: partly because the sudden dependency on libintl might be inconvenient for them, and also because the use of libintl might not even work if their own application doesn't integrate libintl and provide message translations. (It's possible that to support out-of-tree libtarmac clients fully, we might need to separate the messages in this project into a set for the library and a set for the applications. But this switch is surely _also_ useful.) --- cmake/unix.cmake | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmake/unix.cmake b/cmake/unix.cmake index 8a85b0a..8c2a3cd 100644 --- a/cmake/unix.cmake +++ b/cmake/unix.cmake @@ -21,8 +21,6 @@ find_package(Curses ${REQUIRED_PACKAGE}) find_package(PkgConfig ${REQUIRED_PACKAGE}) -find_package(Gettext) -find_package(Intl) include(GNUInstallDirs) include(CheckSymbolExists) @@ -32,7 +30,17 @@ check_symbol_exists(wcswidth "wchar.h" HAVE_WCSWIDTH) set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR} CACHE STRING "Directory to find gettext locale files in.") +# USE_LIBINTL: user-facing option to not even _try_ to link with libintl +set(USE_LIBINTL ON + CACHE BOOL "Use libintl for message internationalisation if possible") + +# HAVE_LIBINTL: whether we turn out to be _actually_ linking with +# libintl (requiring it to be enabled, _and_ found at configure time) set(HAVE_LIBINTL 0) -if(Intl_FOUND) - set(HAVE_LIBINTL 1) +if(USE_LIBINTL) + find_package(Gettext) + find_package(Intl) + if(Intl_FOUND) + set(HAVE_LIBINTL 1) + endif() endif()