Blame cmake/Findlibusb-1.0.cmake

Packit 1fb8d4
# - Try to find libusb-1.0
Packit 1fb8d4
# Once done this will define
Packit 1fb8d4
#
Packit 1fb8d4
# LIBUSB_1_FOUND - system has libusb
Packit 1fb8d4
# LIBUSB_1_INCLUDE_DIRS - the libusb include directory
Packit 1fb8d4
# LIBUSB_1_LIBRARIES - Link these to use libusb
Packit 1fb8d4
# LIBUSB_1_DEFINITIONS - Compiler switches required for using libusb
Packit 1fb8d4
#
Packit 1fb8d4
# Adapted from cmake-modules Google Code project
Packit 1fb8d4
#
Packit 1fb8d4
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
Packit 1fb8d4
#
Packit 1fb8d4
# (Changes for libusb) Copyright (c) 2008 Kyle Machulis <kyle@nonpolynomial.com>
Packit 1fb8d4
#
Packit 1fb8d4
# Redistribution and use is allowed according to the terms of the New BSD license.
Packit 1fb8d4
#
Packit 1fb8d4
# CMake-Modules Project New BSD License
Packit 1fb8d4
#
Packit 1fb8d4
# Redistribution and use in source and binary forms, with or without
Packit 1fb8d4
# modification, are permitted provided that the following conditions are met:
Packit 1fb8d4
#
Packit 1fb8d4
# * Redistributions of source code must retain the above copyright notice, this
Packit 1fb8d4
# list of conditions and the following disclaimer.
Packit 1fb8d4
#
Packit 1fb8d4
# * Redistributions in binary form must reproduce the above copyright notice,
Packit 1fb8d4
# this list of conditions and the following disclaimer in the
Packit 1fb8d4
# documentation and/or other materials provided with the distribution.
Packit 1fb8d4
#
Packit 1fb8d4
# * Neither the name of the CMake-Modules Project nor the names of its
Packit 1fb8d4
# contributors may be used to endorse or promote products derived from this
Packit 1fb8d4
# software without specific prior written permission.
Packit 1fb8d4
#
Packit 1fb8d4
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Packit 1fb8d4
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Packit 1fb8d4
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 1fb8d4
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
Packit 1fb8d4
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Packit 1fb8d4
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Packit 1fb8d4
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Packit 1fb8d4
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 1fb8d4
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Packit 1fb8d4
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 1fb8d4
#
Packit 1fb8d4
Packit 1fb8d4
Packit 1fb8d4
if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
Packit 1fb8d4
  # in cache already
Packit 1fb8d4
  set(LIBUSB_FOUND TRUE)
Packit 1fb8d4
else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
Packit 1fb8d4
  find_path(LIBUSB_1_INCLUDE_DIR
Packit 1fb8d4
    NAMES
Packit 1fb8d4
libusb.h
Packit 1fb8d4
    PATHS
Packit 1fb8d4
      /usr/include
Packit 1fb8d4
      /usr/local/include
Packit 1fb8d4
      /sw/include
Packit 1fb8d4
PATH_SUFFIXES
Packit 1fb8d4
libusb-1.0
Packit 1fb8d4
  )
Packit 1fb8d4
Packit 1fb8d4
  find_library(LIBUSB_1_LIBRARY
Packit 1fb8d4
    NAMES
Packit 1fb8d4
      usb-1.0 usb
Packit 1fb8d4
    PATHS
Packit 1fb8d4
      /usr/lib
Packit 1fb8d4
      /usr/local/lib
Packit 1fb8d4
      /sw/lib
Packit 1fb8d4
  )
Packit 1fb8d4
Packit 1fb8d4
  set(LIBUSB_1_INCLUDE_DIRS
Packit 1fb8d4
    ${LIBUSB_1_INCLUDE_DIR}
Packit 1fb8d4
  )
Packit 1fb8d4
  set(LIBUSB_1_LIBRARIES
Packit 1fb8d4
    ${LIBUSB_1_LIBRARY}
Packit 1fb8d4
)
Packit 1fb8d4
Packit 1fb8d4
  if (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
Packit 1fb8d4
     set(LIBUSB_1_FOUND TRUE)
Packit 1fb8d4
  endif (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
Packit 1fb8d4
Packit 1fb8d4
  if (LIBUSB_1_FOUND)
Packit 1fb8d4
    if (NOT libusb_1_FIND_QUIETLY)
Packit 1fb8d4
      message(STATUS "Found libusb-1.0:")
Packit 1fb8d4
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
Packit 1fb8d4
message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
Packit 1fb8d4
    endif (NOT libusb_1_FIND_QUIETLY)
Packit 1fb8d4
  else (LIBUSB_1_FOUND)
Packit 1fb8d4
    if (libusb_1_FIND_REQUIRED)
Packit 1fb8d4
      message(FATAL_ERROR "Could not find libusb")
Packit 1fb8d4
    endif (libusb_1_FIND_REQUIRED)
Packit 1fb8d4
  endif (LIBUSB_1_FOUND)
Packit 1fb8d4
Packit 1fb8d4
  # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
Packit 1fb8d4
  mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
Packit 1fb8d4
Packit 1fb8d4
endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)