1 # - Try to find the GLIB2 libraries
2 # Once done this will define
4 # GLIB2_FOUND - system has glib2
5 # GLIB2_INCLUDE_DIR - the glib2 include directory
6 # GLIB2_LIBRARIES - glib2 library
8 # Copyright (c) 2008 Laurent Montel, <montel@kde.org>
10 # Redistribution and use is allowed according to the terms of the BSD license.
11 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
15 # Already in cache, be silent
16 set(GLIB2_FIND_QUIETLY TRUE)
17 endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
20 find_package(PkgConfig REQUIRED)
21 pkg_check_modules(PKG_GLIB REQUIRED glib-2.0)
24 find_path(GLIB2_MAIN_INCLUDE_DIR glib.h
25 PATH_SUFFIXES glib-2.0
26 HINTS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_INCLUDEDIR})
28 # search the glibconfig.h include dir under the same root where the library is found
29 find_library(GLIB2_LIBRARIES
31 HINTS ${PKG_GLIB_LIBRARY_DIRS} ${PKG_GLIB_LIBDIR})
33 find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
34 PATH_SUFFIXES glib-2.0/include ../lib/glib-2.0/include
35 HINTS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_LIBRARIES} ${CMAKE_SYSTEM_LIBRARY_PATH})
37 set(GLIB2_INCLUDE_DIR ${GLIB2_MAIN_INCLUDE_DIR})
39 # not sure if this include dir is optional or required
40 # for now it is optional
41 if(GLIB2_INTERNAL_INCLUDE_DIR)
42 set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR})
43 endif(GLIB2_INTERNAL_INCLUDE_DIR)
45 include(FindPackageHandleStandardArgs)
46 find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR)
48 mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES)