2 # Once done this will define
4 # GLIB2_FOUND - system has GLib2
5 # GLIB2_INCLUDE_DIRS - the GLib2 include directory
6 # GLIB2_LIBRARIES - Link these to use GLib2
8 # Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
9 # Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com>
10 # Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
11 # Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com>
13 # Redistribution and use is allowed according to the terms of the New
15 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
19 if (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
22 else (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
24 include(FindPkgConfig)
27 IF ( GLIB2_FIND_REQUIRED )
28 SET( _pkgconfig_REQUIRED "REQUIRED" )
29 ELSE ( GLIB2_FIND_REQUIRED )
30 SET( _pkgconfig_REQUIRED "" )
31 ENDIF ( GLIB2_FIND_REQUIRED )
33 pkg_search_module( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 )
35 # Look for glib2 include dir and libraries w/o pkgconfig
36 IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
37 find_path(_glibconfig_include_DIR
41 /opt/gnome/lib64/glib-2.0/include
42 /opt/gnome/lib/glib-2.0/include
43 /opt/lib/glib-2.0/include
44 /opt/local/lib/glib-2.0/include
45 /sw/lib/glib-2.0/include
46 /usr/lib64/glib-2.0/include
47 /usr/lib/glib-2.0/include
48 /usr/local/include/glib-2.0
51 find_path(_glib2_include_DIR
55 /opt/gnome/include/glib-2.0
56 /opt/local/include/glib-2.0
59 /usr/local/include/glib-2.0
62 find_library( _glib2_link_DIR
72 IF ( _glib2_include_DIR AND _glib2_link_DIR )
73 SET ( _glib2_FOUND TRUE )
74 ENDIF ( _glib2_include_DIR AND _glib2_link_DIR )
78 SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} )
79 SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} )
80 ENDIF ( _glib2_FOUND )
84 IF ( NOT LIBINTL_FOUND )
85 find_path(LIBINTL_INCLUDE_DIR
97 find_library(LIBINTL_LIBRARY
109 if (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
110 set(LIBINTL_FOUND TRUE)
111 endif (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
112 ENDIF ( NOT LIBINTL_FOUND )
115 IF ( NOT LIBICONV_FOUND )
116 find_path(LIBICONV_INCLUDE_DIR
121 /opt/gnome/include/glib-2.0
122 /opt/local/include/glib-2.0
126 /usr/local/include/glib-2.0
127 /usr/include/glib-2.0
130 find_library(LIBICONV_LIBRARY
142 if (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
143 set(LIBICONV_FOUND TRUE)
144 endif (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
145 ENDIF ( NOT LIBICONV_FOUND )
148 set(GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY})
149 set(GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR})
150 endif (LIBINTL_FOUND)
153 set(GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY})
154 set(GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR})
155 endif (LIBICONV_FOUND)
157 ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
161 pkg_search_module(GMODULE2 gmodule-2.0 )
163 # Look for gmodule2 include dir and libraries w/o pkgconfig
164 IF ( NOT GMODULE2_FOUND AND NOT PKG_CONFIG_FOUND )
165 find_path( GMODULE2_INCLUDE_DIR
169 /opt/gnome/include/glib-2.0
170 /opt/local/include/glib-2.0
172 /usr/include/glib-2.0
173 /usr/local/include/glib-2.0
176 find_library( GMODULE2_LIBRARY
187 if (GMODULE2_LIBRARY AND GMODULE2_INCLUDE_DIR)
188 set(GMODULE2_FOUND TRUE)
189 endif (GMODULE2_LIBRARY AND GMODULE2_INCLUDE_DIR)
192 set(GMODULE2_INCLUDE_DIRS ${GMODULE2_INCLUDE_DIR})
193 set(GMODULE2_LIBRARIES ${GMODULE2_LIBRARY})
194 endif (GMODULE2_FOUND)
197 # Handle dependencies
198 # FIXME : glib2 - requires a split in different cmake modules and the user code to call the proper module instead of FindGLIB2 directly
200 ENDIF ( NOT GMODULE2_FOUND AND NOT PKG_CONFIG_FOUND )
204 pkg_search_module( GTHREAD2 gthread-2.0)
206 # Look for gthread2 include dir and libraries w/o pkgconfig
207 IF ( NOT GTHREAD2_FOUND AND NOT PKG_CONFIG_FOUND )
208 find_path(GTHREAD2_INCLUDE_DIR
212 /opt/gnome/include/glib-2.0
213 /opt/local/include/glib-2.0
215 /usr/include/glib-2.0
216 /usr/local/include/glib-2.0
221 find_library(GTHREAD2_LIBRARY
232 if (GTHREAD2_LIBRARY AND GTHREAD2_INCLUDE_DIR)
233 set(GTHREAD2_FOUND TRUE)
234 endif (GTHREAD2_LIBRARY AND GTHREAD2_INCLUDE_DIR)
237 set(GTHREAD2_INCLUDE_DIRS ${GTHREAD2_INCLUDE_DIR})
238 set(GTHREAD2_LIBRARIES ${GTHREAD2_LIBRARY})
239 endif (GTHREAD2_FOUND)
241 # Handle dependencies
242 # FIXME : glib2 - requires a split in different cmake modules and the user code to call the proper module instead of FindGLIB2 directly
244 ENDIF ( NOT GTHREAD2_FOUND AND NOT PKG_CONFIG_FOUND )
248 pkg_search_module( GOBJECT2 gobject-2.0)
250 # Look for gmodule2 include dir and libraries w/o pkgconfig
251 IF ( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND )
252 find_path(GOBJECT2_INCLUDE_DIR
256 /opt/gnome/include/glib-2.0
257 /opt/local/include/glib-2.0
259 /usr/include/glib-2.0
260 /usr/local/include/glib-2.0
265 find_library(GOBJECT2_LIBRARY
276 if (GOBJECT2_LIBRARY AND GOBJECT2_INCLUDE_DIR)
277 set(GOBJECT2_FOUND TRUE)
278 endif (GOBJECT2_LIBRARY AND GOBJECT2_INCLUDE_DIR)
281 set(GOBJECT2_INCLUDE_DIRS ${GOBJECT2_INCLUDE_DIR})
282 set(GOBJECT2_LIBRARIES ${GOBJECT2_LIBRARY})
283 endif (GOBJECT2_FOUND)
285 # Handle dependencies
286 # FIXME : glib2 - requires a split in different cmake modules and the user code to call the proper module instead of FindGLIB2 directly
288 ENDIF ( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND )
297 set(GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${GMODULE2_LIBRARIES})
298 set(GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GMODULE2_INCLUDE_DIRS})
299 endif (GMODULE2_FOUND)
302 set(GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${GTHREAD2_LIBRARIES})
303 set(GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GTHREAD2_INCLUDE_DIRS})
304 endif (GTHREAD2_FOUND)
307 set(GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARY})
308 set(GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GOBJECT2_INCLUDE_DIR})
309 endif (GOBJECT2_FOUND)
311 if (GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
312 set(GLIB2_FOUND TRUE)
313 endif (GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
316 if (NOT GLIB2_FIND_QUIETLY)
317 message(STATUS "Found GLib2: ${GLIB2_LIBRARIES}")
318 endif (NOT GLIB2_FIND_QUIETLY)
320 if (GLIB2_FIND_REQUIRED)
321 message(SEND_ERROR "Could not find GLib2")
322 endif (GLIB2_FIND_REQUIRED)
325 # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view
326 mark_as_advanced(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES)
327 mark_as_advanced(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY)
328 mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY)
330 # same for all other variables
331 mark_as_advanced(GMODULE2_INCLUDE_DIR GMODULE2_LIBRARY)
332 mark_as_advanced(GMODULE2_INCLUDE_DIRS GMODULE2_LIBRARIES)
333 mark_as_advanced(GOBJECT2_INCLUDE_DIR GOBJECT2_LIBRARY)
334 mark_as_advanced(GOBJECT2_INCLUDE_DIRS GOBJECT2_LIBRARIES)
335 mark_as_advanced(GTHREAD2_INCLUDE_DIR GTHREAD2_LIBRARY)
336 mark_as_advanced(GTHREAD2_INCLUDE_DIRS GTHREAD2_LIBRARIES)
338 endif (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS)