Home | History | Annotate | Download | only in cmake
      1 # - Try to find Glib-2.0 (with gobject)
      2 # Once done, this will define
      3 #
      4 #  Glib_FOUND - system has Glib
      5 #  Glib_INCLUDE_DIRS - the Glib include directories
      6 #  Glib_LIBRARIES - link these to use Glib
      7 
      8 include(LibFindMacros)
      9 
     10 # Use pkg-config to get hints about paths
     11 libfind_pkg_check_modules(Glib_PKGCONF glib-2.0)
     12 
     13 # Main include dir
     14 find_path(Glib_INCLUDE_DIR
     15   NAMES glib.h
     16   PATHS ${Glib_PKGCONF_INCLUDE_DIRS}
     17   PATH_SUFFIXES glib-2.0
     18 )
     19 
     20 # Glib-related libraries also use a separate config header, which is in lib dir
     21 find_path(GlibConfig_INCLUDE_DIR
     22   NAMES glibconfig.h
     23   PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr
     24   PATH_SUFFIXES lib/glib-2.0/include
     25 )
     26 
     27 # Finally the library itself
     28 find_library(Glib_LIBRARY
     29   NAMES glib-2.0
     30   PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
     31 )
     32 find_library(Gobject_LIBRARY
     33   NAMES gobject-2.0
     34   PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
     35 )
     36 
     37 # Set the include dir variables and the libraries and let libfind_process do the rest.
     38 # NOTE: Singular variables for this library, plural for libraries this this lib depends on.
     39 set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR)
     40 set(Glib_PROCESS_LIBS Glib_LIBRARY Gobject_LIBRARY)
     41 libfind_process(Glib)
     42 
     43 
     44