diff options
Diffstat (limited to 'project/cmake/modules/FindUDEV.cmake')
| -rw-r--r-- | project/cmake/modules/FindUDEV.cmake | 47 |
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 | |||
| 17 | if(PKG_CONFIG_FOUND) | ||
| 18 | pkg_check_modules(PC_UDEV libudev QUIET) | ||
| 19 | endif() | ||
| 20 | |||
| 21 | find_path(UDEV_INCLUDE_DIR NAMES libudev.h | ||
| 22 | PATHS ${PC_UDEV_INCLUDEDIR}) | ||
| 23 | find_library(UDEV_LIBRARY NAMES udev | ||
| 24 | PATHS ${PC_UDEV_LIBDIR}) | ||
| 25 | |||
| 26 | set(UDEV_VERSION ${PC_UDEV_VERSION}) | ||
| 27 | |||
| 28 | include(FindPackageHandleStandardArgs) | ||
| 29 | find_package_handle_standard_args(UDEV | ||
| 30 | REQUIRED_VARS UDEV_LIBRARY UDEV_INCLUDE_DIR | ||
| 31 | VERSION_VAR UDEV_VERSION) | ||
| 32 | |||
| 33 | if(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() | ||
| 45 | endif() | ||
| 46 | |||
| 47 | mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBRARY) | ||
