File: FindICU.cmake

package info (click to toggle)
odil 0.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 5,092 kB
  • sloc: cpp: 54,080; python: 3,896; xml: 182; makefile: 94
file content (36 lines) | stat: -rw-r--r-- 1,311 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# - Try to find ICU
# Once done this will define
#  ICU_FOUND - System has ICU
#  ICU_INCLUDE_DIRS - The ICU include directories
#  ICU_LIBRARIES - The libraries needed to use ICU
#  ICU_DEFINITIONS - Compiler switches required for using ICU

find_package(PkgConfig)
pkg_check_modules(PC_ICU QUIET icu-uc)
set(ICU_DEFINITIONS ${PC_ICU_CFLAGS_OTHER})

find_path(ICU_INCLUDE_DIR "unicode/ucnv.h" HINTS ${PC_ICU_INCLUDE_DIRS})

# Get version
if(ICU_INCLUDE_DIR AND EXISTS "${ICU_INCLUDE_DIR}/unicode/uvernum.h")
	file(STRINGS "${ICU_INCLUDE_DIR}/unicode/uvernum.h" icu_header_str
	  REGEX "^#define[\t ]+U_ICU_VERSION[\t ]+\".*\".*")

	string(REGEX REPLACE "^#define[\t ]+U_ICU_VERSION[\t ]+\"([0-9]*).*"
	  "\\1" icu_version_string "${icu_header_str}")
	set(ICU_VERSION "${icu_version_string}" )
	unset(icu_header_str)
	unset(icu_version_string)
endif()

find_library(ICU_LIBRARY NAMES icuuc icuuc${ICU_VERSION} icuuc${ICU_VERSION}d HINTS ${PC_ICU_LIBRARY_DIRS} )

set(ICU_LIBRARIES ${ICU_LIBRARY} )
set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set ICU_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(ICU DEFAULT_MSG ICU_LIBRARY ICU_INCLUDE_DIR)

mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY)