# - Find GLIB
# Find the native GLIB includes and library
#
#  GLIB_INCLUDE_DIR - where to find zlib.h, etc.
#  GLIB_LIBRARIES   - List of libraries when using zlib.
#  GLIB_FOUND       - True if zlib found.


IF (GLIB_INCLUDE_DIR)
  # Already in cache, be silent
  SET(GLIB_FIND_QUIETLY TRUE)
ENDIF (GLIB_INCLUDE_DIR)

FIND_PATH(GLIB_INCLUDE_DIR glib.h
		PATH_SUFFIXES glib-2.0
	)

SET(GLIB_NAMES glib-2.0)
FIND_LIBRARY(GLIB_LIBRARY NAMES ${GLIB_NAMES} )

FIND_PATH(GLIB_INTERNAL_INCLUDE_DIR glibconfig.h
  PATH_SUFFIXES glib-2.0/include PATHS ${CMAKE_SYSTEM_LIBRARY_PATH} ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})

# handle the QUIETLY and REQUIRED arguments and set GLIB_FOUND to TRUE if 
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB DEFAULT_MSG GLIB_LIBRARY GLIB_INCLUDE_DIR)

IF(NOT GLIB_INTERNAL_INCLUDE_DIR)
  SET(GLIB_FOUND FALSE)
ENDIF(NOT GLIB_INTERNAL_INCLUDE_DIR)

IF(GLIB_FOUND)
  SET( GLIB_LIBRARIES ${GLIB_LIBRARY} )
ELSE(GLIB_FOUND)
  SET( GLIB_LIBRARIES )
ENDIF(GLIB_FOUND)

MARK_AS_ADVANCED( GLIB_LIBRARY GLIB_INCLUDE_DIR )
