summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindDBus.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/FindDBus.cmake')
-rw-r--r--cmake/modules/FindDBus.cmake52
1 files changed, 52 insertions, 0 deletions
diff --git a/cmake/modules/FindDBus.cmake b/cmake/modules/FindDBus.cmake
new file mode 100644
index 0000000..2d64af4
--- /dev/null
+++ b/cmake/modules/FindDBus.cmake
@@ -0,0 +1,52 @@
1#.rst:
2# FindDBUS
3# -------
4# Finds the DBUS library
5#
6# This will will define the following variables::
7#
8# DBUS_FOUND - system has DBUS
9# DBUS_INCLUDE_DIRS - the DBUS include directory
10# DBUS_LIBRARIES - the DBUS libraries
11# DBUS_DEFINITIONS - the DBUS definitions
12#
13# and the following imported targets::
14#
15# DBus::DBus - The DBUS library
16
17if(PKG_CONFIG_FOUND)
18 pkg_check_modules(PC_DBUS dbus-1 QUIET)
19endif()
20
21find_path(DBUS_INCLUDE_DIR NAMES dbus/dbus.h
22 PATH_SUFFIXES dbus-1.0
23 PATHS ${PC_DBUS_INCLUDE_DIR})
24find_path(DBUS_ARCH_INCLUDE_DIR NAMES dbus/dbus-arch-deps.h
25 PATH_SUFFIXES dbus-1.0/include
26 PATHS ${PC_DBUS_LIBDIR}
27 /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
28find_library(DBUS_LIBRARY NAMES dbus-1
29 PATHS ${PC_DBUS_LIBDIR})
30
31set(DBUS_VERSION ${PC_DBUS_VERSION})
32
33include(FindPackageHandleStandardArgs)
34find_package_handle_standard_args(DBus
35 REQUIRED_VARS DBUS_LIBRARY DBUS_INCLUDE_DIR DBUS_ARCH_INCLUDE_DIR
36 VERSION_VAR DBUS_VERSION)
37
38if(DBUS_FOUND)
39 set(DBUS_LIBRARIES ${DBUS_LIBRARY})
40 set(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
41 set(DBUS_DEFINITIONS -DHAVE_DBUS=1)
42
43 if(NOT TARGET DBus::DBus)
44 add_library(DBus::DBus UNKNOWN IMPORTED)
45 set_target_properties(DBus::DBus PROPERTIES
46 IMPORTED_LOCATION "${DBUS_LIBRARY}"
47 INTERFACE_INCLUDE_DIRECTORIES "${DBUS_INCLUDE_DIR}"
48 INTERFACE_COMPILE_DEFINITIONS HAVE_DBUS=1)
49 endif()
50endif()
51
52mark_as_advanced(DBUS_INCLUDE_DIR DBUS_LIBRARY)