aboutsummaryrefslogtreecommitdiff
path: root/cmake/FindHIDAPI.cmake
diff options
context:
space:
mode:
authoriDunk5400 <iDunk5400@users.noreply.github.com>2018-10-06 13:57:23 +0200
committeriDunk5400 <iDunk5400@users.noreply.github.com>2018-10-06 16:48:14 +0200
commitcbdd6b910b3140f8ef317bd02ad1398bccff3bf0 (patch)
treea3679aabf8061cca704010e4b9511d8545ff973d /cmake/FindHIDAPI.cmake
parentMerge pull request #4472 (diff)
downloadmonero-cbdd6b910b3140f8ef317bd02ad1398bccff3bf0.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--cmake/FindHIDAPI.cmake14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmake/FindHIDAPI.cmake b/cmake/FindHIDAPI.cmake
index a689fb4eb..9b45dcc4c 100644
--- a/cmake/FindHIDAPI.cmake
+++ b/cmake/FindHIDAPI.cmake
@@ -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()