2011-07-21 06:33:29 -04:00
|
|
|
|
2015-02-27 18:05:29 -05:00
|
|
|
set(CUSTOM_GETTEXT_PATH "${PROJECT_SOURCE_DIR}/../../gettext"
|
2011-07-21 06:33:29 -04:00
|
|
|
CACHE FILEPATH "path to custom gettext")
|
|
|
|
|
2015-02-27 18:05:29 -05:00
|
|
|
find_path(GETTEXT_INCLUDE_DIR
|
2011-07-21 06:33:29 -04:00
|
|
|
NAMES libintl.h
|
|
|
|
PATHS "${CUSTOM_GETTEXT_PATH}/include"
|
2015-02-27 18:05:29 -05:00
|
|
|
DOC "GetText include directory")
|
2011-07-21 06:33:29 -04:00
|
|
|
|
2015-02-27 18:05:29 -05:00
|
|
|
find_program(GETTEXT_MSGFMT
|
2011-07-21 06:33:29 -04:00
|
|
|
NAMES msgfmt
|
|
|
|
PATHS "${CUSTOM_GETTEXT_PATH}/bin"
|
2015-02-27 18:05:29 -05:00
|
|
|
DOC "Path to msgfmt")
|
|
|
|
|
|
|
|
set(GETTEXT_REQUIRED_VARS GETTEXT_INCLUDE_DIR GETTEXT_MSGFMT)
|
2011-07-21 06:33:29 -04:00
|
|
|
|
2014-06-26 14:30:22 -04:00
|
|
|
if(APPLE)
|
2015-02-27 18:05:29 -05:00
|
|
|
find_library(GETTEXT_LIBRARY
|
2014-06-26 14:30:22 -04:00
|
|
|
NAMES libintl.a
|
|
|
|
PATHS "${CUSTOM_GETTEXT_PATH}/lib"
|
2015-02-27 18:05:29 -05:00
|
|
|
DOC "GetText library")
|
2014-06-26 14:30:22 -04:00
|
|
|
|
2015-02-27 18:05:29 -05:00
|
|
|
find_library(ICONV_LIBRARY
|
2014-06-26 14:30:22 -04:00
|
|
|
NAMES libiconv.dylib
|
|
|
|
PATHS "/usr/lib"
|
2015-02-27 18:05:29 -05:00
|
|
|
DOC "IConv library")
|
|
|
|
set(GETTEXT_REQUIRED_VARS ${GETTEXT_REQUIRED_VARS} GETTEXT_LIBRARY ICONV_LIBRARY)
|
2014-06-26 14:30:22 -04:00
|
|
|
endif(APPLE)
|
|
|
|
|
2015-02-27 18:05:29 -05:00
|
|
|
# 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
|
2011-07-21 08:50:15 -04:00
|
|
|
libintl.lib intl.lib libintl3.lib intl3.lib)
|
2015-02-27 18:05:29 -05:00
|
|
|
else()
|
|
|
|
set(GETTEXT_LIB_NAMES
|
2011-07-21 08:50:15 -04:00
|
|
|
libintl.dll.a intl.dll.a libintl3.dll.a intl3.dll.a)
|
2015-02-27 18:05:29 -05:00
|
|
|
endif()
|
|
|
|
find_library(GETTEXT_LIBRARY
|
2011-07-21 08:50:15 -04:00
|
|
|
NAMES ${GETTEXT_LIB_NAMES}
|
2011-07-21 06:33:29 -04:00
|
|
|
PATHS "${CUSTOM_GETTEXT_PATH}/lib"
|
2015-02-27 18:05:29 -05:00
|
|
|
DOC "GetText library")
|
|
|
|
find_file(GETTEXT_DLL
|
2011-07-21 06:33:29 -04:00
|
|
|
NAMES libintl.dll intl.dll libintl3.dll intl3.dll
|
2011-07-21 07:24:37 -04:00
|
|
|
PATHS "${CUSTOM_GETTEXT_PATH}/bin" "${CUSTOM_GETTEXT_PATH}/lib"
|
2011-07-21 06:33:29 -04:00
|
|
|
DOC "gettext *intl*.dll")
|
2015-02-27 18:05:29 -05:00
|
|
|
find_file(GETTEXT_ICONV_DLL
|
2011-07-21 06:33:29 -04:00
|
|
|
NAMES libiconv2.dll
|
2011-07-21 07:24:37 -04:00
|
|
|
PATHS "${CUSTOM_GETTEXT_PATH}/bin" "${CUSTOM_GETTEXT_PATH}/lib"
|
2011-07-21 06:33:29 -04:00
|
|
|
DOC "gettext *iconv*.lib")
|
2015-02-27 18:05:29 -05:00
|
|
|
set(GETTEXT_REQUIRED_VARS ${GETTEXT_REQUIRED_VARS} GETTEXT_DLL GETTEXT_ICONV_DLL)
|
|
|
|
endif(WIN32)
|
|
|
|
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(GetText DEFAULT_MSG ${GETTEXT_REQUIRED_VARS})
|
|
|
|
|
|
|
|
|
|
|
|
if(GETTEXT_FOUND)
|
|
|
|
# BSD variants require special linkage as they don't use glibc
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
|
|
|
set(GETTEXT_LIBRARY "intl")
|
|
|
|
endif()
|
2011-07-21 06:33:29 -04:00
|
|
|
|
2015-02-27 18:05:29 -05:00
|
|
|
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)
|
|
|
|
file(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*")
|
|
|
|
list(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
|
|
|
|
list(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES timestamp)
|
|
|
|
macro(SET_MO_PATHS _buildvar _destvar _locale)
|
|
|
|
string(REPLACE "<locale>" ${_locale} ${_buildvar} ${GETTEXT_MO_BUILD_PATH})
|
|
|
|
string(REPLACE "<locale>" ${_locale} ${_destvar} ${GETTEXT_MO_DEST_PATH})
|
|
|
|
endmacro()
|
|
|
|
endif()
|
2011-07-21 06:33:29 -04:00
|
|
|
|