From ee7a60d5d7a3815d2f5ba6a5a4b5588ff6a8f815 Mon Sep 17 00:00:00 2001 From: Martin Müller Date: Mon, 14 Jan 2019 02:56:35 +0100 Subject: CMake: Try to use pkg-config for hidapi on macOS --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 119ca79..f0fe6e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,10 +76,16 @@ add_library(nitrokey ${SOURCE_FILES}) set(HIDAPI_LIBUSB_NAME hidapi-libusb) IF(APPLE) - include_directories(hidapi/hidapi) - add_library(hidapi-libusb STATIC hidapi/mac/hid.c ) - target_link_libraries(hidapi-libusb "-framework CoreFoundation" "-framework IOKit") - target_link_libraries(nitrokey hidapi-libusb) + find_package(PkgConfig) + IF(PKG_CONFIG_FOUND) + pkg_search_module(HIDAPI REQUIRED hidapi) + target_link_libraries(nitrokey ${HIDAPI_LDFLAGS}) + ELSE() + include_directories(hidapi/hidapi) + add_library(hidapi-libusb STATIC hidapi/mac/hid.c ) + target_link_libraries(hidapi-libusb "-framework CoreFoundation" "-framework IOKit") + target_link_libraries(nitrokey hidapi-libusb) + ENDIF() ELSEIF(UNIX) # add_library(hidapi-libusb STATIC hidapi/libusb/hid.c ) find_package(PkgConfig) -- cgit v1.2.3