File: FindLibUSB.cmake

package info (click to toggle)
libuvc 0.0.7-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 820 kB
  • sloc: ansic: 5,898; python: 249; makefile: 22
file content (51 lines) | stat: -rw-r--r-- 1,304 bytes parent folder | download | duplicates (2)
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
#[==============================================[
FindLibUSB
-----------

Searching libusb-1.0 library and creating imported 
target LibUSB::LibUSB

#]==============================================]

# TODO Append parts for Version compasion and REQUIRED support

if (MSVC OR MINGW)
    return()
endif()

if (NOT TARGET LibUSB::LibUSB)
  find_package(PkgConfig)
  pkg_check_modules(LibUSB REQUIRED
    libusb-1.0
  )

  if(LibUSB_FOUND)
    message(STATUS "libusb-1.0 found using pkgconfig")

    add_library(LibUSB::LibUSB
      UNKNOWN IMPORTED
    )
    if (DEFINED LibUSB_INCLUDE_DIRS AND NOT LibUSB_INCLUDE_DIRS STREQUAL "")
      set_target_properties(LibUSB::LibUSB PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES ${LibUSB_INCLUDE_DIRS}
      )
    endif()

    if(LibUSB_LIBRARIES)
      find_library(LibUSB_LIBRARY
        NAMES ${LibUSB_LIBRARIES}
        PATHS ${LibUSB_LIBDIR} ${LibUSB_LIBRARY_DIRS}
      )
      if(LibUSB_LIBRARY)
        set_target_properties(LibUSB::LibUSB PROPERTIES
          IMPORTED_LINK_INTERFACE_LANGUAGES "C"
          IMPORTED_LOCATION ${LibUSB_LIBRARY}
        )
      else()
        message(WARNING "Could not found libusb-1.0 library file")
      endif()
    endif()
  endif()
else()
  message(WARNING "libusb-1.0 could not be found using pkgconfig")
endif()