Fix when statically linking with distro's boost: in this case, we most likely also...
[blender.git] / build_files / cmake / Modules / FindIcuLinux.cmake
1 # - Find static icu libraries
2 # Find the native static icu libraries (needed for static boost_locale :/ ).
3 # This module defines
4 #  ICU_LIBRARIES, libraries to link against to use icu.
5 #  ICU_ROOT_DIR, The base directory to search for icu.
6 #                    This can also be an environment variable.
7 #  ICU_FOUND, If false, do not try to use icu.
8 #
9 # also defined, but not for general use are
10 #  ICU_LIBRARY_xxx, where to find the icu libraries.
11
12 #=============================================================================
13 # Copyright 2012 Blender Foundation.
14 #
15 # Distributed under the OSI-approved BSD License (the "License");
16 # see accompanying file Copyright.txt for details.
17 #
18 # This software is distributed WITHOUT ANY WARRANTY; without even the
19 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 # See the License for more information.
21 #=============================================================================
22
23 # If ICU_ROOT_DIR was defined in the environment, use it.
24 IF(NOT ICU_ROOT_DIR AND NOT $ENV{ICU_ROOT_DIR} STREQUAL "")
25   SET(ICU_ROOT_DIR $ENV{ICU_ROOT_DIR})
26 ENDIF()
27
28 if(Boost_USE_STATIC_LIBS)
29   set(_icu_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
30   set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
31 endif()
32
33 SET(_icu_SEARCH_DIRS
34   ${ICU_ROOT_DIR}
35   /usr/local
36   /sw # Fink
37   /opt/local # DarwinPorts
38   /opt/csw # Blastwave
39 )
40
41 # We don't need includes, only libs to link against...
42 #FIND_PATH(ICU_INCLUDE_DIR
43 #  NAMES
44 #    utf.h
45 #  HINTS
46 #    ${_icu_SEARCH_DIRS}
47 #  PATH_SUFFIXES
48 #    include/unicode
49 #)
50
51 FIND_LIBRARY(ICU_LIBRARY_DATA
52   NAMES
53     icudata
54   HINTS
55     ${_icu_SEARCH_DIRS}
56   PATH_SUFFIXES
57     lib64 lib
58   )
59
60 FIND_LIBRARY(ICU_LIBRARY_I18N
61   NAMES
62     icui18n
63   HINTS
64     ${_icu_SEARCH_DIRS}
65   PATH_SUFFIXES
66     lib64 lib
67   )
68
69 FIND_LIBRARY(ICU_LIBRARY_IO
70   NAMES
71     icuio
72   HINTS
73     ${_icu_SEARCH_DIRS}
74   PATH_SUFFIXES
75     lib64 lib
76   )
77
78 FIND_LIBRARY(ICU_LIBRARY_LE
79   NAMES
80     icule
81   HINTS
82     ${_icu_SEARCH_DIRS}
83   PATH_SUFFIXES
84     lib64 lib
85   )
86
87 FIND_LIBRARY(ICU_LIBRARY_LX
88   NAMES
89     iculx
90   HINTS
91     ${_icu_SEARCH_DIRS}
92   PATH_SUFFIXES
93     lib64 lib
94   )
95
96 FIND_LIBRARY(ICU_LIBRARY_TU
97   NAMES
98     icutu
99   HINTS
100     ${_icu_SEARCH_DIRS}
101   PATH_SUFFIXES
102     lib64 lib
103   )
104
105 FIND_LIBRARY(ICU_LIBRARY_UC
106   NAMES
107     icuuc
108   HINTS
109     ${_icu_SEARCH_DIRS}
110   PATH_SUFFIXES
111     lib64 lib
112   )
113
114 # Restore the original find library ordering
115 if(Boost_USE_STATIC_LIBS)
116   set(CMAKE_FIND_LIBRARY_SUFFIXES ${_icu_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
117 endif()
118
119 # handle the QUIETLY and REQUIRED arguments and set ICU_FOUND to TRUE if 
120 # all listed variables are TRUE
121 INCLUDE(FindPackageHandleStandardArgs)
122 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Icu DEFAULT_MSG
123     ICU_LIBRARY_DATA
124     ICU_LIBRARY_I18N
125     ICU_LIBRARY_IO
126     ICU_LIBRARY_LE
127     ICU_LIBRARY_LX
128     ICU_LIBRARY_TU
129     ICU_LIBRARY_UC
130 )
131
132 IF(ICU_FOUND)
133   SET(ICU_LIBRARIES ${ICU_LIBRARY_DATA} ${ICU_LIBRARY_I18N} ${ICU_LIBRARY_IO} ${ICU_LIBRARY_LE} ${ICU_LIBRARY_LX} ${ICU_LIBRARY_TU} ${ICU_LIBRARY_UC})
134   SET(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
135 ENDIF(ICU_FOUND)
136
137 MARK_AS_ADVANCED(
138   ICU_INCLUDE_DIR
139   ICU_LIBRARY_DATA
140   ICU_LIBRARY_I18N
141   ICU_LIBRARY_IO
142   ICU_LIBRARY_LE
143   ICU_LIBRARY_LX
144   ICU_LIBRARY_TU
145   ICU_LIBRARY_UC
146 )