2022-09-26 16:59:47 +02:00
|
|
|
# This module find everything related to Gettext:
|
|
|
|
# * development tools (msgfmt)
|
|
|
|
# * libintl for runtime usage
|
2011-07-21 12:33:29 +02:00
|
|
|
|
2015-02-28 00:05:29 +01:00
|
|
|
find_program(GETTEXT_MSGFMT
|
2011-07-21 12:33:29 +02:00
|
|
|
NAMES msgfmt
|
2022-09-26 16:59:47 +02:00
|
|
|
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)
|
2015-02-28 00:05:29 +01:00
|
|
|
else()
|
2022-09-26 16:59:47 +02:00
|
|
|
set(GETTEXT_REQUIRED_VARS _LIBINTL_WAS_NOT_FOUND)
|
2015-02-28 00:05:29 +01:00
|
|
|
endif()
|
2022-09-26 16:59:47 +02:00
|
|
|
endif()
|
2015-02-28 00:05:29 +01:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
2020-04-28 16:34:18 +02:00
|
|
|
find_package_handle_standard_args(GettextLib DEFAULT_MSG ${GETTEXT_REQUIRED_VARS})
|
2015-02-28 00:05:29 +01:00
|
|
|
|
2020-04-28 16:34:18 +02:00
|
|
|
if(GETTEXTLIB_FOUND)
|
2022-09-26 16:59:47 +02:00
|
|
|
# Set up paths for building
|
2015-02-28 00:05:29 +01:00
|
|
|
set(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
|
2023-03-27 20:02:48 +02:00
|
|
|
# If the executable is expected to be ran from <source dir>/bin/, also
|
|
|
|
# generate the locale in <source dir>/locale/.
|
|
|
|
if(RUN_IN_PLACE AND NOT CMAKE_CROSSCOMPILING)
|
|
|
|
set(GETTEXT_MO_BUILD_PATH ${CMAKE_SOURCE_DIR}/locale/<locale>/LC_MESSAGES)
|
|
|
|
else()
|
|
|
|
set(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
|
|
|
|
endif()
|
2015-02-28 00:05:29 +01:00
|
|
|
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 12:33:29 +02:00
|
|
|
|