FindLibUSB.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # - Find libusb-1.0 library
  2. # This module defines
  3. # LIBUSB_INCLUDE_DIR, where to find bluetooth.h
  4. # LIBUSB_LIBRARIES, the libraries needed to use libusb-1.0.
  5. # LIBUSB_FOUND, If false, do not try to use libusb-1.0.
  6. #
  7. # Copyright (c) 2009, Michal Cihar, <michal@cihar.com>
  8. #
  9. # vim: expandtab sw=4 ts=4 sts=4:
  10. if(ANDROID)
  11. set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
  12. message(STATUS "libusb-1.0 not found.")
  13. elseif (NOT LIBUSB_FOUND)
  14. pkg_check_modules (LIBUSB_PKG libusb-1.0)
  15. find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
  16. PATHS
  17. ${LIBUSB_PKG_INCLUDE_DIRS}
  18. /usr/include/libusb-1.0
  19. /usr/include
  20. /usr/local/include/libusb-1.0
  21. /usr/local/include
  22. )
  23. find_library(LIBUSB_LIBRARIES NAMES usb-1.0 usb
  24. PATHS
  25. ${LIBUSB_PKG_LIBRARY_DIRS}
  26. /usr/lib
  27. /usr/local/lib
  28. )
  29. if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
  30. set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
  31. message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
  32. else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
  33. set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
  34. message(STATUS "libusb-1.0 not found.")
  35. endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
  36. mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
  37. endif ()
  38. if(LIBUSB_FOUND AND NOT TARGET LibUSB::LibUSB)
  39. add_library(LibUSB::LibUSB UNKNOWN IMPORTED)
  40. set_target_properties(LibUSB::LibUSB PROPERTIES
  41. IMPORTED_LOCATION "${LIBUSB_LIBRARIES}"
  42. INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}"
  43. )
  44. endif()