FindICU.cmake 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Finds the International Components for Unicode (ICU) Library
  2. #
  3. # ICU_FOUND - True if ICU found.
  4. # ICU_I18N_FOUND - True if ICU's internationalization library found.
  5. # ICU_INCLUDE_DIRS - Directory to include to get ICU headers
  6. # Note: always include ICU headers as, e.g.,
  7. # unicode/utypes.h
  8. # ICU_LIBRARIES - Libraries to link against for the common ICU
  9. # ICU_I18N_LIBRARIES - Libraries to link against for ICU internationaliation
  10. # (note: in addition to ICU_LIBRARIES)
  11. # Look for the header file.
  12. find_path(
  13. ICU_INCLUDE_DIR
  14. NAMES unicode/utypes.h
  15. DOC "Include directory for the ICU library")
  16. mark_as_advanced(ICU_INCLUDE_DIR)
  17. # Look for the library.
  18. find_library(
  19. ICU_LIBRARY
  20. NAMES icuuc cygicuuc cygicuuc32
  21. DOC "Libraries to link against for the common parts of ICU")
  22. mark_as_advanced(ICU_LIBRARY)
  23. # Copy the results to the output variables.
  24. if (ICU_INCLUDE_DIR AND ICU_LIBRARY)
  25. set(ICU_FOUND 1)
  26. set(ICU_LIBRARIES ${ICU_LIBRARY})
  27. set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
  28. set(ICU_VERSION 0)
  29. set(ICU_MAJOR_VERSION 0)
  30. set(ICU_MINOR_VERSION 0)
  31. file(READ "${ICU_INCLUDE_DIR}/unicode/uversion.h" _ICU_VERSION_CONENTS)
  32. string(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONENTS}")
  33. string(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONENTS}")
  34. set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}")
  35. # Look for the ICU internationalization libraries
  36. find_library(
  37. ICU_I18N_LIBRARY
  38. NAMES icuin icui18n cygicuin cygicuin32
  39. DOC "Libraries to link against for ICU internationalization")
  40. mark_as_advanced(ICU_I18N_LIBRARY)
  41. if (ICU_I18N_LIBRARY)
  42. set(ICU_I18N_FOUND 1)
  43. set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY})
  44. else ()
  45. set(ICU_I18N_FOUND 0)
  46. set(ICU_I18N_LIBRARIES)
  47. endif ()
  48. else ()
  49. set(ICU_FOUND 0)
  50. set(ICU_I18N_FOUND 0)
  51. set(ICU_LIBRARIES)
  52. set(ICU_I18N_LIBRARIES)
  53. set(ICU_INCLUDE_DIRS)
  54. set(ICU_VERSION)
  55. set(ICU_MAJOR_VERSION)
  56. set(ICU_MINOR_VERSION)
  57. endif ()
  58. if (ICU_FOUND)
  59. if (NOT ICU_FIND_QUIETLY)
  60. message(STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}")
  61. message(STATUS "Found ICU libraries: ${ICU_LIBRARIES}")
  62. endif ()
  63. else ()
  64. if (ICU_FIND_REQUIRED)
  65. message(FATAL_ERROR "Could not find ICU")
  66. else ()
  67. message(STATUS "Optional package ICU was not found")
  68. endif ()
  69. endif ()