Defer searching for libintl to CMake

resolves #12800
This commit is contained in:
sfan5 2022-09-26 16:59:47 +02:00
parent af38bae57f
commit e8ee4cb40d
3 changed files with 26 additions and 50 deletions

@ -279,9 +279,10 @@ Library specific options:
FREETYPE_LIBRARY - Path to libfreetype.a/libfreetype.so/freetype.lib FREETYPE_LIBRARY - Path to libfreetype.a/libfreetype.so/freetype.lib
FREETYPE_DLL - Only on Windows; path to libfreetype-6.dll 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_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_INCLUDE_DIR - Only when building with gettext; directory that contains libintl.h
GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a 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 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_DLL - Only on Windows; path to IrrlichtMt.dll
IRRLICHT_INCLUDE_DIR - Directory that contains IrrCompileConfig.h (usable for server build only) 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 LEVELDB_INCLUDE_DIR - Only when building with LevelDB; directory that contains db.h

@ -1,60 +1,36 @@
# This module find everything related to Gettext:
set(CUSTOM_GETTEXT_PATH "${PROJECT_SOURCE_DIR}/../../gettext" # * development tools (msgfmt)
CACHE FILEPATH "path to custom gettext") # * libintl for runtime usage
find_path(GETTEXT_INCLUDE_DIR
NAMES libintl.h
PATHS "${CUSTOM_GETTEXT_PATH}/include"
DOC "GetText include directory")
find_program(GETTEXT_MSGFMT find_program(GETTEXT_MSGFMT
NAMES msgfmt NAMES msgfmt
PATHS "${CUSTOM_GETTEXT_PATH}/bin" DOC "Path to Gettext msgfmt")
DOC "Path to msgfmt")
set(GETTEXT_REQUIRED_VARS GETTEXT_INCLUDE_DIR 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)
if(APPLE) set(GETTEXT_REQUIRED_VARS GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT)
find_library(GETTEXT_LIBRARY else()
NAMES libintl.a find_package(Intl)
PATHS "${CUSTOM_GETTEXT_PATH}/lib" set(GETTEXT_INCLUDE_DIR ${Intl_INCLUDE_DIRS})
DOC "GetText library") set(GETTEXT_LIBRARY ${Intl_LIBRARIES})
find_library(ICONV_LIBRARY # Because intl may be part of the libc it's valid for the two variables to
NAMES libiconv.dylib # be empty, therefore we can't just put them into GETTEXT_REQUIRED_VARS.
PATHS "/usr/lib" if(Intl_FOUND)
DOC "IConv library") set(GETTEXT_REQUIRED_VARS GETTEXT_MSGFMT)
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)
else() else()
set(GETTEXT_LIB_NAMES set(GETTEXT_REQUIRED_VARS _LIBINTL_WAS_NOT_FOUND)
libintl.dll.a intl.dll.a libintl3.dll.a intl3.dll.a)
endif() endif()
find_library(GETTEXT_LIBRARY endif()
NAMES ${GETTEXT_LIB_NAMES}
PATHS "${CUSTOM_GETTEXT_PATH}/lib"
DOC "GetText library")
endif(WIN32)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GettextLib DEFAULT_MSG ${GETTEXT_REQUIRED_VARS}) find_package_handle_standard_args(GettextLib DEFAULT_MSG ${GETTEXT_REQUIRED_VARS})
if(GETTEXTLIB_FOUND) if(GETTEXTLIB_FOUND)
# BSD variants require special linkage as they don't use glibc # Set up paths for building
if(${CMAKE_SYSTEM_NAME} MATCHES "BSD|DragonFly")
set(GETTEXT_LIBRARY "intl")
endif()
set(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po) set(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
set(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES) set(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
set(GETTEXT_MO_DEST_PATH ${LOCALEDIR}/<locale>/LC_MESSAGES) set(GETTEXT_MO_DEST_PATH ${LOCALEDIR}/<locale>/LC_MESSAGES)

@ -292,16 +292,15 @@ else()
endif(HAVE_LIBRT) endif(HAVE_LIBRT)
endif(APPLE) endif(APPLE)
# Prefer local iconv if installed
find_library(ICONV_LIBRARY iconv) find_library(ICONV_LIBRARY iconv)
mark_as_advanced(ICONV_LIBRARY) mark_as_advanced(ICONV_LIBRARY)
if (ICONV_LIBRARY) if (ICONV_LIBRARY)
set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY}) set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY})
endif() endif()
if (HAIKU)
set(PLATFORM_LIBS ${PLATFORM_LIBS} intl network)
endif()
if (HAIKU)
set(PLATFORM_LIBS ${PLATFORM_LIBS} network)
endif()
endif() endif()
check_include_files(endian.h HAVE_ENDIAN_H) check_include_files(endian.h HAVE_ENDIAN_H)