add CMake config (#20) master
authorChristoph Gysin <christoph.gysin@gmail.com>
Mon, 24 Jul 2017 17:22:15 +0000 (20:22 +0300)
committerPavel A <pavel-a@users.noreply.github.com>
Mon, 24 Jul 2017 17:22:15 +0000 (20:22 +0300)
fixes #7

commandline/CMakeLists.txt [new file with mode: 0644]

diff --git a/commandline/CMakeLists.txt b/commandline/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bb3383e
--- /dev/null
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 3.0)
+project(hidusb-relay)
+
+if(WIN32)
+    message("Building against hid")
+    set(SOURCES hiddata_mswin.c)
+    set(LIBRARIES hid setupapi)
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin AND NOT USE_LIBUSB_ON_MACOS)
+    option(USE_LIBUSB_ON_MACOS "Use libusb instead of IOKit on MacOS" ON)
+
+    set(SOURCES hiddata_osx.c)
+    set(LIBRARIES
+        "-framework CoreFoundation"
+        "-framework IOKit"
+    )
+else()
+    set(SOURCES hiddata_libusb01.c)
+    include(FindPkgConfig)
+    pkg_check_modules(LIBUSB REQUIRED libusb)
+    include_directories(${LIBUSB_INCLUDE_DIRS})
+    set(LIBRARIES ${LIBUSB_LIBRARIES})
+endif()
+
+add_library(hidusb-relay SHARED ${SOURCES})
+target_link_libraries(hidusb-relay ${LIBRARIES})
+
+add_executable(hidusb-relay-cmd usbrelay-cmd.c)
+target_link_libraries(hidusb-relay-cmd hidusb-relay)