make HIDAPI link more robust
authorKonrad Rosenbaum <konrad@silmor.de>
Wed, 18 Nov 2015 12:44:50 +0000 (13:44 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Wed, 18 Nov 2015 12:52:03 +0000 (13:52 +0100)
add fido u2f

plugins/bcs-usb/hidapi.pri
plugins/fido-u2f/fido-u2f.pro [new file with mode: 0644]
plugins/plugins.pro

index 9b0ba28..83bca94 100644 (file)
@@ -4,17 +4,35 @@ HIDAPIDIR = $$PWD/../../hidapi
 
 INCLUDEPATH += $$HIDAPIDIR/hidapi
 
-linux {
-        SOURCES += $$HIDAPIDIR/libusb/hid.c
-        CONFIG += link_pkgconfig
-        PKGCONFIG += libusb-1.0
-}
-win32 {
+CONFIG += link_pkgconfig
+
+packagesExist(hidapi-hidraw) {
+       PKGCONFIG += hidapi-hidraw
+       message("Pkg-Config: using HIDAPI with HIDraw interface")
+} else {
+  packagesExist(hidapi) {
+       PKGCONFIG += hidapi
+       message("Pkg-Config: using HIDAPI with default interface")
+  } else {
+    packagesExist(hidapi-libusb) {
+       PKGCONFIG += hidapi-libusb
+       message("Pkg-Config: using HIDAPI with libusb interface")
+    } else {
+      linux {
+        SOURCES += $$HIDAPIDIR/linux/hid.c
+       message("Using built-in HIDAPI for Linux")
+      }
+      win32 {
         SOURCES += $$HIDAPIDIR/windows/hid.c
         LIBS += -lsetupapi
-}
-mac {
+       message("Using built-in HIDAPI for Windows")
+      }
+      mac {
         SOURCES += $$HIDAPIDIR/mac
         #from mac/Makefile-manual, not sure how to use this:
         #LIBS += -framework IOKit -framework CoreFoundation
+       message("Using built-in HIDAPI for MacOS/X")
+      }
+    }
+  }
 }
diff --git a/plugins/fido-u2f/fido-u2f.pro b/plugins/fido-u2f/fido-u2f.pro
new file mode 100644 (file)
index 0000000..808c115
--- /dev/null
@@ -0,0 +1,18 @@
+TEMPLATE = lib
+TARGET = msp-fido-u2f
+CONFIG += plugin no_plugin_name_prefix
+
+include (../../basics.pri)
+include (../../src/smoke.pri)
+
+#SOURCES += bcs-plugin.cpp configwidget.cpp bcskeyboard.cpp hidscanner.cpp
+#HEADERS += bcs-plugin.h configwidget.h bcskeyboard.h hidscanner.h
+
+CONFIG += link_pkgconfig
+
+packagesExist(u2f-host u2f-server) {
+       PKGCONFIG += u2f-host u2f-server
+       message("Pkg-Config: U2F libs found")
+} else {
+       error("Pkg-Config: U2F libs not found!")
+}
index 88a3553..c7f19dc 100644 (file)
@@ -1,2 +1,2 @@
 TEMPLATE = subdirs
-SUBDIRS = bcs-usb
\ No newline at end of file
+SUBDIRS = bcs-usb fido-u2f