2012-04-01 16:52:41 +02:00
|
|
|
if(NOT LIBUSB_FOUND)
|
|
|
|
pkg_check_modules (LIBUSB_PKG libusb-1.0)
|
|
|
|
find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
|
|
|
PATHS
|
|
|
|
${LIBUSB_PKG_INCLUDE_DIRS}
|
|
|
|
/usr/include/libusb-1.0
|
|
|
|
/usr/include
|
|
|
|
/usr/local/include
|
|
|
|
)
|
|
|
|
|
2013-11-17 19:09:59 +01:00
|
|
|
#standard library name for libusb-1.0
|
|
|
|
set(libusb1_library_names usb-1.0)
|
|
|
|
|
|
|
|
#libusb-1.0 compatible library on freebsd
|
|
|
|
if((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") OR (CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD"))
|
|
|
|
list(APPEND libusb1_library_names usb)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_library(LIBUSB_LIBRARIES
|
|
|
|
NAMES ${libusb1_library_names}
|
2012-04-01 16:52:41 +02:00
|
|
|
PATHS
|
|
|
|
${LIBUSB_PKG_LIBRARY_DIRS}
|
|
|
|
/usr/lib
|
|
|
|
/usr/local/lib
|
|
|
|
)
|
|
|
|
|
2014-01-24 03:57:53 +01:00
|
|
|
include(CheckFunctionExists)
|
|
|
|
if(LIBUSB_INCLUDE_DIRS)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${LIBUSB_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
if(LIBUSB_LIBRARIES)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${LIBUSB_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
CHECK_FUNCTION_EXISTS("libusb_handle_events_timeout_completed" HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
|
|
|
|
if(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
|
|
|
|
add_definitions(-DHAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED=1)
|
|
|
|
endif(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
|
|
|
|
|
|
|
|
CHECK_FUNCTION_EXISTS("libusb_error_name" HAVE_LIBUSB_ERROR_NAME)
|
|
|
|
if(HAVE_LIBUSB_ERROR_NAME)
|
|
|
|
add_definitions(-DHAVE_LIBUSB_ERROR_NAME=1)
|
|
|
|
endif(HAVE_LIBUSB_ERROR_NAME)
|
|
|
|
|
2012-04-01 16:52:41 +02:00
|
|
|
if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
|
|
|
set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
|
|
|
|
message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
|
|
|
|
else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
|
|
|
set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
|
|
|
|
message(STATUS "libusb-1.0 not found.")
|
|
|
|
endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
|
|
|
|
|
|
|
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
|
|
|
|
|
|
|
|
endif(NOT LIBUSB_FOUND)
|