2
0

FindGettextLib.cmake 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. set(CUSTOM_GETTEXT_PATH "${PROJECT_SOURCE_DIR}/../../gettext"
  2. CACHE FILEPATH "path to custom gettext")
  3. find_path(GETTEXT_INCLUDE_DIR
  4. NAMES libintl.h
  5. PATHS "${CUSTOM_GETTEXT_PATH}/include"
  6. DOC "GetText include directory")
  7. find_program(GETTEXT_MSGFMT
  8. NAMES msgfmt
  9. PATHS "${CUSTOM_GETTEXT_PATH}/bin"
  10. DOC "Path to msgfmt")
  11. set(GETTEXT_REQUIRED_VARS GETTEXT_INCLUDE_DIR GETTEXT_MSGFMT)
  12. if(APPLE)
  13. find_library(GETTEXT_LIBRARY
  14. NAMES libintl.a
  15. PATHS "${CUSTOM_GETTEXT_PATH}/lib"
  16. DOC "GetText library")
  17. find_library(ICONV_LIBRARY
  18. NAMES libiconv.dylib
  19. PATHS "/usr/lib"
  20. DOC "IConv library")
  21. set(GETTEXT_REQUIRED_VARS ${GETTEXT_REQUIRED_VARS} GETTEXT_LIBRARY ICONV_LIBRARY)
  22. endif(APPLE)
  23. # Modern Linux, as well as OSX, does not require special linking because
  24. # GetText is part of glibc.
  25. # TODO: check the requirements on other BSDs and older Linux
  26. if(WIN32)
  27. if(MSVC)
  28. set(GETTEXT_LIB_NAMES
  29. libintl.lib intl.lib libintl3.lib intl3.lib)
  30. else()
  31. set(GETTEXT_LIB_NAMES
  32. libintl.dll.a intl.dll.a libintl3.dll.a intl3.dll.a)
  33. endif()
  34. find_library(GETTEXT_LIBRARY
  35. NAMES ${GETTEXT_LIB_NAMES}
  36. PATHS "${CUSTOM_GETTEXT_PATH}/lib"
  37. DOC "GetText library")
  38. endif(WIN32)
  39. include(FindPackageHandleStandardArgs)
  40. find_package_handle_standard_args(GettextLib DEFAULT_MSG ${GETTEXT_REQUIRED_VARS})
  41. if(GETTEXTLIB_FOUND)
  42. # BSD variants require special linkage as they don't use glibc
  43. if(${CMAKE_SYSTEM_NAME} MATCHES "BSD|DragonFly")
  44. set(GETTEXT_LIBRARY "intl")
  45. endif()
  46. set(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
  47. set(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
  48. set(GETTEXT_MO_DEST_PATH ${LOCALEDIR}/<locale>/LC_MESSAGES)
  49. file(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*")
  50. list(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
  51. list(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES timestamp)
  52. macro(SET_MO_PATHS _buildvar _destvar _locale)
  53. string(REPLACE "<locale>" ${_locale} ${_buildvar} ${GETTEXT_MO_BUILD_PATH})
  54. string(REPLACE "<locale>" ${_locale} ${_destvar} ${GETTEXT_MO_DEST_PATH})
  55. endmacro()
  56. endif()