Debian Codegraph @

CMakeModules/FindDBus.cmake

raw
1 # Finding dbus (https://www.freedesktop.org/wiki/Software/dbus/)
2 # Defining:
3 # DBUS_LIBRARY
4 # DBUS_INCLUDE_DIR
5
6 set(dbus_target "_no_target_")
7
8 if(WIN32 OR APPLE)
9 FIND_PATH(DBUS_INCLUDE_DIRS dbus/dbus.h
10 PATH_SUFFIXES include include/dbus-1.0
11 HINTS ${ADDITIONAL_LIBRARY_PATHS})
12
13 find_path(arch_deps dbus/dbus-arch-deps.h
14 NO_DEFAULT_PATH
15 PATHS ${DBUS_INCLUDE_DIRS})
16
17 if (NOT arch_deps)
18 message(STATUS "Looking for dbus-arch-deps.h in lib/ prefix")
19
20 FIND_PATH(DBUS_LIB_INCLUDE_DIRS dbus/dbus-arch-deps.h
21 PATH_SUFFIXES lib/dbus-1.0/include
22 HINTS ${ADDITIONAL_LIBRARY_PATHS})
23
24 if (NOT DBUS_LIB_INCLUDE_DIRS)
25 message(STATUS "Couldn't find DBus dbus/dbus-arch-deps.h header")
26 # fail the check below by clearing the include dirs variable
27 unset(DBUS_INCLUDE_DIRS CACHE)
28 endif()
29 endif()
30
31 FIND_LIBRARY(DBUS_LIBRARIES NAMES dbus-1
32 PATH_SUFFIXES lib
33 HINTS ${ADDITIONAL_LIBRARY_PATHS})
34
35 # define an imported target for DBus manually
36 if (DBUS_INCLUDE_DIRS AND DBUS_LIBRARIES)
37 add_library(DBus UNKNOWN IMPORTED)
38 set_target_properties(DBus PROPERTIES
39 INTERFACE_INCLUDE_DIRECTORIES "${DBUS_INCLUDE_DIRS}"
40 IMPORTED_LOCATION "${DBUS_LIBRARIES}"
41 )
42
43 if (DBUS_LIB_INCLUDE_DIRS)
44 set_property(TARGET DBus APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${DBUS_LIB_INCLUDE_DIRS}")
45 endif()
46
47 set(HAVE_DBUS 1)
48 set(dbus_target "DBus")
49 endif()
50 else()
51 find_package(PkgConfig QUIET)
52
53 if(PKG_CONFIG_FOUND)
54 pkg_check_modules(DBUS IMPORTED_TARGET dbus-1)
55 endif (PKG_CONFIG_FOUND)
56
57 if(DBUS_FOUND)
58 set(HAVE_DBUS 1)
59
60 # can't use an ALIAS here, needs CMake 3.11
61 # use a global property instead
62 set(dbus_target "PkgConfig::DBUS")
63 endif(DBUS_FOUND)
64 endif()