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..df3edc5
--- /dev/null
+++ b/cmake/modules/FindDBus.cmake
@@ -0,0 +1,52 @@
+#.rst:
+# FindDBUS
+# -------
+# Finds the DBUS library
+#
+# This will define the following variables::
+#
+# DBUS_FOUND - system has DBUS
+# DBUS_INCLUDE_DIRS - the DBUS include directory
+# DBUS_LIBRARIES - the DBUS libraries
+# DBUS_DEFINITIONS - the DBUS definitions
+#
+# and the following imported targets::
+#
+# DBus::DBus - The DBUS library
+
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_DBUS dbus-1 QUIET)
+endif()
+
+find_path(DBUS_INCLUDE_DIR NAMES dbus/dbus.h
+ PATH_SUFFIXES dbus-1.0
+ PATHS ${PC_DBUS_INCLUDE_DIR})
+find_path(DBUS_ARCH_INCLUDE_DIR NAMES dbus/dbus-arch-deps.h
+ PATH_SUFFIXES dbus-1.0/include
+ PATHS ${PC_DBUS_LIBDIR}
+ /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
+find_library(DBUS_LIBRARY NAMES dbus-1
+ PATHS ${PC_DBUS_LIBDIR})
+
+set(DBUS_VERSION ${PC_DBUS_VERSION})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(DBus
+ REQUIRED_VARS DBUS_LIBRARY DBUS_INCLUDE_DIR DBUS_ARCH_INCLUDE_DIR
+ VERSION_VAR DBUS_VERSION)
+
+if(DBUS_FOUND)
+ set(DBUS_LIBRARIES ${DBUS_LIBRARY})
+ set(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
+ set(DBUS_DEFINITIONS -DHAS_DBUS=1)
+
+ if(NOT TARGET DBus::DBus)
+ add_library(DBus::DBus UNKNOWN IMPORTED)
+ set_target_properties(DBus::DBus PROPERTIES
+ IMPORTED_LOCATION "${DBUS_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${DBUS_INCLUDE_DIR}"
+ INTERFACE_COMPILE_DEFINITIONS HAS_DBUS=1)
+ endif()
+endif()
+
+mark_as_advanced(DBUS_INCLUDE_DIR DBUS_LIBRARY)