From 1d6e1fd75272b0d1799c453b16a1b73500452974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 15 Oct 2023 14:58:26 +0200 Subject: core: make libintl.h required if CMake option ENABLE_NLS is enabled (issue #2031) --- cmake/FindGettext.cmake | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'cmake') diff --git a/cmake/FindGettext.cmake b/cmake/FindGettext.cmake index 358734688..2460e190b 100644 --- a/cmake/FindGettext.cmake +++ b/cmake/FindGettext.cmake @@ -45,26 +45,28 @@ set(CMAKE_REQUIRED_INCLUDES ${LIBINTL_INCLUDE}) check_include_files(libintl.h HAVE_LIBINTL_H) -if(HAVE_LIBINTL_H) - check_function_exists(dgettext LIBC_HAS_DGETTEXT) - if(LIBC_HAS_DGETTEXT) - set(GETTEXT_FOUND TRUE) - else() - find_library(LIBINTL_LIBRARY NAMES intl - PATHS - /usr/local/lib - /usr/lib - ) - if(LIBINTL_LIBRARY) - if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") - set(CMAKE_REQUIRED_LIBRARIES "iconv") - check_library_exists(${LIBINTL_LIBRARY} "libintl_dgettext" "" LIBINTL_HAS_DGETTEXT) - else() - check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT) - endif() - if(LIBINTL_HAS_DGETTEXT) - set(GETTEXT_FOUND TRUE) - endif() +if(NOT HAVE_LIBINTL_H) + message(SEND_ERROR "Header libintl.h not found, required if ENABLE_NLS is enabled") +endif() + +check_function_exists(dgettext LIBC_HAS_DGETTEXT) +if(LIBC_HAS_DGETTEXT) + set(GETTEXT_FOUND TRUE) +else() + find_library(LIBINTL_LIBRARY NAMES intl + PATHS + /usr/local/lib + /usr/lib + ) + if(LIBINTL_LIBRARY) + if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") + set(CMAKE_REQUIRED_LIBRARIES "iconv") + check_library_exists(${LIBINTL_LIBRARY} "libintl_dgettext" "" LIBINTL_HAS_DGETTEXT) + else() + check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT) + endif() + if(LIBINTL_HAS_DGETTEXT) + set(GETTEXT_FOUND TRUE) endif() endif() endif() -- cgit v1.2.3