add CMake config (#20)
[usb-relay-hid.git] / commandline / CMakeLists.txt
CommitLineData
87cf2d92
CG
1cmake_minimum_required(VERSION 3.0)
2project(hidusb-relay)
3
4if(WIN32)
5 message("Building against hid")
6 set(SOURCES hiddata_mswin.c)
7 set(LIBRARIES hid setupapi)
8elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin AND NOT USE_LIBUSB_ON_MACOS)
9 option(USE_LIBUSB_ON_MACOS "Use libusb instead of IOKit on MacOS" ON)
10
11 set(SOURCES hiddata_osx.c)
12 set(LIBRARIES
13 "-framework CoreFoundation"
14 "-framework IOKit"
15 )
16else()
17 set(SOURCES hiddata_libusb01.c)
18 include(FindPkgConfig)
19 pkg_check_modules(LIBUSB REQUIRED libusb)
20 include_directories(${LIBUSB_INCLUDE_DIRS})
21 set(LIBRARIES ${LIBUSB_LIBRARIES})
22endif()
23
24add_library(hidusb-relay SHARED ${SOURCES})
25target_link_libraries(hidusb-relay ${LIBRARIES})
26
27add_executable(hidusb-relay-cmd usbrelay-cmd.c)
28target_link_libraries(hidusb-relay-cmd hidusb-relay)