kdelibs/cmake/modules/FindUDev.cmake
Ivailo Monev 8c6c2f1384 cmake: modules review
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2021-03-07 02:40:21 +02:00

40 lines
1.3 KiB
CMake

# Try to find UDev, once done this will define:
#
# UDEV_FOUND - system has UDev
# UDEV_INCLUDE_DIR - the libudev include directory
# UDEV_LIBS - The libudev libraries
# UDEV_HAVE_GET_SYSATTR_LIST_ENTRY - TRUE if the udev library has the function
# udev_device_get_sysattr_list_entry(), added in version 167 of libudev
# Copyright (c) 2010, Rafael Fernández López, <ereslibre@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBUDEV libudev)
endif()
find_path(UDEV_INCLUDE_DIR
NAMES libudev.h
HINTS ${PC_LIBUDEV_INCLUDEDIR} ${PC_LIBUDEV_INCLUDE_DIRS}
)
find_library(UDEV_LIBS
NAMES udev
HINTS ${PC_LIBUDEV_LIBDIR} ${PC_LIBUDEV_LIBRARY_DIRS}
)
if(UDEV_INCLUDE_DIR AND UDEV_LIBS)
include(CheckFunctionExists)
include(CMakePushCheckState)
cmake_reset_check_state()
set(CMAKE_REQUIRED_LIBRARIES ${UDEV_LIBS})
check_function_exists(udev_device_get_sysattr_list_entry UDEV_HAVE_GET_SYSATTR_LIST_ENTRY)
cmake_reset_check_state()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(UDev DEFAULT_MSG UDEV_INCLUDE_DIR UDEV_LIBS)
mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBS)