From c6f47a098198f22922100346d13f054de4aace32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?=
Date: Sat, 2 Aug 2025 18:55:31 +0200 Subject: [PATCH] CMakeLists.txt: improve searching for hidapi Debian-based distributions don't include the CMake module. --- CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e91b48..c240a16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,13 +41,16 @@ pkg_check_modules (libusb libusb-1.0) # On MSYS2, the CMake package cannot link statically, but pkg-config can. # On macOS, we explicitly want to use the CMake package. -if (WIN32) +if (NOT WIN32) + find_package (hidapi QUIET) + if (hidapi_FOUND) + set (hidapi_INCLUDE_DIRS) + set (hidapi_LIBRARY_DIRS) + set (hidapi_LIBRARIES hidapi::hidapi) + endif () +endif () +if (NOT hidapi_FOUND) pkg_search_module (hidapi hidapi hidapi-hidraw hidapi-libusb) -else () - find_package (hidapi) - set (hidapi_INCLUDE_DIRS) - set (hidapi_LIBRARY_DIRS) - set (hidapi_LIBRARIES hidapi::hidapi) endif () option (WITH_LIBUSB "Compile with libusb-based utilities" ${libusb_FOUND})