The open source OpenXR runtime
1# - try to find the udev library
2#
3# Cache Variables: (probably not for direct use in your scripts)
4# UDEV_INCLUDE_DIR
5# UDEV_SOURCE_DIR
6# UDEV_LIBRARY
7#
8# Non-cache variables you might use in your CMakeLists.txt:
9# UDEV_FOUND
10# UDEV_INCLUDE_DIRS
11# UDEV_LIBRARIES
12#
13# Requires these CMake modules:
14# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
15#
16# Original Authors:
17# 2014, Kevin M. Godby <kevin@godby.org>
18# 2021, Rylie Pavlik <rylie.pavlik@collabora.com> <rylie@ryliepavlik.com>
19#
20# Copyright 2014, Kevin M. Godby <kevin@godby.org>
21# Copyright 2021, Collabora, Ltd.
22#
23# SPDX-License-Identifier: BSL-1.0
24#
25# Distributed under the Boost Software License, Version 1.0.
26# (See accompanying file LICENSE_1_0.txt or copy at
27# http://www.boost.org/LICENSE_1_0.txt)
28
29set(UDEV_ROOT_DIR
30 "${UDEV_ROOT_DIR}"
31 CACHE
32 PATH
33 "Directory to search for udev")
34
35if(NOT ANDROID)
36 find_package(PkgConfig QUIET)
37 if(PKG_CONFIG_FOUND)
38 pkg_check_modules(PC_LIBUDEV QUIET libudev)
39 endif()
40endif()
41
42find_library(UDEV_LIBRARY
43 NAMES
44 udev
45 PATHS
46 ${PC_LIBUDEV_LIBRARY_DIRS}
47 ${PC_LIBUDEV_LIBDIR}
48 HINTS
49 "${UDEV_ROOT_DIR}"
50 PATH_SUFFIXES
51 lib
52 )
53
54get_filename_component(_libdir "${UDEV_LIBRARY}" PATH)
55
56find_path(UDEV_INCLUDE_DIR
57 NAMES
58 libudev.h
59 PATHS
60 ${PC_LIBUDEV_INCLUDE_DIRS}
61 ${PC_LIBUDEV_INCLUDEDIR}
62 HINTS
63 "${_libdir}"
64 "${_libdir}/.."
65 "${UDEV_ROOT_DIR}"
66 PATH_SUFFIXES
67 include
68 )
69
70include(FindPackageHandleStandardArgs)
71find_package_handle_standard_args(udev
72 DEFAULT_MSG
73 UDEV_LIBRARY
74 UDEV_INCLUDE_DIR
75 )
76
77if(UDEV_FOUND)
78 list(APPEND UDEV_LIBRARIES ${UDEV_LIBRARY})
79 list(APPEND UDEV_INCLUDE_DIRS ${UDEV_INCLUDE_DIR})
80 mark_as_advanced(UDEV_ROOT_DIR)
81endif()
82
83mark_as_advanced(UDEV_INCLUDE_DIR
84 UDEV_LIBRARY)
85