1 # - Try to find USB-1.0
2 # Once done this will define
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
9 # Copyright (c) 2009 Andreas Schneider <mail@cynapses.org>
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions
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.
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.
36 if (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)
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)
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)
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)
52 find_path(USB-1.0_INCLUDE_DIR
56 ${_USB-1.0_INCLUDEDIR}
64 mark_as_advanced(USB-1.0_INCLUDE_DIR)
66 find_library(USB-1.0_LIBRARY
76 mark_as_advanced(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)
83 set(USB-1.0_INCLUDE_DIRS
84 ${USB-1.0_INCLUDE_DIR}
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)
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)
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)
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)
111 endif (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)