FindUDev.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # razor-de: Configure libudev environment
  2. #
  3. # UDEV_FOUND - system has a libudev
  4. # UDEV_INCLUDE_DIR - where to find header files
  5. # UDEV_LIBRARIES - the libraries to link against udev
  6. # UDEV_STABLE - it's true when is the version greater or equals to 143 - version when the libudev was stabilized in its API
  7. #
  8. # copyright (c) 2011 Petr Vanek <petr@scribus.info>
  9. # Redistribution and use is allowed according to the terms of the BSD license.
  10. #
  11. FIND_PATH(
  12. UDEV_INCLUDE_DIR
  13. libudev.h
  14. /usr/include
  15. /usr/local/include
  16. ${UDEV_PATH_INCLUDES}
  17. )
  18. FIND_LIBRARY(
  19. UDEV_LIBRARIES
  20. NAMES udev libudev
  21. PATHS
  22. /usr/lib${LIB_SUFFIX}
  23. /usr/local/lib${LIB_SUFFIX}
  24. ${UDEV_PATH_LIB}
  25. )
  26. IF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
  27. SET(UDEV_FOUND "YES")
  28. execute_process(COMMAND pkg-config --atleast-version=143 libudev RESULT_VARIABLE UDEV_STABLE)
  29. # retvale is 0 of the condition is "true" so we need to negate the value...
  30. if (UDEV_STABLE)
  31. set(UDEV_STABLE 0)
  32. else ()
  33. set(UDEV_STABLE 1)
  34. endif ()
  35. message(STATUS "libudev stable: ${UDEV_STABLE}")
  36. ENDIF ()
  37. IF (UDEV_FOUND)
  38. MESSAGE(STATUS "Found UDev: ${UDEV_LIBRARIES}")
  39. MESSAGE(STATUS " include: ${UDEV_INCLUDE_DIR}")
  40. ELSE ()
  41. MESSAGE(STATUS "UDev not found.")
  42. MESSAGE(STATUS "UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include")
  43. MESSAGE(STATUS " currently found includes: ${UDEV_INCLUDE_DIR}")
  44. MESSAGE(STATUS "UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib")
  45. MESSAGE(STATUS " currently found libs: ${UDEV_LIBRARIES}")
  46. IF (UDev_FIND_REQUIRED)
  47. MESSAGE(FATAL_ERROR "Could not find UDev library")
  48. ENDIF ()
  49. ENDIF ()