]> git.lizzy.rs Git - minetest.git/commitdiff
Defer searching for libintl to CMake
authorsfan5 <sfan5@live.de>
Mon, 26 Sep 2022 14:59:47 +0000 (16:59 +0200)
committersfan5 <sfan5@live.de>
Thu, 13 Oct 2022 21:02:11 +0000 (23:02 +0200)
resolves #12800

README.md
cmake/Modules/FindGettextLib.cmake
src/CMakeLists.txt

index 32dacd348e56f2710a9eadce8ebb56e614bfec98..c13d5f8223db3e4e494ba6f080e92a31c0bea049 100644 (file)
--- a/README.md
+++ b/README.md
@@ -279,9 +279,10 @@ Library specific options:
     FREETYPE_LIBRARY                - Path to libfreetype.a/libfreetype.so/freetype.lib
     FREETYPE_DLL                    - Only on Windows; path to libfreetype-6.dll
     GETTEXT_DLL                     - Only when building with gettext on Windows; paths to libintl + libiconv DLLs
-    GETTEXT_INCLUDE_DIR             - Only when building with gettext; directory that contains iconv.h
-    GETTEXT_LIBRARY                 - Only when building with gettext on Windows; path to libintl.dll.a
+    GETTEXT_INCLUDE_DIR             - Only when building with gettext; directory that contains libintl.h
+    GETTEXT_LIBRARY                 - Optional/platform-dependent with gettext; path to libintl.so/libintl.dll.a
     GETTEXT_MSGFMT                  - Only when building with gettext; path to msgfmt/msgfmt.exe
+    ICONV_LIBRARY                   - Optional/platform-dependent; path to libiconv.so/libiconv.dylib
     IRRLICHT_DLL                    - Only on Windows; path to IrrlichtMt.dll
     IRRLICHT_INCLUDE_DIR            - Directory that contains IrrCompileConfig.h (usable for server build only)
     LEVELDB_INCLUDE_DIR             - Only when building with LevelDB; directory that contains db.h
index b7681827c0ff159c924e4a675c8e4a808a80905c..4aacc9a40212291caeaaa16a8781515634d4676e 100644 (file)
@@ -1,60 +1,36 @@
-
-set(CUSTOM_GETTEXT_PATH "${PROJECT_SOURCE_DIR}/../../gettext"
-       CACHE FILEPATH "path to custom gettext")
-
-find_path(GETTEXT_INCLUDE_DIR
-       NAMES libintl.h
-       PATHS "${CUSTOM_GETTEXT_PATH}/include"
-       DOC "GetText include directory")
+# This module find everything related to Gettext:
+# * development tools (msgfmt)
+# * libintl for runtime usage
 
 find_program(GETTEXT_MSGFMT
        NAMES msgfmt
-       PATHS "${CUSTOM_GETTEXT_PATH}/bin"
-       DOC "Path to msgfmt")
-
-set(GETTEXT_REQUIRED_VARS GETTEXT_INCLUDE_DIR GETTEXT_MSGFMT)
-
-if(APPLE)
-       find_library(GETTEXT_LIBRARY
-               NAMES libintl.a
-               PATHS "${CUSTOM_GETTEXT_PATH}/lib"
-               DOC "GetText library")
-
-       find_library(ICONV_LIBRARY
-               NAMES libiconv.dylib
-               PATHS "/usr/lib"
-               DOC "IConv library")
-       set(GETTEXT_REQUIRED_VARS ${GETTEXT_REQUIRED_VARS} GETTEXT_LIBRARY ICONV_LIBRARY)
-endif(APPLE)
-
-# Modern Linux, as well as OSX, does not require special linking because
-# GetText is part of glibc.
-# TODO: check the requirements on other BSDs and older Linux
-if(WIN32)
-       if(MSVC)
-               set(GETTEXT_LIB_NAMES
-                       libintl.lib intl.lib libintl3.lib intl3.lib)
+       DOC "Path to Gettext msgfmt")
+
+if(GETTEXT_INCLUDE_DIR AND GETTEXT_LIBRARY)
+       # This is only really used on Windows
+       find_path(GETTEXT_INCLUDE_DIR NAMES libintl.h)
+       find_library(GETTEXT_LIBRARY NAMES intl)
+
+       set(GETTEXT_REQUIRED_VARS GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT)
+else()
+       find_package(Intl)
+       set(GETTEXT_INCLUDE_DIR ${Intl_INCLUDE_DIRS})
+       set(GETTEXT_LIBRARY ${Intl_LIBRARIES})
+
+       # Because intl may be part of the libc it's valid for the two variables to
+       # be empty, therefore we can't just put them into GETTEXT_REQUIRED_VARS.
+       if(Intl_FOUND)
+               set(GETTEXT_REQUIRED_VARS GETTEXT_MSGFMT)
        else()
-               set(GETTEXT_LIB_NAMES
-                       libintl.dll.a intl.dll.a libintl3.dll.a intl3.dll.a)
+               set(GETTEXT_REQUIRED_VARS _LIBINTL_WAS_NOT_FOUND)
        endif()
-       find_library(GETTEXT_LIBRARY
-               NAMES ${GETTEXT_LIB_NAMES}
-               PATHS "${CUSTOM_GETTEXT_PATH}/lib"
-               DOC "GetText library")
-endif(WIN32)
-
+endif()
 
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(GettextLib DEFAULT_MSG ${GETTEXT_REQUIRED_VARS})
 
-
 if(GETTEXTLIB_FOUND)
-       # BSD variants require special linkage as they don't use glibc
-       if(${CMAKE_SYSTEM_NAME} MATCHES "BSD|DragonFly")
-               set(GETTEXT_LIBRARY "intl")
-       endif()
-
+       # Set up paths for building
        set(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
        set(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
        set(GETTEXT_MO_DEST_PATH ${LOCALEDIR}/<locale>/LC_MESSAGES)
index 34341866880a9e96fca8bd1ef7a6c955d3dc0448..1f1e987f79566f2416b35e699c8e3116dfec080f 100644 (file)
@@ -292,16 +292,15 @@ else()
                endif(HAVE_LIBRT)
        endif(APPLE)
 
-       # Prefer local iconv if installed
        find_library(ICONV_LIBRARY iconv)
        mark_as_advanced(ICONV_LIBRARY)
        if (ICONV_LIBRARY)
                set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY})
        endif()
+
        if (HAIKU)
-               set(PLATFORM_LIBS ${PLATFORM_LIBS} intl network)
+               set(PLATFORM_LIBS ${PLATFORM_LIBS} network)
        endif()
-
 endif()
 
 check_include_files(endian.h HAVE_ENDIAN_H)