File: FindGObject.cmake

package info (click to toggle)
qt6-multimedia 6.10.2-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 43,900 kB
  • sloc: cpp: 186,273; ansic: 78,309; java: 2,870; python: 262; xml: 193; sh: 136; makefile: 30
file content (58 lines) | stat: -rw-r--r-- 1,867 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

# FindGObject
# ---------
#
# Try to locate the gobject-2.0 library.
# If found, this will define the following variables:
#
# ``GObject_FOUND``
#     True if the gobject-2.0 library is available
#
# If ``GObject_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``GObject::GObject``
#     The gobject-2.0 library

include(CMakeFindDependencyMacro)
find_dependency(GLIB2)
qt_internal_disable_find_package_global_promotion(GLIB2::GLIB2)

if(NOT TARGET GObject::GObject)
    find_package(PkgConfig QUIET)
    pkg_check_modules(PC_GOBJECT gobject-2.0 IMPORTED_TARGET)
    if(TARGET PkgConfig::PC_GOBJECT)
        add_library(GObject::GObject INTERFACE IMPORTED)
        target_link_libraries(GObject::GObject INTERFACE
                            PkgConfig::PC_GOBJECT
                            GLIB2::GLIB2
        )
    else()
        find_path(GObject_INCLUDE_DIR
            NAMES gobject.h
            PATH_SUFFIXES glib-2.0/gobject/
        )
        find_library(GObject_LIBRARY NAMES gobject-2.0)
        if(GObject_LIBRARY AND GObject_INCLUDE_DIR)
            add_library(GObject::GObject INTERFACE IMPORTED)
            target_include_directories(GObject::GObject INTERFACE
                                    ${GObject_INCLUDE_DIR}
            )
            target_link_libraries(GObject::GObject INTERFACE
                                ${GObject_LIBRARY}
                                GLIB2::GLIB2
            )
        endif()
        include(FindPackageHandleStandardArgs)
        find_package_handle_standard_args(GObject REQUIRED_VARS
                                        GObject_LIBRARY
                                        GObject_INCLUDE_DIR
    )
    endif()
endif()

if(TARGET GObject::GObject)
    set(GObject_FOUND TRUE)
endif()