Linux: Fix building of static binaries with hw device support

This should enable building static binaries on Linux systems where dependencies are already built with -fPIC, such as Ubuntu 18.04.
This commit is contained in:
iDunk5400 2018-10-06 13:57:23 +02:00
parent 79d46c4d55
commit cbdd6b910b
No known key found for this signature in database
GPG key ID: 0F1715596D812FD8

View file

@ -39,6 +39,20 @@ find_package_handle_standard_args(HIDAPI
if(HIDAPI_FOUND)
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARY}")
if((STATIC AND UNIX AND NOT APPLE) OR (DEPENDS AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
find_library(LIBUSB-1.0_LIBRARY usb-1.0)
find_library(LIBUDEV_LIBRARY udev)
if(LIBUSB-1.0_LIBRARY)
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUSB-1.0_LIBRARY}")
if(LIBUDEV_LIBRARY)
set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUDEV_LIBRARY}")
else()
message(WARNING "libudev library not found, binaries may fail to link.")
endif()
else()
message(WARNING "libusb-1.0 library not found, binaries may fail to link.")
endif()
endif()
set(HIDAPI_INCLUDE_DIRS "${HIDAPI_INCLUDE_DIR}")
endif()