forked from Gadgetoid/pi400kb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
91 lines (71 loc) · 2.87 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
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
cmake_minimum_required(VERSION 3.9)
project(pikmreciever LANGUAGES C CXX)
# for asprintf
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
add_compile_definitions(_GNU_SOURCE)
option(NO_OUTPUT "Disable USB HID output" OFF)
if(NOT HOOK_PATH)
set(HOOK_PATH "/home/pi/pikmreciever/hook.sh" CACHE STRING "Path to .sh toggle hook")
endif()
add_library(libusbgx INTERFACE)
target_sources(libusbgx INTERFACE
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/usbg.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/usbg_common.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/usbg_common_libconfig.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/usbg_schemes_libconfig.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/usbg_error.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/ether.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/ffs.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/hid.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/loopback.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/midi.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/ms.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/phonet.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/serial.c
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/uac2.c
)
# disable -Waddress-of-packed-member unaligned pointer warning
set_source_files_properties(
${CMAKE_CURRENT_LIST_DIR}/libusbgx/src/function/ether.c
PROPERTIES COMPILE_FLAGS
"-Wno-address-of-packed-member"
)
target_include_directories(libusbgx INTERFACE ${CMAKE_CURRENT_LIST_DIR}/libusbgx/include)
target_include_directories(libusbgx INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(libusbgx INTERFACE HAS_GADGET_SCHEMES)
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/libusbgx/include/usbg/usbg_version.h.in)
set(USBG_VERSION_HEX "0x00000000")
configure_file(${CMAKE_CURRENT_LIST_DIR}/libusbgx/include/usbg/usbg_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/usbg_version.h @ONLY)
else()
message(FATAL_ERROR "Missing usbg_version.h.in. Did you forget to `git submodule update --init`?")
endif()
find_library(libconfig libconfig)
# find_library(hidapi hidapi)
target_link_libraries(libusbgx INTERFACE config)
add_executable(
pikmreciever
pikmreciever.c
include/create-gadget-hid.c
include/remove-gadget-hid.c
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
HAS_GADGET_SCHEMES
HOOK_PATH="${HOOK_PATH}"
)
if(NO_OUTPUT)
target_compile_definitions(${PROJECT_NAME} PRIVATE NO_OUTPUT)
endif()
target_link_libraries(${PROJECT_NAME} libusbgx)
target_link_libraries(${PROJECT_NAME} hidapi-libusb)
install(FILES
${CMAKE_CURRENT_LIST_DIR}/hook.sh
${CMAKE_CURRENT_LIST_DIR}/pikmreciever.service
${CMAKE_CURRENT_LIST_DIR}/README.md
DESTINATION .
)
install(TARGETS ${PROJECT_NAME} DESTINATION .)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_GENERATOR "ZIP" "TGZ")
include(CPack)