find_package(PkgConfig REQUIRED)

pkg_search_module(GLIB2 REQUIRED glib-2.0)
#message(STATUS "GLIB2_LIBRARIES ${GLIB2_LIBRARIES}")
message(STATUS "GLIB2_LIBRARY_DIRS ${GLIB2_LIBRARY_DIRS}")
#message(STATUS "GLIB2_LDFLAGS ${GLIB2_LDFLAGS}")
#message(STATUS "GLIB2_LDFLAGS_OTHER ${GLIB2_LDFLAGS_OTHER}")
message(STATUS "GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS}")
#message(STATUS "GLIB2_CFLAGS ${GLIB2_CFLAGS}")
#message(STATUS "GLIB2_CFLAGS_OTHER ${GLIB2_CFLAGS_OTHER}")
message(STATUS "GLIB2_LIBDIR ${GLIB2_LIBDIR}")

set(GLIB2_DEFINITIONS ${GLIB2_CFLAGS_OTHER})
#message(STATUS "GLIB2_DEFINITIONS ${GLIB2_DEFINITIONS}")

set(GLIB2_LIBRARY_NAMES ${GLIB2_LIBRARIES})
set(GLIB2_LIBRARIES "")
foreach(GLIB2_LIB ${GLIB2_LIBRARY_NAMES})
#  message(STATUS "lib: ${GLIB2_LIB}")
  set(TMP TMP-NOTFOUND)
  find_library(TMP NAMES ${GLIB2_LIB}
               PATHS ${GLIB2_LIBRARY_DIRS}
               PATHS ${GLIB2_LIBDIR}
               NO_DEFAULT_PATH)
#  message(STATUS "TMP: ${TMP}")
  list(APPEND GLIB2_LIBRARIES "${TMP}")
endforeach()
message(STATUS "GLIB2_LIBRARIES: ${GLIB2_LIBRARIES}")
