1 # Attempts to find libusb-1.0
3 # LIBUSB_FOUND - system has libusb
4 # LIBUSB_INCLUDE_DIRS - the libusb include directory
5 # LIBUSB_LIBRARIES - Link these to use libusb
6 # LIBUSB_DEFINITIONS - Compiler switches required for using libusb
8 # Adapted from cmake-modules Google Code project
10 # Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
12 # (Changes for libusb) Copyright (c) 2014 Jacob Alexander <haata@kiibohd.com>
14 # Redistribution and use is allowed according to the terms of the New BSD license.
16 # CMake-Modules Project New BSD License
18 # Redistribution and use in source and binary forms, with or without
19 # modification, are permitted provided that the following conditions are met:
21 # * Redistributions of source code must retain the above copyright notice, this
22 # list of conditions and the following disclaimer.
24 # * Redistributions in binary form must reproduce the above copyright notice,
25 # this list of conditions and the following disclaimer in the
26 # documentation and/or other materials provided with the distribution.
28 # * Neither the name of the CMake-Modules Project nor the names of its
29 # contributors may be used to endorse or promote products derived from this
30 # software without specific prior written permission.
32 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
36 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
39 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 if ( LIBUSB_LIBRARIES AND LIBUSB_INCLUDE_DIRS )
47 set( LIBUSB_FOUND TRUE )
49 find_path( LIBUSB_INCLUDE_DIR
62 find_library( LIBUSB_LIBRARY
73 set( LIBUSB_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIR} )
74 set( LIBUSB_LIBRARIES ${LIBUSB_LIBRARY} )
76 if ( LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES )
77 set( LIBUSB_FOUND TRUE )
81 if ( NOT LIBUSB_FIND_QUIETLY )
82 message( STATUS "Found libusb:" )
83 message( STATUS " - Includes: ${LIBUSB_INCLUDE_DIRS}" )
84 message( STATUS " - Libraries: ${LIBUSB_LIBRARIES}" )
87 if ( LIBUSB_FIND_REQUIRED )
88 message( FATAL_ERROR "Could not find libusb-1.0" )
92 # show the LIBUSB_INCLUDE_DIRS and LIBUSB_LIBRARIES variables only in the advanced view
93 mark_as_advanced( LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES )