INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_GOBJECT_INTROSPECTION gobject-introspection-1.0)

IF(NOT GOBJECT_INTROSPECTION_INCLUDE_DIR)
    FIND_PATH(
        GOBJECT_INTROSPECTION_INCLUDE_DIR girffi.h
        HINTS $ENV{GOBJECT_INTROSPECTION_DIR}
              ${PC_GOBJECT_INTROSPECTION_INCLUDEDIR}
              ${PC_GOBJECT_INTROSPECTION_INCLUDE_DIRS}
        PATH_SUFFIXES gobject-introspection-1.0
    )
ENDIF()

IF(NOT GOBJECT_INTROSPECTION_LIBRARIES)
    FIND_LIBRARY(
        GOBJECT_INTROSPECTION_LIBRARIES girepository-1.0
        HINTS $ENV{GOBJECT_INTROSPECTION_DIR}
              ${PC_GOBJECT_INTROSPECTION_LIBS}
    )                  
ENDIF()

MARK_AS_ADVANCED(GOBJECT_INTROSPECTION_INCLUDE_DIR)
MARK_AS_ADVANCED(GOBJECT_INTROSPECTION_LIBRARIES)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(
    GObjectIntrospection
    DEFAULT_MSG
    GOBJECT_INTROSPECTION_LIBRARIES
    GOBJECT_INTROSPECTION_INCLUDE_DIR
)

