| 1 |
# - Try to find the GLIB2 libraries |
| 2 |
# Once done this will define |
| 3 |
# |
| 4 |
# GLIB2_FOUND - system has glib2 |
| 5 |
# GLIB2_INCLUDE_DIR - the glib2 include directory |
| 6 |
# GLIB2_LIBRARIES - glib2 library |
| 7 |
|
| 8 |
# Copyright (c) 2008 Laurent Montel, <[email protected]> |
| 9 |
# Copyright (c) 2013 Ralf Habacker, <[email protected]> |
| 10 |
# SPDX-License-Identifier: LicenseRef-CMakeScripts |
| 11 |
# |
| 12 |
# Redistribution and use is allowed according to the terms of the BSD license. |
| 13 |
# For details see LICENSES/LicenseRef-CMakeScripts.txt. |
| 14 |
|
| 15 |
|
| 16 |
if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) |
| 17 |
# Already in cache, be silent |
| 18 |
set(GLIB2_FIND_QUIETLY TRUE) |
| 19 |
endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) |
| 20 |
|
| 21 |
if (NOT WIN32) |
| 22 |
find_package(PkgConfig) |
| 23 |
pkg_check_modules(PC_LibGLIB2 QUIET glib-2.0) |
| 24 |
endif() |
| 25 |
|
| 26 |
find_path(GLIB2_MAIN_INCLUDE_DIR |
| 27 |
NAMES glib.h |
| 28 |
HINTS ${PC_LibGLIB2_INCLUDEDIR} |
| 29 |
PATH_SUFFIXES glib-2.0) |
| 30 |
|
| 31 |
find_library(GLIB2_LIBRARY |
| 32 |
NAMES glib-2.0 |
| 33 |
HINTS ${PC_LibGLIB2_LIBDIR} |
| 34 |
) |
| 35 |
|
| 36 |
find_library(GOBJECT2_LIBRARY |
| 37 |
NAMES gobject-2.0 |
| 38 |
HINTS ${PC_LibGLIB2_LIBDIR} |
| 39 |
) |
| 40 |
|
| 41 |
find_library(GIO2_LIBRARY |
| 42 |
NAMES gio-2.0 |
| 43 |
HINTS ${PC_LibGLIB2_LIBDIR} |
| 44 |
) |
| 45 |
|
| 46 |
set(GLIB2_LIBRARIES ${GLIB2_LIBRARY} ${GOBJECT2_LIBRARY} ${GIO2_LIBRARY}) |
| 47 |
|
| 48 |
# search the glibconfig.h include dir under the same root where the library is found |
| 49 |
get_filename_component(glib2LibDir "${GLIB2_LIBRARY}" PATH) |
| 50 |
|
| 51 |
find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h |
| 52 |
PATH_SUFFIXES glib-2.0/include |
| 53 |
HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) |
| 54 |
|
| 55 |
set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}") |
| 56 |
|
| 57 |
# not sure if this include dir is optional or required |
| 58 |
# for now it is optional |
| 59 |
if(GLIB2_INTERNAL_INCLUDE_DIR) |
| 60 |
set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}") |
| 61 |
endif(GLIB2_INTERNAL_INCLUDE_DIR) |
| 62 |
|
| 63 |
include(FindPackageHandleStandardArgs) |
| 64 |
find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) |
| 65 |
|
| 66 |
mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) |