1 # - Try to find libusb-1.0
2 # Once done this will define
4 # LIBUSB_1_FOUND - system has libusb
5 # LIBUSB_1_INCLUDE_DIRS - the libusb include directory
6 # LIBUSB_1_LIBRARIES - Link these to use libusb
7 # LIBUSB_1_DEFINITIONS - Compiler switches required for using libusb
9 # Adapted from cmake-modules Google Code project
11 # Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
13 # (Changes for libusb) Copyright (c) 2008 Kyle Machulis <kyle@nonpolynomial.com>
15 # Redistribution and use is allowed according to the terms of the New BSD license.
17 # CMake-Modules Project New BSD License
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions are met:
22 # * Redistributions of source code must retain the above copyright notice, this
23 # list of conditions and the following disclaimer.
25 # * Redistributions in binary form must reproduce the above copyright notice,
26 # this list of conditions and the following disclaimer in the
27 # documentation and/or other materials provided with the distribution.
29 # * Neither the name of the CMake-Modules Project nor the names of its
30 # contributors may be used to endorse or promote products derived from this
31 # software without specific prior written permission.
33 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
37 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
40 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
48 set(LIBUSB_FOUND TRUE)
49 else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
50 find_path(LIBUSB_1_INCLUDE_DIR
62 find_library(LIBUSB_1_LIBRARY
72 set(LIBUSB_1_INCLUDE_DIRS
73 ${LIBUSB_1_INCLUDE_DIR}
75 set(LIBUSB_1_LIBRARIES
79 if (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
80 set(LIBUSB_1_FOUND TRUE)
81 endif (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
84 if (NOT libusb_1_FIND_QUIETLY)
85 message(STATUS "Found libusb-1.0:")
86 message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
87 message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
88 endif (NOT libusb_1_FIND_QUIETLY)
90 if (libusb_1_FIND_REQUIRED)
91 message(FATAL_ERROR "Could not find libusb")
92 endif (libusb_1_FIND_REQUIRED)
93 endif (LIBUSB_1_FOUND)
95 # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
96 mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
98 endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)