Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LIBUSB_ENABLE_UDEV option #20

Merged
merged 5 commits into from
Dec 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ option(LIBUSB_TARGETS_INCLUDE_USING_SYSTEM "Make targets include paths System" O

option(LIBUSB_ENABLE_LOGGING "Enable Logging" ON)
option(LIBUSB_ENABLE_DEBUG_LOGGING "Enable Debug Logging" OFF)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
option(LIBUSB_ENABLE_UDEV "Enable udev backend for device enumeration" ON)
endif()

set(LIBUSB_GEN_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}/gen_include")
generate_config_file()
Expand Down Expand Up @@ -160,13 +163,22 @@ else()
)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
target_sources(usb-1.0 PRIVATE
"${LIBUSB_ROOT}/os/linux_udev.c"
"${LIBUSB_ROOT}/os/linux_usbfs.c"
"${LIBUSB_ROOT}/os/linux_usbfs.h"
)
if(LIBUSB_ENABLE_UDEV)
target_sources(usb-1.0 PRIVATE
"${LIBUSB_ROOT}/os/linux_udev.c"
)
target_link_libraries(usb-1.0 PRIVATE udev)
target_compile_definitions(usb-1.0 PRIVATE HAVE_LIBUDEV=1)
else()
target_sources(usb-1.0 PRIVATE
"${LIBUSB_ROOT}/os/linux_netlink.c"
)
endif()
find_package(Threads REQUIRED)
target_link_libraries(usb-1.0 PRIVATE udev Threads::Threads)
target_compile_definitions(usb-1.0 PRIVATE HAVE_LIBUDEV=1)
target_link_libraries(usb-1.0 PRIVATE Threads::Threads)
elseif(ANDROID)
target_sources(usb-1.0 PRIVATE
"${LIBUSB_ROOT}/os/linux_netlink.c"
Expand Down