Warning, /frameworks/extra-cmake-modules/find-modules/FindGLIB2.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2008 Laurent Montel <montel@kde.org>
0002 #
0003 # SPDX-License-Identifier: BSD-3-Clause
0004 
0005 #[=======================================================================[.rst:
0006 FindGLIB2
0007 ---------
0008 
0009 Try to locate the GLib2 library.
0010 If found, this will define the following variables:
0011 
0012 ``GLIB2_FOUND``
0013     True if the GLib2 library is available
0014 ``GLIB2_INCLUDE_DIRS``
0015     The GLib2 include directories
0016 ``GLIB2_LIBRARIES``
0017     The GLib2 libraries for linking
0018 ``GLIB2_INCLUDE_DIR``
0019     Deprecated, use ``GLIB2_INCLUDE_DIRS``
0020 ``GLIB2_LIBRARY``
0021     Deprecated, use ``GLIB2_LIBRARIES``
0022 
0023 If ``GLIB2_FOUND`` is TRUE, it will also define the following
0024 imported target:
0025 
0026 ``GLIB2::GLIB2``
0027     The GLIB2 library
0028 
0029 Since 5.41.0.
0030 #]=======================================================================]
0031 
0032 find_package(PkgConfig QUIET)
0033 pkg_check_modules(PC_GLIB2 QUIET glib-2.0)
0034 
0035 find_path(GLIB2_INCLUDE_DIRS
0036           NAMES glib.h
0037           HINTS ${PC_GLIB2_INCLUDEDIR}
0038           PATH_SUFFIXES glib-2.0)
0039 
0040 find_library(GLIB2_LIBRARIES
0041              NAMES glib-2.0
0042              HINTS ${PC_GLIB2_LIBDIR}
0043 )
0044 
0045 # search the glibconfig.h include dir under the same root where the library is found
0046 get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH)
0047 
0048 find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
0049           PATH_SUFFIXES glib-2.0/include
0050           HINTS ${PC_GLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
0051 
0052 # not sure if this include dir is optional or required
0053 # for now it is optional
0054 if(GLIB2_INTERNAL_INCLUDE_DIR)
0055   list(APPEND GLIB2_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}")
0056 endif()
0057 
0058 # Deprecated synonyms
0059 set(GLIB2_INCLUDE_DIR "${GLIB2_INCLUDE_DIRS}")
0060 set(GLIB2_LIBRARY "${GLIB2_LIBRARIES}")
0061 
0062 include(FindPackageHandleStandardArgs)
0063 find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_INCLUDE_DIRS)
0064 
0065 if(GLIB2_FOUND AND NOT TARGET GLIB2::GLIB2)
0066   add_library(GLIB2::GLIB2 UNKNOWN IMPORTED)
0067   set_target_properties(GLIB2::GLIB2 PROPERTIES
0068                         IMPORTED_LOCATION "${GLIB2_LIBRARIES}"
0069                         INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_INCLUDE_DIRS}")
0070 endif()
0071 
0072 mark_as_advanced(GLIB2_INCLUDE_DIRS GLIB2_INCLUDE_DIR
0073                  GLIB2_LIBRARIES GLIB2_LIBRARY)
0074 
0075 include(FeatureSummary)
0076 set_package_properties(GLIB2 PROPERTIES
0077   URL "https://wiki.gnome.org/Projects/GLib"
0078   DESCRIPTION "Event loop and utility library")