From a47058981611bacae464ed6deac39c6686357f3a Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 31 Dec 2018 19:14:59 +0000 Subject: Link to hidapi on non-Linux systems According to the hidapi README [0], only Linux provides two different hidapi backends. Therefore this patch changes the build script to default to linking to hidapi on non-Linux systems. This patch fixes the macOS build issue reported by Philippe Normand and is based on the patch proposed by Philippe Normand at [1]. [0] https://github.com/signal11/hidapi/blob/master/README.txt [1] https://github.com/d-e-s-o/nitrocli/pull/42 --- CHANGELOG.md | 2 ++ build.rs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 492afa0..26f88a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased - Use the -std=c++14 compiler flag. +- Change the build script to link to `-lhidapi` on non-Linux operating systems + (while still using `-lhidapi-libusb` on Linux). # v3.4.1 (2018-12-10) diff --git a/build.rs b/build.rs index 38950d3..c52bf34 100644 --- a/build.rs +++ b/build.rs @@ -101,5 +101,10 @@ fn main() { .file(version_source) .compile("libnitrokey.a"); - println!("cargo:rustc-link-lib=hidapi-libusb"); + let hidapi_library_name = if cfg!(target_os = "linux") { + "hidapi-libusb" + } else { + "hidapi" + }; + println!("cargo:rustc-link-lib={}", hidapi_library_name); } -- cgit v1.2.1