2009-09-09 14:32:41 +02:00
|
|
|
# This CMake script wants to use libusb functionality, therefore it looks
|
|
|
|
# for libusb include files and libraries.
|
|
|
|
#
|
|
|
|
# Operating Systems Supported:
|
|
|
|
# - Unix (requires pkg-config)
|
|
|
|
# Tested with Ubuntu 9.04 and Fedora 11
|
2011-04-08 16:11:42 +02:00
|
|
|
# - Windows (requires MinGW)
|
|
|
|
# Tested with Windows XP/Windows 7
|
2009-09-09 14:32:41 +02:00
|
|
|
#
|
|
|
|
# This should work for both 32 bit and 64 bit systems.
|
|
|
|
#
|
|
|
|
# Author: F. Kooman <fkooman@tuxed.net>
|
|
|
|
#
|
|
|
|
|
2009-12-01 14:26:34 +01:00
|
|
|
# FreeBSD has built-in libusb since 800069
|
|
|
|
IF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
|
|
|
|
EXEC_PROGRAM(sysctl ARGS -n kern.osreldate OUTPUT_VARIABLE FREEBSD_VERSION)
|
|
|
|
SET(MIN_FREEBSD_VERSION 800068)
|
|
|
|
IF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
|
|
|
|
SET(LIBUSB_FOUND TRUE)
|
|
|
|
SET(LIBUSB_INCLUDE_DIRS "/usr/include")
|
|
|
|
SET(LIBUSB_LIBRARIES "usb")
|
|
|
|
SET(LIBUSB_LIBRARY_DIRS "/usr/lib/")
|
|
|
|
ENDIF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
|
|
|
|
ENDIF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
|
|
|
|
|
|
|
|
IF(NOT LIBUSB_FOUND)
|
2010-11-17 09:29:41 +01:00
|
|
|
IF(WIN32)
|
2011-06-09 16:00:45 +02:00
|
|
|
FIND_PATH(LIBUSB_INCLUDE_DIRS lusb0_usb.h "$ENV{ProgramFiles}/LibUSB-Win32/include" NO_SYSTEM_ENVIRONMENT_PATH)
|
2011-04-08 16:11:42 +02:00
|
|
|
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/gcc")
|
2011-04-20 15:18:38 +02:00
|
|
|
SET(LIBUSB_LIBRARY_DIR "$ENV{ProgramFiles}/LibUSB-Win32/bin/x86/")
|
2010-11-17 09:29:41 +01:00
|
|
|
ELSE(WIN32)
|
|
|
|
# If not under Windows we use PkgConfig
|
2009-09-09 14:32:41 +02:00
|
|
|
FIND_PACKAGE (PkgConfig)
|
|
|
|
IF(PKG_CONFIG_FOUND)
|
|
|
|
PKG_CHECK_MODULES(LIBUSB REQUIRED libusb)
|
|
|
|
ELSE(PKG_CONFIG_FOUND)
|
|
|
|
MESSAGE(FATAL_ERROR "Could not find PkgConfig")
|
|
|
|
ENDIF(PKG_CONFIG_FOUND)
|
2010-11-17 09:29:41 +01:00
|
|
|
ENDIF(WIN32)
|
2009-09-09 14:32:41 +02:00
|
|
|
|
|
|
|
IF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
|
|
|
|
SET(LIBUSB_FOUND TRUE)
|
|
|
|
ENDIF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
|
2009-12-01 14:26:34 +01:00
|
|
|
ENDIF(NOT LIBUSB_FOUND)
|
2009-09-09 14:32:41 +02:00
|
|
|
|
|
|
|
IF(LIBUSB_FOUND)
|
|
|
|
IF(NOT LIBUSB_FIND_QUIETLY)
|
2011-01-17 14:42:24 +01:00
|
|
|
MESSAGE(STATUS "Found LIBUSB: ${LIBUSB_LIBRARIES} ${LIBUSB_INCLUDE_DIRS}")
|
2009-09-09 14:32:41 +02:00
|
|
|
ENDIF (NOT LIBUSB_FIND_QUIETLY)
|
|
|
|
ELSE(LIBUSB_FOUND)
|
|
|
|
IF(LIBUSB_FIND_REQUIRED)
|
|
|
|
MESSAGE(FATAL_ERROR "Could not find LIBUSB")
|
|
|
|
ENDIF(LIBUSB_FIND_REQUIRED)
|
|
|
|
ENDIF(LIBUSB_FOUND)
|