• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
12# Look for the header file.
13FIND_PATH(
14    ICU_INCLUDE_DIR
15    NAMES unicode/utypes.h
16    DOC "Include directory for the ICU library")
17MARK_AS_ADVANCED(ICU_INCLUDE_DIR)
18
19# Look for the library.
20FIND_LIBRARY(
21    ICU_LIBRARY
22    NAMES icuuc cygicuuc cygicuuc32
23    DOC "Libraries to link against for the common parts of ICU")
24MARK_AS_ADVANCED(ICU_LIBRARY)
25
26# Copy the results to the output variables.
27IF (ICU_INCLUDE_DIR AND ICU_LIBRARY)
28    SET(ICU_FOUND 1)
29    SET(ICU_LIBRARIES ${ICU_LIBRARY})
30    SET(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
31
32    SET(ICU_VERSION 0)
33    SET(ICU_MAJOR_VERSION 0)
34    SET(ICU_MINOR_VERSION 0)
35    FILE(READ "${ICU_INCLUDE_DIR}/unicode/uversion.h" _ICU_VERSION_CONENTS)
36    STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONENTS}")
37    STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONENTS}")
38
39    SET(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}")
40
41    # Look for the ICU internationalization libraries
42    FIND_LIBRARY(
43        ICU_I18N_LIBRARY
44        NAMES icuin icui18n cygicuin cygicuin32
45        DOC "Libraries to link against for ICU internationalization")
46    MARK_AS_ADVANCED(ICU_I18N_LIBRARY)
47    IF (ICU_I18N_LIBRARY)
48        SET(ICU_I18N_FOUND 1)
49        SET(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY})
50    ELSE ()
51        SET(ICU_I18N_FOUND 0)
52        SET(ICU_I18N_LIBRARIES)
53    ENDIF ()
54ELSE ()
55    SET(ICU_FOUND 0)
56    SET(ICU_I18N_FOUND 0)
57    SET(ICU_LIBRARIES)
58    SET(ICU_I18N_LIBRARIES)
59    SET(ICU_INCLUDE_DIRS)
60    SET(ICU_VERSION)
61    SET(ICU_MAJOR_VERSION)
62    SET(ICU_MINOR_VERSION)
63ENDIF ()
64
65IF (ICU_FOUND)
66    IF (NOT ICU_FIND_QUIETLY)
67        MESSAGE(STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}")
68        MESSAGE(STATUS "Found ICU libraries: ${ICU_LIBRARIES}")
69    ENDIF ()
70ELSE ()
71    IF (ICU_FIND_REQUIRED)
72        MESSAGE(FATAL_ERROR "Could not find ICU")
73    ELSE ()
74        MESSAGE(STATUS "Optional package ICU was not found")
75    ENDIF ()
76ENDIF ()
77
78