diff --git a/CMakeLists.txt b/CMakeLists.txt index 1004baf3..924762a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,10 +74,16 @@ set(BUILD_SHARED_LIBS ON CACHE BOOL "Build all libraries as shared") add_library(nitrokey ${SOURCE_FILES}) 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)