| 1 |
# - try to find HIDAPI library |
| 2 |
# from http://www.signal11.us/oss/hidapi/ |
| 3 |
# |
| 4 |
# Cache Variables: (probably not for direct use in your scripts) |
| 5 |
# HIDAPI_INCLUDE_DIR |
| 6 |
# HIDAPI_LIBRARY |
| 7 |
# |
| 8 |
# Non-cache variables you might use in your CMakeLists.txt: |
| 9 |
# HIDAPI_FOUND |
| 10 |
# HIDAPI_INCLUDE_DIRS |
| 11 |
# HIDAPI_LIBRARIES |
| 12 |
# |
| 13 |
# Requires these CMake modules: |
| 14 |
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2) |
| 15 |
# |
| 16 |
# Original Author: |
| 17 |
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]> |
| 18 |
# http://academic.cleardefinition.com |
| 19 |
# Iowa State University HCI Graduate Program/VRAC |
| 20 |
# |
| 21 |
# Copyright Iowa State University 2009-2010. |
| 22 |
# Distributed under the Boost Software License, Version 1.0. |
| 23 |
# (See accompanying file LICENSE_1_0.txt or copy at |
| 24 |
# http://www.boost.org/LICENSE_1_0.txt) |
| 25 |
|
| 26 |
find_library(HIDAPI_LIBRARY |
| 27 |
NAMES hidapi hidapi-libusb) |
| 28 |
|
| 29 |
find_path(HIDAPI_INCLUDE_DIR |
| 30 |
NAMES hidapi.h |
| 31 |
PATH_SUFFIXES |
| 32 |
hidapi) |
| 33 |
|
| 34 |
include(FindPackageHandleStandardArgs) |
| 35 |
find_package_handle_standard_args(HIDAPI |
| 36 |
DEFAULT_MSG |
| 37 |
HIDAPI_LIBRARY |
| 38 |
HIDAPI_INCLUDE_DIR) |
| 39 |
|
| 40 |
if(HIDAPI_FOUND) |
| 41 |
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARY}") |
| 42 |
if((STATIC AND UNIX AND NOT APPLE) OR (DEPENDS AND CMAKE_SYSTEM_NAME STREQUAL "Linux") OR ANDROID) |
| 43 |
find_library(LIBUSB-1.0_LIBRARY usb-1.0) |
| 44 |
find_library(LIBUDEV_LIBRARY udev) |
| 45 |
if(LIBUSB-1.0_LIBRARY) |
| 46 |
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUSB-1.0_LIBRARY}") |
| 47 |
if(LIBUDEV_LIBRARY) |
| 48 |
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUDEV_LIBRARY}") |
| 49 |
elseif(NOT ANDROID) |
| 50 |
message(WARNING "libudev library not found, binaries may fail to link.") |
| 51 |
endif() |
| 52 |
else() |
| 53 |
message(WARNING "libusb-1.0 library not found, binaries may fail to link.") |
| 54 |
endif() |
| 55 |
if(ANDROID) |
| 56 |
# libusb uses android log library |
| 57 |
find_library(ANDROID_LOG_LIBRARY log) |
| 58 |
if(ANDROID_LOG_LIBRARY) |
| 59 |
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${ANDROID_LOG_LIBRARY}") |
| 60 |
else() |
| 61 |
message(WARNING "Android log library not found, binaries may fail to link.") |
| 62 |
endif() |
| 63 |
endif() |
| 64 |
endif() |
| 65 |
|
| 66 |
set(HIDAPI_INCLUDE_DIRS "${HIDAPI_INCLUDE_DIR}") |
| 67 |
endif() |
| 68 |
|
| 69 |
mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY) |