File: Findlibusb.cmake

package info (click to toggle)
pcl 1.13.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 143,524 kB
  • sloc: cpp: 518,578; xml: 28,792; ansic: 13,676; python: 334; lisp: 93; sh: 49; makefile: 30
file content (73 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#.rst:
# Findlibusb
# --------
#
# Try to find libusb library and headers.
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the :prop_tgt:`IMPORTED` targets:
#
# ``libusb::libusb``
#  Defined if the system has libusb.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module sets the following variables:
#
# ::
#
#   LIBUSB_FOUND               True in case libusb is found, otherwise false
#   LIBUSB_ROOT                Path to the root of found libusb installation
#
# Example usage
# ^^^^^^^^^^^^^
#
# ::
#
#     find_package(libusb REQUIRED)
#
#     add_executable(foo foo.cc)
#     target_link_libraries(foo libusb::libusb)
#

# Early return if libusb target is already defined. This makes it safe to run
# this script multiple times.
if(TARGET libusb::libusb)
  return()
endif()

find_package(PkgConfig QUIET)
if(libusb_FIND_VERSION)
  pkg_check_modules(PC_libusb libusb-1.0>=${libusb_FIND_VERSION})
else()
  pkg_check_modules(PC_libusb libusb-1.0)
endif()

find_path(libusb_INCLUDE_DIR
  NAMES
    libusb-1.0/libusb.h
  PATHS
    ${PC_libusb_INCLUDEDIR}
)

find_library(libusb_LIBRARIES
  NAMES
    usb-1.0
    libusb
  PATHS
    ${PC_libusb_LIBRARY_DIRS}
)
  
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libusb DEFAULT_MSG libusb_LIBRARIES libusb_INCLUDE_DIR)

mark_as_advanced(libusb_INCLUDE_DIRS libusb_LIBRARIES)

if(libusb_FOUND)
  add_library(libusb::libusb UNKNOWN IMPORTED)
  set_target_properties(libusb::libusb PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${libusb_INCLUDE_DIR}")
  set_target_properties(libusb::libusb PROPERTIES IMPORTED_LOCATION "${libusb_LIBRARIES}")
endif()