summaryrefslogtreecommitdiffstats
path: root/project/cmake/modules/FindUDEV.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/modules/FindUDEV.cmake')
-rw-r--r--project/cmake/modules/FindUDEV.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/project/cmake/modules/FindUDEV.cmake b/project/cmake/modules/FindUDEV.cmake
new file mode 100644
index 0000000..422c437
--- /dev/null
+++ b/project/cmake/modules/FindUDEV.cmake
@@ -0,0 +1,47 @@
1#.rst:
2# FindUDEV
3# -------
4# Finds the UDEV library
5#
6# This will will define the following variables::
7#
8# UDEV_FOUND - system has UDEV
9# UDEV_INCLUDE_DIRS - the UDEV include directory
10# UDEV_LIBRARIES - the UDEV libraries
11# UDEV_DEFINITIONS - the UDEV definitions
12#
13# and the following imported targets::
14#
15# UDEV::UDEV - The UDEV library
16
17if(PKG_CONFIG_FOUND)
18 pkg_check_modules(PC_UDEV libudev QUIET)
19endif()
20
21find_path(UDEV_INCLUDE_DIR NAMES libudev.h
22 PATHS ${PC_UDEV_INCLUDEDIR})
23find_library(UDEV_LIBRARY NAMES udev
24 PATHS ${PC_UDEV_LIBDIR})
25
26set(UDEV_VERSION ${PC_UDEV_VERSION})
27
28include(FindPackageHandleStandardArgs)
29find_package_handle_standard_args(UDEV
30 REQUIRED_VARS UDEV_LIBRARY UDEV_INCLUDE_DIR
31 VERSION_VAR UDEV_VERSION)
32
33if(UDEV_FOUND)
34 set(UDEV_LIBRARIES ${UDEV_LIBRARY})
35 set(UDEV_INCLUDE_DIRS ${UDEV_INCLUDE_DIR})
36 set(UDEV_DEFINITIONS -DHAVE_LIBUDEV=1)
37
38 if(NOT TARGET UDEV::UDEV)
39 add_library(UDEV::UDEV UNKNOWN IMPORTED)
40 set_target_properties(UDEV::UDEV PROPERTIES
41 IMPORTED_LOCATION "${UDEV_LIBRARY}"
42 INTERFACE_INCLUDE_DIRECTORIES "${UDEV_INCLUDE_DIR}"
43 INTERFACE_COMPILE_DEFINITIONS HAVE_LIBUDEV=1)
44 endif()
45endif()
46
47mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBRARY)