kdelibs/cmake/modules/FindLibUSB.cmake
Ivailo Monev 3065f6f156 cmake: review CMake modules rewritten by me
since find_package_handle_standard_args() is used and no status messages
are printed by the modules there is no reason to set <MODULE>_FIND_QUIETLY
variable (which should be prefixed with the actual module name, not upper
case)

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
2020-02-19 20:52:40 +00:00

43 lines
1.1 KiB
CMake

# - Try to find libusb
#
# Once done this will define
#
# LIBUSB_FOUND - system has libusb
# LIBUSB_INCLUDES - the libusb include directory
# LIBUSB_LIBRARIES - the libraries needed to use libusb
#
# Copyright (c) 2016-2020, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_LIBUSB QUIET libusb-1.0)
set(LIBUSB_INCLUDES ${PC_LIBUSB_INCLUDE_DIRS})
set(LIBUSB_LIBRARIES ${PC_LIBUSB_LIBRARIES})
endif()
set(LIBUSB_VERSION ${PC_LIBUSB_VERSION})
if(NOT LIBUSB_INCLUDES OR NOT LIBUSB_LIBRARIES)
find_path(LIBUSB_INCLUDES
NAMES libusb.h
PATH_SUFFIXES libusb-1.0
HINTS $ENV{LIBUSBDIR}/include
)
find_library(LIBUSB_LIBRARIES
NAMES usb-1.0
HINTS $ENV{LIBUSBDIR}/lib
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibUSB
VERSION_VAR LIBUSB_VERSION
REQUIRED_VARS LIBUSB_LIBRARIES LIBUSB_INCLUDES
)
mark_as_advanced(LIBUSB_INCLUDES LIBUSB_LIBRARIES)