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 # HAVE_GLIB_GREGEX_H glib has gregex.h header and
9 # supports g_regex_match_simple
11 # Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
12 # Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com>
13 # Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
14 # Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com>
15 # Copyright (c) 2008 Michael Bell <michael.bell@web.de>
16 # Copyright (c) 2008 Bjoern Ricks <bjoern.ricks@googlemail.com>
18 # Redistribution and use is allowed according to the terms of the New
20 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
24 IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
27 ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
29 INCLUDE(FindPkgConfig)
32 IF ( GLIB2_FIND_REQUIRED )
33 SET( _pkgconfig_REQUIRED "REQUIRED" )
34 ELSE ( GLIB2_FIND_REQUIRED )
35 SET( _pkgconfig_REQUIRED "" )
36 ENDIF ( GLIB2_FIND_REQUIRED )
38 IF ( GLIB2_MIN_VERSION )
39 PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} )
40 ELSE ( GLIB2_MIN_VERSION )
41 PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 )
42 ENDIF ( GLIB2_MIN_VERSION )
43 IF ( PKG_CONFIG_FOUND )
45 SET ( GLIB2_CORE_FOUND TRUE )
47 SET ( GLIB2_CORE_FOUND FALSE )
49 ENDIF ( PKG_CONFIG_FOUND )
51 # Look for glib2 include dir and libraries w/o pkgconfig
52 IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
54 _glibconfig_include_DIR
85 #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}")
99 IF ( _glib2_include_DIR AND _glib2_link_DIR )
100 SET ( _glib2_FOUND TRUE )
101 ENDIF ( _glib2_include_DIR AND _glib2_link_DIR )
105 SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} )
106 SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} )
107 SET ( GLIB2_CORE_FOUND TRUE )
108 ELSE ( _glib2_FOUND )
109 SET ( GLIB2_CORE_FOUND FALSE )
110 ENDIF ( _glib2_FOUND )
112 # Handle dependencies
114 IF ( NOT LIBINTL_FOUND )
115 FIND_PATH(LIBINTL_INCLUDE_DIR
126 FIND_LIBRARY(LIBINTL_LIBRARY
137 IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
138 SET (LIBINTL_FOUND TRUE)
139 ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
140 ENDIF ( NOT LIBINTL_FOUND )
143 IF ( NOT LIBICONV_FOUND )
144 FIND_PATH(LIBICONV_INCLUDE_DIR
159 FIND_LIBRARY(LIBICONV_LIBRARY
170 IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
171 SET (LIBICONV_FOUND TRUE)
172 ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
173 ENDIF ( NOT LIBICONV_FOUND )
176 SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY})
177 SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR})
178 ENDIF (LIBINTL_FOUND)
181 SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY})
182 SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR})
183 ENDIF (LIBICONV_FOUND)
185 ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
188 IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
189 SET (GLIB2_FOUND TRUE)
190 ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
193 IF (NOT GLIB2_FIND_QUIETLY)
194 MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}")
195 ENDIF (NOT GLIB2_FIND_QUIETLY)
197 IF (GLIB2_FIND_REQUIRED)
198 MESSAGE (SEND_ERROR "Could not find GLib2")
199 ENDIF (GLIB2_FIND_REQUIRED)
202 # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view
203 MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES)
204 MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY)
205 MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY)
207 ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS)
210 # Check if system has a newer version of glib
211 # which supports g_regex_match_simple
212 INCLUDE( CheckIncludeFiles )
213 SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} )
214 CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H )
215 # Reset CMAKE_REQUIRED_INCLUDES
216 SET( CMAKE_REQUIRED_INCLUDES "" )