-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
47 lines (36 loc) · 1.69 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.2)
project(hidapi-test)
set(CMAKE_CXX_STANDARD 11)
################ hidapi
set(HIDAPI_ROOT ${CMAKE_BINARY_DIR}/thirdparty/hidapi)
set(HIDAPI_LIB_DIR ${HIDAPI_ROOT}/bin/lib)
set(HIDAPI_INCLUDE_DIR ${HIDAPI_ROOT}/bin/include)
include(ExternalProject)
ExternalProject_Add(hidapi_external
PREFIX ${HIDAPI_ROOT}
GIT_REPOSITORY "https://github.com/signal11/hidapi.git"
GIT_TAG "40cf516139b5b61e30d9403a48db23d8f915f52c"
UPDATE_COMMAND ""
PATCH_COMMAND ""
BINARY_DIR ${HIDAPI_ROOT}/src/hidapi
SOURCE_DIR ${HIDAPI_ROOT}/src/hidapi
INSTALL_DIR ${HIDAPI_ROOT}/bin
CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR>
BUILD_COMMAND make
BUILD_BYPRODUCTS ${HIDAPI_LIB_DIR}/libhidapi.a)
# hidapi requires an initial execution of "./bootstrap" to run autoreconf
ExternalProject_Add_Step(hidapi_external
bootstrap
COMMAND ./bootstrap
DEPENDEES download
DEPENDERS configure
WORKING_DIRECTORY ${HIDAPI_ROOT}/src/hidapi)
add_library(libhidapi STATIC IMPORTED)
set_target_properties(libhidapi PROPERTIES IMPORTED_LOCATION ${HIDAPI_LIB_DIR}/libhidapi.a)
add_dependencies(libhidapi hidapi_external)
################ test app
find_library(IOKIT NAMES IOKit)
find_library(COREFOUNDATION NAMES CoreFoundation)
include_directories(${HIDAPI_INCLUDE_DIR})
add_executable(hidapi-test src/main.cpp)
target_link_libraries(hidapi-test ${IOKIT} ${COREFOUNDATION} libhidapi)