From 90dc96046cac31891b80fe6461bace2838c3cb89 Mon Sep 17 00:00:00 2001 From: Georgiy Frolov Date: Tue, 24 Nov 2015 12:54:09 -0500 Subject: [PATCH] add submodules --- .gitmodules | 6 +++ vendor/CMakeLists.txt | 4 ++ vendor/HIDAPIpp | 1 + vendor/hidapi | 1 + vendor/hidapi.cmake | 109 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+) create mode 100644 .gitmodules create mode 100644 vendor/CMakeLists.txt create mode 160000 vendor/HIDAPIpp create mode 160000 vendor/hidapi create mode 100644 vendor/hidapi.cmake diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..943cf0f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "vendor/HIDAPIpp"] + path = vendor/HIDAPIpp + url = https://github.com/sensics/HIDAPIpp.git +[submodule "vendor/hidapi"] + path = vendor/hidapi + url = https://github.com/signal11/hidapi.git diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt new file mode 100644 index 0000000..ca02185 --- /dev/null +++ b/vendor/CMakeLists.txt @@ -0,0 +1,4 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/hidapi.cmake") + +add_library(HIDAPIpp INTERFACE) +target_include_directories(HIDAPIpp INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/HIDAPIpp") \ No newline at end of file diff --git a/vendor/HIDAPIpp b/vendor/HIDAPIpp new file mode 160000 index 0000000..68c4215 --- /dev/null +++ b/vendor/HIDAPIpp @@ -0,0 +1 @@ +Subproject commit 68c4215840eda023dab3514eb7448644abf2358d diff --git a/vendor/hidapi b/vendor/hidapi new file mode 160000 index 0000000..d17db57 --- /dev/null +++ b/vendor/hidapi @@ -0,0 +1 @@ +Subproject commit d17db57b9d4354752e0af42f5f33007a42ef2906 diff --git a/vendor/hidapi.cmake b/vendor/hidapi.cmake new file mode 100644 index 0000000..66299ab --- /dev/null +++ b/vendor/hidapi.cmake @@ -0,0 +1,109 @@ +# Partially based on VRPN build system, BSL1.0 license + +set(_source) +set(_libs) +set(_includes) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +if(NOT HIDAPI_ROOT) + set(HIDAPI_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/hidapi") +endif() + +if(NOT EXISTS "${HIDAPI_ROOT}/hidapi/hidapi.h") + message(STATUS "HIDAPI submodule missing (git submodule update --init --recursive) and/or didn't pass alternate location as HIDAPI_ROOT") + return() +endif() +# Local HIDAPI requirements +if(ANDROID) + find_package(Libusb1) + + # Check to see if our submodule is new enough. + if(NOT EXISTS "${HIDAPI_ROOT}/android/jni/Android.mk") + message(STATUS "HIDAPI_ROOT ${HIDAPI_ROOT} is not new enough to contain Android support!") + return() + endif() + + if(NOT LIBUSB1_FOUND) + message(STATUS "HIDAPI: Requires Libusb1.0, not found") + return() + endif() + + set(_source "${HIDAPI_ROOT}/libusb/hid.c") + set(_includes ${LIBUSB1_INCLUDE_DIRS}) + set(_libs ${LIBUSB1_LIBRARIES}) +elseif(WIN32) + # No extra deps needed on Windows - dynamically/delay loading the dlls. + set(HIDAPI_BACKEND_FOUND YES) + set(_source ${CMAKE_CURRENT_SOURCE_DIR}/hidapi/windows/hid.c) + set(_libs setupapi) + +elseif(APPLE) + find_package(MacHID) + if(NOT MACHID_FOUND) + message(STATUS "HIDAPI: Requires some Mac HID libraries you should have had, not found.") + return() + endif() + set(_source ${CMAKE_CURRENT_SOURCE_DIR}/hidapi/mac/hid.c) + set(_libs ${MACHID_LIBRARIES}) +else() + find_package(Libusb1) + + set(HIDAPI_LIBUDEV_FOUND NO) + if(CMAKE_SYSTEM_NAME MATCHES "Linux") + find_library(HIDAPI_LIBUDEV udev) + find_path(HIDAPI_HIDRAW_INCLUDE_DIR linux/hidraw.h) + find_path(HIDAPI_LIBUDEV_INCLUDE_DIR libudev.h) + if(HIDAPI_LIBUDEV AND HIDAPI_HIDRAW_INCLUDE_DIR AND HIDAPI_LIBUDEV_INCLUDE_DIR) + mark_as_advanced(HIDAPI_LIBUDEV + HIDAPI_HIDRAW_INCLUDE_DIR + HIDAPI_LIBUDEV_INCLUDE_DIR) + set(HIDAPI_LIBUDEV_FOUND YES) + endif() + endif() + if(HIDAPI_LIBUDEV_FOUND AND LIBUSB1_FOUND) + option(HIDAPI_USE_UDEV_HIDRAW "Should we build against the Linux kernel, HID raw, and libudev? (Alternative is libusb1)" OFF) + if(HIDAPI_USE_UDEV_HIDRAW) + set(_hidapi_udev ON) + set(_hidapi_libusb OFF) + else() + set(_hidapi_udev OFF) + set(_hidapi_libusb ON) + endif() + elseif(HIDAPI_LIBUDEV_FOUND) + # Only found libudev, using it. + set(_hidapi_udev ON) + set(_hidapi_libusb OFF) + elseif(LIBUSB1_FOUND) + # Only found libusb1, using it. + set(_hidapi_udev OFF) + set(_hidapi_libusb ON) + else() + message(STATUS "HIDAPI: Assuming your platform may be supported by libusb1, but libusb1 not found! (If this is Linux, we didn't find the hidraw kernel header and libudev either!)") + return() + endif() + + if(_hidapi_libusb) + set(_source "${HIDAPI_ROOT}/libusb/hid.c") + set(_includes ${LIBUSB1_INCLUDE_DIRS}) + set(_libs ${LIBUSB1_LIBRARIES}) + elseif(_hidapi_udev) + set(_source "${HIDAPI_ROOT}/linux/hid.c") + set(_includes ${HIDAPI_HIDRAW_INCLUDE_DIR} ${HIDAPI_LIBUDEV_INCLUDE_DIR}) + set(_libs ${HIDAPI_LIBUDEV}) + endif() + find_library(HIDAPI_LIBRT rt) + mark_as_advanced(HIDAPI_LIBRT) + if(HIDAPI_LIBRT) + list(APPEND _libs ${HIDAPI_LIBRT}) + endif() +endif() + +add_library(hidapi STATIC "${HIDAPI_ROOT}/hidapi/hidapi.h" ${_source}) +target_include_directories(hidapi PUBLIC "${HIDAPI_ROOT}/hidapi") +if(_libs) + target_link_libraries(hidapi PRIVATE ${_libs}) +endif() +if(_includes) + target_include_directories(hidapi PRIVATE ${_includes}) +endif()