File: FindLibusb1.cmake

package info (click to toggle)
freespace2 25.0.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 47,232 kB
  • sloc: cpp: 657,500; ansic: 22,305; sh: 293; python: 200; makefile: 198; xml: 181
file content (101 lines) | stat: -rw-r--r-- 2,171 bytes parent folder | download | duplicates (3)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# - try to find libusb-1 library
#
# Cache Variables: (probably not for direct use in your scripts)
#  LIBUSB1_LIBRARY
#  LIBUSB1_INCLUDE_DIR
#
# Non-cache variables you should use in your CMakeLists.txt:
#  LIBUSB1_LIBRARIES
#  LIBUSB1_INCLUDE_DIRS
#  LIBUSB1_FOUND - if this is not true, do not attempt to use this library
#
# Requires these CMake modules:
#  ProgramFilesGlob
#  FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2021 Rylie Pavlik <rylie@ryliepavlik.com>
# https://ryliepavlik.com/
#
# Copyright 2009-2010, Iowa State University
# Copyright 2021, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)


set(LIBUSB1_ROOT_DIR
	"${LIBUSB1_ROOT_DIR}"
	CACHE
	PATH
	"Root directory to search for libusb-1")

if(WIN32)
	include(ProgramFilesGlob)
	program_files_fallback_glob(_dirs "LibUSB-Win32")
	if(CMAKE_SIZEOF_VOID_P EQUAL 8)
		if(MSVC)
			set(_lib_suffixes lib/msvc_x64 MS64/static)
		endif()
	else()
		if(MSVC)
			set(_lib_suffixes lib/msvc MS32/static)
		elseif(COMPILER_IS_GNUCXX)
			set(_lib_suffixes lib/gcc)
		endif()
	endif()
else()
	set(_lib_suffixes)
	if(NOT ANDROID)
		find_package(PkgConfig QUIET)
		if(PKG_CONFIG_FOUND)
			pkg_check_modules(PC_LIBUSB1 QUIET libusb-1.0)
		endif()
	endif()
endif()

find_path(LIBUSB1_INCLUDE_DIR
	NAMES
	libusb.h
	PATHS
	${PC_LIBUSB1_INCLUDE_DIRS}
	${PC_LIBUSB1_INCLUDEDIR}
	${_dirs}
	HINTS
	"${LIBUSB1_ROOT_DIR}"
	PATH_SUFFIXES
	include/libusb-1.0
	include
	libusb-1.0)

find_library(LIBUSB1_LIBRARY
	NAMES
	libusb-1.0
	usb-1.0
	PATHS
	${PC_LIBUSB1_LIBRARY_DIRS}
	${PC_LIBUSB1_LIBDIR}
	${_dirs}
	HINTS
	"${LIBUSB1_ROOT_DIR}"
	PATH_SUFFIXES
	${_lib_suffixes})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libusb1
	DEFAULT_MSG
	LIBUSB1_LIBRARY
	LIBUSB1_INCLUDE_DIR)

if(LIBUSB1_FOUND)
	set(LIBUSB1_LIBRARIES "${LIBUSB1_LIBRARY}")

	set(LIBUSB1_INCLUDE_DIRS "${LIBUSB1_INCLUDE_DIR}")

	mark_as_advanced(LIBUSB1_ROOT_DIR)
endif()

mark_as_advanced(LIBUSB1_INCLUDE_DIR LIBUSB1_LIBRARY)