1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
cmake_minimum_required(VERSION 3.5)
project(hidapi VERSION 0.7.1)
option(HID_DEBUG_PARSER "verbose parser debugging output" OFF)
# option(LIBUSB "use libusb backend" OFF)
# option(HIDRAW "use hidraw backend (linux/freebsd)" ON)
option(HID_EXAMPLE_TEST "build test example" OFF)
option(HID_EXAMPLE_OSC "build osc example" OFF)
option(HID_INSTALL_HUT "install hid usage tables" ON)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(HIDAPI "default" CACHE STRING "HID API to use (one of {default,hidraw,libusb})")
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(HIDAPI "libusb")
endif()
# add our own cmake-modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake_modules/")
if( HID_DEBUG_PARSER )
add_definitions( -DDEBUG_PARSER )
endif()
# some default libraries
if (NOT WIN32)
find_package(Pthreads)
if (NOT PTHREADS_FOUND)
message(SEND_ERROR "cannot find libpthreads")
endif()
endif()
# directories
add_subdirectory(hidapi)
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions( -DLINUX_FREEBSD )
if(HIDAPI STREQUAL "default")
set( HIDAPI hidraw )
endif()
if(NOT HIDAPI MATCHES "^(libusb|hidraw)$")
message(WARNING "Unrecognised hid API: ${HIDAPI}")
endif()
if (HIDAPI STREQUAL hidraw)
add_subdirectory(linux)
# set( hidapi_source ${hidapi_SOURCE_DIR}/linux )
link_directories( ${UDEV_LIBRARIES} )
elseif (HIDAPI STREQUAL libusb)
add_subdirectory(libusb)
# set( hidapi_source ${hidapi_SOURCE_DIR}/libusb )
link_directories( ${LIBUSB_1_LIBRARIES} ${PTHREADS_LIBRARIES} )
endif()
endif()
if(WIN32)
add_definitions( -DWIN32 )
add_subdirectory(windows)
# set( hidapi_source ${hidapi_SOURCE_DIR}/windows )
#todo: add library dependencies
endif()
if(APPLE)
add_definitions( -DAPPLE )
add_subdirectory(mac)
# set( hidapi_source ${hidapi_SOURCE_DIR}/mac )
#todo: add library dependencies - TEST
find_library(IOKIT_LIBRARY IOKit )
find_library(COREFOUNDATION_LIBRARY CoreFoundation )
mark_as_advanced (COREFOUNDATION_LIBRARY
IOKIT_LIBRARY)
set(EXTRA_LIBS ${COREFOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
#link_directories("-framework IOKit -framework CoreFoundation")
endif()
add_subdirectory(hidapi_parser)
# message( "main: hidapi source dir: ${hidapi_source}" )
if( HID_EXAMPLE_TEST )
add_subdirectory(hidtest)
add_subdirectory(hidparsertest)
if(APPLE)
add_subdirectory(hidtestosx)
endif()
if(WIN32)
add_subdirectory(hidtestwindows)
endif()
endif()
if( HID_EXAMPLE_OSC )
add_subdirectory(hidapi2osc)
endif()
if( HID_DEBUG_PARSER OR HID_INSTALL_HUT )
# provisional to avoid having to commit to sc master while the HID submodule
# is not final/added to master
# the sc-settings for cmake_install_prefix and scappauxresourcesdir are not
# visible in this scope
if(APPLE)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/Install")
endif()
# this will break if scappbundlename is reassigned in SC
# similar problem in editors/sc-ide/CMakeLists.txt 284
set(scappbundlename "SuperCollider")
set(scappauxresourcesdir "${scappbundlename}/${scappbundlename}.app/Contents/Resources")
set(HID_HUT_PATH "${CMAKE_INSTALL_PREFIX}/${scappauxresourcesdir}/HID_Support")
elseif(WIN32)
set(auxresourcesdir "SuperCollider" CACHE STRING "Resources directory")
set(HID_HUT_PATH "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HID_Support")
else()
set(auxresourcesdir "share/SuperCollider" CACHE STRING "Resources directory")
set(HID_HUT_PATH "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HID_Support")
endif(APPLE)
install(DIRECTORY hut
DESTINATION ${HID_HUT_PATH}
FILES_MATCHING PATTERN "*.yaml"
)
endif()
|