-
Notifications
You must be signed in to change notification settings - Fork 474
Originally posted by @madebr in #681 (comment) :
For this, SDL uses a FindLibUSB.cmake module and a GitHub prebuilt release to provide binaries
All reactions
Replies: 4 comments 5 replies
FYI, it looks like your cmake script does not allow for easy building of hidapi with libusb.
Define what do you expect to be easy.
I'm using libusb-cmake and because of this (need add_subdirectory(libusb) before add_subdirectory(hidapi) ) - it is quite trivial.
All reactions
Originally posted by @madebr in #681 (comment)
Define what do you expect to be easy.
By easy, I mean the cmake script does need no modifications and can build with libusb support (using a system library) without needing to building libusb yourself.
Lines 40 to 48 in 4578ea2
Lines 110 to 130 in 4578ea2
HIDAPI_WITH_LIBUSB is not used on Windows
I'm using libusb-cmake and because of this (need
add_subdirectory(libusb)beforeadd_subdirectory(hidapi)) - it is quite trivial.
It works, but you're effectively using a fork and do not use upstream.
For SDL's use case, we don't want this hard dependency: users should bring their own libusb.
This is also valid for every (mingw) distribution (e.g. msys2)
One more thing - do you thing we could update HIDAPI CI script to catch this/similar issues in the future?
Looking at SDL's cmake script, we've added a SDL_WERROR cmake option to build with -Werror//WX (default off, enabled on ci).
Recent CMake versions have a cmake property for this: configure with -DCMAKE_COMPILER_WARNING_AS_ERROR=1.
We don't pass a special MSVC warning flag.
All reactions
By easy, I mean the cmake script does need no modifications and can build with libusb support (using a system library) without needing to building libusb yourself.
HIDAPI_WITH_LIBUSB is not used on Windows
This is also valid for every (mingw) distribution (e.g. msys2)
libusb backend for HIDAPI officially supported only on a number of platforms but Windows is not one of them. If you happen to use libusb backend of HIDAPI on Windows - you must be using modified or your own build script for HIDAPI, which is not official distribution as of yet.
On those supported platforms, libusb officially distributed in a way that pkg-config should be used to find it, and this part of HIDAPI CMake script handles it, at least according to my testing. Are you saying it doesn't work in your environemnt?
Looking at SDL's cmake script, we've added a SDL_WERROR cmake option to build with -Werror//WX (default off, enabled on ci).
We have /WX on our CI too, so I wounder why it wasn't caught...
All reactions
On those supported platforms, libusb officially distributed in a way that pkg-config should be used to find it, and this part of HIDAPI CMake script handles it, at least according to my testing. Are you saying it doesn't work in your environemnt?
pkg-config is a unix-ism, and is not commonly installed on MSVC development systems.
The "CMake way" is to use modules.
(SDL's FindLibUSB.cmake uses pkg-config as a hint)
I know there's pkgconf, which works well on Windows, but building with MSVC in autoconf in a bash shell is an adventure on itself.
But again, the "official" libusb MSVC binaries don't contain pc files so pkgconf won't find anything.
All reactions
Again, libusb backend is not supported by HIDAPI on Windows, specially with MSVC. What is your use-case?
All reactions
Oh, SDL3 allows me to configure and build in this configuration.
I assumed this was a working combination.
All reactions
Maybe it is working in some environments, but it is not officially supported by HIDAPI build system or sources (yet).
All reactions
I think SDL heavily patched hidapi. That's why there lives a fork inside SDL.
All reactions
I caught this on a local MSVC instance, which apparently warned about this.
I don't know how to reproduce the warning in a fresh project (apart from adding /W3).
On gcc, you can warn with -Wconversion and -Wfloat-conversion.