diff options
Diffstat (limited to 'project/cmake/modules/FindDBus.cmake')
| -rw-r--r-- | project/cmake/modules/FindDBus.cmake | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/project/cmake/modules/FindDBus.cmake b/project/cmake/modules/FindDBus.cmake new file mode 100644 index 0000000..2d64af4 --- /dev/null +++ b/project/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 | |||
| 17 | if(PKG_CONFIG_FOUND) | ||
| 18 | pkg_check_modules(PC_DBUS dbus-1 QUIET) | ||
| 19 | endif() | ||
| 20 | |||
| 21 | find_path(DBUS_INCLUDE_DIR NAMES dbus/dbus.h | ||
| 22 | PATH_SUFFIXES dbus-1.0 | ||
| 23 | PATHS ${PC_DBUS_INCLUDE_DIR}) | ||
| 24 | find_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}) | ||
| 28 | find_library(DBUS_LIBRARY NAMES dbus-1 | ||
| 29 | PATHS ${PC_DBUS_LIBDIR}) | ||
| 30 | |||
| 31 | set(DBUS_VERSION ${PC_DBUS_VERSION}) | ||
| 32 | |||
| 33 | include(FindPackageHandleStandardArgs) | ||
| 34 | find_package_handle_standard_args(DBus | ||
| 35 | REQUIRED_VARS DBUS_LIBRARY DBUS_INCLUDE_DIR DBUS_ARCH_INCLUDE_DIR | ||
| 36 | VERSION_VAR DBUS_VERSION) | ||
| 37 | |||
| 38 | if(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() | ||
| 50 | endif() | ||
| 51 | |||
| 52 | mark_as_advanced(DBUS_INCLUDE_DIR DBUS_LIBRARY) | ||
