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 if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
9 # Already in cache, be silent
10 set(GLIB2_FIND_QUIETLY TRUE)
11 endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
15 pkgconfig(glib-2.0 _LibGLIB2IncDir _LibGLIB2LinkDir _LibGLIB2LinkFlags _LibGLIB2Cflags)
18 find_path(GLIB2_MAIN_INCLUDE_DIR glib.h
19 PATH_SUFFIXES glib-2.0
20 PATHS ${_LibGLIB2IncDir} )
22 # search the glibconfig.h include dir under the same root where the library is found
23 find_library(GLIB2_LIBRARIES
25 PATHS ${_LibGLIB2LinkDir} )
27 get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH)
29 find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
30 PATH_SUFFIXES glib-2.0/include
31 PATHS ${_LibGLIB2IncDir} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
33 set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}")
35 # not sure if this include dir is optional or required
36 # for now it is optional
37 if(GLIB2_INTERNAL_INCLUDE_DIR)
38 set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}")
39 endif(GLIB2_INTERNAL_INCLUDE_DIR)
41 include(FindPackageHandleStandardArgs)
42 find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR)
44 mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES)