CMake: bump the minimal required version to 3.5
[libftdi] / cmake / FindLibUSB.cmake
1 # - Try to find the libusb library
2 # Once done this defines
3 #
4 #  LIBUSB_FOUND - system has libusb
5 #  LIBUSB_INCLUDE_DIR - the libusb include directory
6 #  LIBUSB_LIBRARIES - Link these to use libusb
7
8 # Copyright (c) 2006, 2008  Laurent Montel, <montel@kde.org>
9 #
10 # Redistribution and use is allowed according to the terms of the BSD license.
11 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
12
13 if (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
14
15   # in cache already
16   set(LIBUSB_FOUND TRUE)
17
18 else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
19   # use pkg-config to get the directories and then use these values
20   # in the FIND_PATH() and FIND_LIBRARY() calls
21   find_package(PkgConfig)
22   pkg_check_modules(PC_LIBUSB libusb-1.0)
23
24   find_path(LIBUSB_INCLUDE_DIR libusb.h
25     PATH_SUFFIXES libusb-1.0
26     PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS})
27
28   find_library(LIBUSB_LIBRARIES NAMES ${PC_LIBUSB_LIBRARIES}
29     PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS})
30
31   include(FindPackageHandleStandardArgs)
32   find_package_handle_standard_args(
33     LibUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR
34   )
35
36   mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
37
38 endif (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)