2
0

FindGettextLib.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Package finder for gettext libs and include files
  2. SET(CUSTOM_GETTEXT_PATH "${PROJECT_SOURCE_DIR}/../../gettext"
  3. CACHE FILEPATH "path to custom gettext")
  4. # by default
  5. SET(GETTEXT_FOUND FALSE)
  6. FIND_PATH(GETTEXT_INCLUDE_DIR
  7. NAMES libintl.h
  8. PATHS "${CUSTOM_GETTEXT_PATH}/include"
  9. DOC "gettext include directory")
  10. FIND_PROGRAM(GETTEXT_MSGFMT
  11. NAMES msgfmt
  12. PATHS "${CUSTOM_GETTEXT_PATH}/bin"
  13. DOC "path to msgfmt")
  14. # modern Linux, as well as Mac, seem to not need require special linking
  15. # they do not because gettext is part of glibc
  16. # TODO check the requirements on other BSDs and older Linux
  17. IF (WIN32)
  18. IF(MSVC)
  19. SET(GETTEXT_LIB_NAMES
  20. libintl.lib intl.lib libintl3.lib intl3.lib)
  21. ELSE()
  22. SET(GETTEXT_LIB_NAMES
  23. libintl.dll.a intl.dll.a libintl3.dll.a intl3.dll.a)
  24. ENDIF()
  25. FIND_LIBRARY(GETTEXT_LIBRARY
  26. NAMES ${GETTEXT_LIB_NAMES}
  27. PATHS "${CUSTOM_GETTEXT_PATH}/lib"
  28. DOC "gettext *intl*.lib")
  29. FIND_FILE(GETTEXT_DLL
  30. NAMES libintl.dll intl.dll libintl3.dll intl3.dll
  31. PATHS "${CUSTOM_GETTEXT_PATH}/bin" "${CUSTOM_GETTEXT_PATH}/lib"
  32. DOC "gettext *intl*.dll")
  33. FIND_FILE(GETTEXT_ICONV_DLL
  34. NAMES libiconv2.dll
  35. PATHS "${CUSTOM_GETTEXT_PATH}/bin" "${CUSTOM_GETTEXT_PATH}/lib"
  36. DOC "gettext *iconv*.lib")
  37. ENDIF(WIN32)
  38. IF(GETTEXT_INCLUDE_DIR AND GETTEXT_MSGFMT)
  39. IF (WIN32)
  40. # in the Win32 case check also for the extra linking requirements
  41. IF(GETTEXT_LIBRARY AND GETTEXT_DLL AND GETTEXT_ICONV_DLL)
  42. SET(GETTEXT_FOUND TRUE)
  43. ENDIF()
  44. ELSE(WIN32)
  45. # *BSD variants require special linkage as they don't use glibc
  46. IF(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
  47. SET(GETTEXT_LIBRARY "intl")
  48. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
  49. SET(GETTEXT_FOUND TRUE)
  50. ENDIF(WIN32)
  51. ENDIF()
  52. IF(GETTEXT_FOUND)
  53. SET(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
  54. SET(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
  55. SET(GETTEXT_MO_DEST_PATH ${LOCALEDIR}/<locale>/LC_MESSAGES)
  56. FILE(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*")
  57. LIST(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
  58. MACRO(SET_MO_PATHS _buildvar _destvar _locale)
  59. STRING(REPLACE "<locale>" ${_locale} ${_buildvar} ${GETTEXT_MO_BUILD_PATH})
  60. STRING(REPLACE "<locale>" ${_locale} ${_destvar} ${GETTEXT_MO_DEST_PATH})
  61. ENDMACRO(SET_MO_PATHS)
  62. ELSE()
  63. SET(GETTEXT_INCLUDE_DIR "")
  64. SET(GETTEXT_LIBRARY "")
  65. ENDIF()