Changeset View
Changeset View
Standalone View
Standalone View
cmake/FindGObject.cmake
- This file was added.
1 | # FindGObject.cmake | ||||
---|---|---|---|---|---|
2 | # <https://github.com/nemequ/gnome-cmake> | ||||
3 | # | ||||
4 | # CMake support for GObject. | ||||
5 | # | ||||
6 | # License: | ||||
7 | # | ||||
8 | # Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> | ||||
9 | # | ||||
10 | # Permission is hereby granted, free of charge, to any person | ||||
11 | # obtaining a copy of this software and associated documentation | ||||
12 | # files (the "Software"), to deal in the Software without | ||||
13 | # restriction, including without limitation the rights to use, copy, | ||||
14 | # modify, merge, publish, distribute, sublicense, and/or sell copies | ||||
15 | # of the Software, and to permit persons to whom the Software is | ||||
16 | # furnished to do so, subject to the following conditions: | ||||
17 | # | ||||
18 | # The above copyright notice and this permission notice shall be | ||||
19 | # included in all copies or substantial portions of the Software. | ||||
20 | # | ||||
21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
23 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
24 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||||
25 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||||
26 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
27 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||||
28 | # DEALINGS IN THE SOFTWARE. | ||||
29 | | ||||
30 | find_package(PkgConfig) | ||||
31 | | ||||
32 | set(GObject_DEPS | ||||
33 | GLib) | ||||
34 | | ||||
35 | if(PKG_CONFIG_FOUND) | ||||
36 | pkg_search_module(GObject_PKG gobject-2.0) | ||||
37 | endif() | ||||
38 | | ||||
39 | find_library(GObject_LIBRARY gobject-2.0 HINTS ${GObject_PKG_LIBRARY_DIRS}) | ||||
40 | set(GObject gobject-2.0) | ||||
41 | | ||||
42 | if(GObject_LIBRARY AND NOT GObject_FOUND) | ||||
43 | add_library(${GObject} SHARED IMPORTED) | ||||
44 | set_property(TARGET ${GObject} PROPERTY IMPORTED_LOCATION "${GObject_LIBRARY}") | ||||
45 | set_property(TARGET ${GObject} PROPERTY INTERFACE_COMPILE_OPTIONS "${GObject_PKG_CFLAGS_OTHER}") | ||||
46 | | ||||
47 | find_path(GObject_INCLUDE_DIR "gobject/gobject.h" | ||||
48 | HINTS ${GObject_PKG_INCLUDE_DIRS}) | ||||
49 | | ||||
50 | find_package(GLib) | ||||
51 | set(GObject_VERSION "${GLib_VERSION}") | ||||
52 | | ||||
53 | list(APPEND GObject_DEPS_FOUND_VARS "GLib_FOUND") | ||||
54 | list(APPEND GObject_INCLUDE_DIRS ${GLib_INCLUDE_DIRS}) | ||||
55 | set_property(TARGET ${GObject} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GObject_INCLUDE_DIR}") | ||||
56 | | ||||
57 | set_property (TARGET "${GObject}" APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${GLib}") | ||||
58 | endif() | ||||
59 | | ||||
60 | find_program(GLib_GENMARSHAL glib-genmarshal) | ||||
61 | if(GLib_GENMARSHAL AND NOT GLib_FOUND) | ||||
62 | add_executable(glib-genmarshal IMPORTED) | ||||
63 | set_property(TARGET glib-genmarshal PROPERTY IMPORTED_LOCATION "${GLib_GENMARSHAL}") | ||||
64 | endif() | ||||
65 | | ||||
66 | find_program(GLib_MKENUMS glib-mkenums) | ||||
67 | if(GLib_MKENUMS AND NOT GLib_FOUND) | ||||
68 | add_executable(glib-mkenums IMPORTED) | ||||
69 | set_property(TARGET glib-mkenums PROPERTY IMPORTED_LOCATION "${GLib_MKENUMS}") | ||||
70 | endif() | ||||
71 | | ||||
72 | include(FindPackageHandleStandardArgs) | ||||
73 | find_package_handle_standard_args(GObject | ||||
74 | REQUIRED_VARS | ||||
75 | GObject_LIBRARY | ||||
76 | GObject_INCLUDE_DIRS | ||||
77 | ${GObject_DEPS_FOUND_VARS} | ||||
78 | VERSION_VAR | ||||
79 | GObject_VERSION) | ||||
80 | | ||||
81 | unset(GObject_DEPS_FOUND_VARS) |