summaryrefslogtreecommitdiff
path: root/carl9170fw/extra/FindUSB-1.0.cmake
blob: 83df063901c1a82ab0d920411c2470c09dfaa4c4 (plain)
    1 # - Try to find USB-1.0
    2 # Once done this will define
    3 #
    4 #  USB-1.0_FOUND - system has USB-1.0
    5 #  USB-1.0_INCLUDE_DIRS - the USB-1.0 include directory
    6 #  USB-1.0_LIBRARIES - Link these to use USB-1.0
    7 #  USB-1.0_DEFINITIONS - Compiler switches required for using USB-1.0
    8 #
    9 #  Copyright (c) 2009 Andreas Schneider <mail@cynapses.org>
   10 #
   11 # Redistribution and use in source and binary forms, with or without
   12 # modification, are permitted provided that the following conditions
   13 # are met:
   14 #
   15 # 1. Redistributions of source code must retain the copyright
   16 #    notice, this list of conditions and the following disclaimer.
   17 # 2. Redistributions in binary form must reproduce the copyright
   18 #    notice, this list of conditions and the following disclaimer in the
   19 #    documentation and/or other materials provided with the distribution.
   20 # 3. The name of the author may not be used to endorse or promote products
   21 #    derived from this software without specific prior written permission.
   22 #
   23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   25 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   26 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   28 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   32 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   33 #
   34 
   35 
   36 if (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)
   37   # in cache already
   38   set(USB-1.0_FOUND TRUE)
   39 else (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)
   40   # use pkg-config to get the directories and then use these values
   41   # in the FIND_PATH() and FIND_LIBRARY() calls
   42   if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
   43     include(UsePkgConfig)
   44     pkgconfig(libusb-1.0 _USB-1.0_INCLUDEDIR _USB-1.0_LIBDIR _USB-1.0_LDFLAGS _USB-1.0_CFLAGS)
   45   else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
   46     find_package(PkgConfig)
   47     if (PKG_CONFIG_FOUND)
   48       pkg_check_modules(_USB-1.0 libusb-1.0)
   49     endif (PKG_CONFIG_FOUND)
   50   endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
   51 
   52   find_path(USB-1.0_INCLUDE_DIR
   53     NAMES
   54       libusb.h
   55     PATHS
   56       ${_USB-1.0_INCLUDEDIR}
   57       /usr/include
   58       /usr/local/include
   59       /opt/local/include
   60       /sw/include
   61     PATH_SUFFIXES
   62       libusb-1.0
   63   )
   64   mark_as_advanced(USB-1.0_INCLUDE_DIR)
   65 
   66   find_library(USB-1.0_LIBRARY
   67     NAMES
   68       usb-1.0
   69     PATHS
   70       ${_USB-1.0_LIBDIR}
   71       /usr/lib
   72       /usr/local/lib
   73       /opt/local/lib
   74       /sw/lib
   75   )
   76   mark_as_advanced(USB-1.0_LIBRARY)
   77 
   78   if (USB-1.0_LIBRARY)
   79     set(USB-1.0_FOUND TRUE)
   80     mark_as_advanced(USB-1.0_FOUND)
   81   endif (USB-1.0_LIBRARY)
   82 
   83   set(USB-1.0_INCLUDE_DIRS
   84     ${USB-1.0_INCLUDE_DIR}
   85   )
   86 
   87   if (USB-1.0_FOUND)
   88     set(USB-1.0_LIBRARIES
   89       ${USB-1.0_LIBRARIES}
   90       ${USB-1.0_LIBRARY}
   91     )
   92   endif (USB-1.0_FOUND)
   93 
   94   if (USB-1.0_INCLUDE_DIRS AND USB-1.0_LIBRARIES)
   95      set(USB-1.0_FOUND TRUE)
   96   endif (USB-1.0_INCLUDE_DIRS AND USB-1.0_LIBRARIES)
   97 
   98   if (USB-1.0_FOUND)
   99     if (NOT USB-1.0_FIND_QUIETLY)
  100       message(STATUS "Found USB-1.0: ${USB-1.0_LIBRARIES}")
  101     endif (NOT USB-1.0_FIND_QUIETLY)
  102   else (USB-1.0_FOUND)
  103     if (USB-1.0_FIND_REQUIRED)
  104       message(FATAL_ERROR "Could not find USB-1.0")
  105     endif (USB-1.0_FIND_REQUIRED)
  106   endif (USB-1.0_FOUND)
  107 
  108   # show the USB-1.0_INCLUDE_DIRS and USB-1.0_LIBRARIES variables only in the advanced view
  109   mark_as_advanced(USB-1.0_INCLUDE_DIRS USB-1.0_LIBRARIES)
  110 
  111 endif (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)

Generated by cgit