carl9170 firmware: import 1.7.0
[carl9170fw.git] / extra / FindUSB-1.0.cmake
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 is allowed according to the terms of the New
12 #  BSD license.
13 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 #
15
16
17 if (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)
18   # in cache already
19   set(USB-1.0_FOUND TRUE)
20 else (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)
21   # use pkg-config to get the directories and then use these values
22   # in the FIND_PATH() and FIND_LIBRARY() calls
23   if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
24     include(UsePkgConfig)
25     pkgconfig(libusb-1.0 _USB-1.0_INCLUDEDIR _USB-1.0_LIBDIR _USB-1.0_LDFLAGS _USB-1.0_CFLAGS)
26   else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
27     find_package(PkgConfig)
28     if (PKG_CONFIG_FOUND)
29       pkg_check_modules(_USB-1.0 libusb-1.0)
30     endif (PKG_CONFIG_FOUND)
31   endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
32
33   find_path(USB-1.0_INCLUDE_DIR
34     NAMES
35       libusb.h
36     PATHS
37       ${_USB-1.0_INCLUDEDIR}
38       /usr/include
39       /usr/local/include
40       /opt/local/include
41       /sw/include
42     PATH_SUFFIXES
43       libusb-1.0
44   )
45   mark_as_advanced(USB-1.0_INCLUDE_DIR)
46
47   find_library(USB-1.0_LIBRARY
48     NAMES
49       usb-1.0
50     PATHS
51       ${_USB-1.0_LIBDIR}
52       /usr/lib
53       /usr/local/lib
54       /opt/local/lib
55       /sw/lib
56   )
57   mark_as_advanced(USB-1.0_LIBRARY)
58
59   if (USB-1.0_LIBRARY)
60     set(USB-1.0_FOUND TRUE)
61     mark_as_advanced(USB-1.0_FOUND)
62   endif (USB-1.0_LIBRARY)
63
64   set(USB-1.0_INCLUDE_DIRS
65     ${USB-1.0_INCLUDE_DIR}
66   )
67
68   if (USB-1.0_FOUND)
69     set(USB-1.0_LIBRARIES
70       ${USB-1.0_LIBRARIES}
71       ${USB-1.0_LIBRARY}
72     )
73   endif (USB-1.0_FOUND)
74
75   if (USB-1.0_INCLUDE_DIRS AND USB-1.0_LIBRARIES)
76      set(USB-1.0_FOUND TRUE)
77   endif (USB-1.0_INCLUDE_DIRS AND USB-1.0_LIBRARIES)
78
79   if (USB-1.0_FOUND)
80     if (NOT USB-1.0_FIND_QUIETLY)
81       message(STATUS "Found USB-1.0: ${USB-1.0_LIBRARIES}")
82     endif (NOT USB-1.0_FIND_QUIETLY)
83   else (USB-1.0_FOUND)
84     if (USB-1.0_FIND_REQUIRED)
85       message(FATAL_ERROR "Could not find USB-1.0")
86     endif (USB-1.0_FIND_REQUIRED)
87   endif (USB-1.0_FOUND)
88
89   # show the USB-1.0_INCLUDE_DIRS and USB-1.0_LIBRARIES variables only in the advanced view
90   mark_as_advanced(USB-1.0_INCLUDE_DIRS USB-1.0_LIBRARIES)
91
92 endif (USB-1.0_LIBRARIES AND USB-1.0_INCLUDE_DIRS)
93