CMakeLists.txt: improve searching for hidapi
All checks were successful
Alpine 3.21 Success

Debian-based distributions don't include the CMake module.
This commit is contained in:
Přemysl Eric Janouch 2025-08-02 18:55:31 +02:00
parent c8f3b9ba38
commit c6f47a0981
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -41,14 +41,17 @@ 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)
pkg_search_module (hidapi hidapi hidapi-hidraw hidapi-libusb)
else ()
find_package (hidapi)
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)
endif ()
option (WITH_LIBUSB "Compile with libusb-based utilities" ${libusb_FOUND})
option (WITH_HIDAPI "Compile with hidapi-based utilities" ${hidapi_FOUND})