Add: [NewGRF] Vehicle prop that allows refittability based on cargo class intersection.
[openttd-github.git] / cmake / FindICU.cmake
blobefb3ba3abf7229e2cdd84ac96a2b3f399ac12f59
1 # CMake provides a FindICU module since version 3.7.
2 # But it doesn't use pkgconfig, doesn't set expected variables,
3 # And it returns incomplete dependencies if only some modules are searched.
6 #[=======================================================================[.rst:
7 FindICU
8 -------
10 Finds components of the ICU library.
12 Accepted components are: uc, i18n, le, lx, io, data
14 Result Variables
15 ^^^^^^^^^^^^^^^^
17 This will define the following variables:
19 ``ICU_FOUND``
20   True if components of ICU library are found.
21 ``ICU_VERSION``
22   The version of the ICU library which was found.
23 ``ICU_<c>_FOUND``
24   True if the system has the <c> component of ICU library.
25 ``ICU_<c>_INCLUDE_DIRS``
26   Include directories needed to use the <c> component of ICU library.
27 ``ICU_<c>_LIBRARIES``
28   Libraries needed to link to the <c> component of ICU library.
30 #]=======================================================================]
32 find_package(PkgConfig QUIET)
34 set(ICU_KNOWN_COMPONENTS "uc" "i18n" "le" "lx" "io" "data")
36 foreach(MOD_NAME IN LISTS ICU_FIND_COMPONENTS)
37     if(NOT MOD_NAME IN_LIST ICU_KNOWN_COMPONENTS)
38         message(FATAL_ERROR "Unknown ICU component: ${MOD_NAME}")
39     endif()
40     pkg_check_modules(PC_ICU_${MOD_NAME} QUIET icu-${MOD_NAME})
42     # Check the libraries returned by pkg-config really exist.
43     unset(PC_LIBRARIES)
44     foreach(LIBRARY IN LISTS PC_ICU_${MOD_NAME}_LIBRARIES)
45         unset(PC_LIBRARY CACHE)
46         find_library(PC_LIBRARY NAMES ${LIBRARY})
47         if(NOT PC_LIBRARY)
48             unset(PC_ICU_${MOD_NAME}_FOUND)
49         endif()
50         list(APPEND PC_LIBRARIES ${PC_LIBRARY})
51     endforeach()
52     unset(PC_LIBRARY CACHE)
54     if(${PC_ICU_${MOD_NAME}_FOUND})
55         set(ICU_COMPONENT_FOUND TRUE)
56         set(ICU_${MOD_NAME}_FOUND TRUE)
57         set(ICU_${MOD_NAME}_LIBRARIES ${PC_LIBRARIES})
58         set(ICU_${MOD_NAME}_INCLUDE_DIRS ${PC_ICU_${MOD_NAME}_INCLUDE_DIRS})
59         set(ICU_VERSION ${PC_ICU_${MOD_NAME}_VERSION})
60     endif()
61 endforeach()
63 include(FindPackageHandleStandardArgs)
64 find_package_handle_standard_args(ICU
65     FOUND_VAR ICU_FOUND
66     REQUIRED_VARS ICU_COMPONENT_FOUND
67     VERSION_VAR ICU_VERSION
68     HANDLE_COMPONENTS