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,13 +41,16 @@ pkg_check_modules (libusb libusb-1.0)
# On MSYS2, the CMake package cannot link statically, but pkg-config can. # On MSYS2, the CMake package cannot link statically, but pkg-config can.
# On macOS, we explicitly want to use the CMake package. # 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) 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 () endif ()
option (WITH_LIBUSB "Compile with libusb-based utilities" ${libusb_FOUND}) option (WITH_LIBUSB "Compile with libusb-based utilities" ${libusb_FOUND})