diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 073b80b3d..134b177f4 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -21,7 +21,7 @@ target_sources( finders/FindOSS.cmake finders/FindPulseAudio.cmake finders/Findudev.cmake - finders/Finduhid.cmake + finders/Findusbhid.cmake macos/dependencies.cmake macos/compilerconfig.cmake macos/defaults.cmake diff --git a/cmake/finders/Finduhid.cmake b/cmake/finders/Finduhid.cmake deleted file mode 100644 index 53fe8791d..000000000 --- a/cmake/finders/Finduhid.cmake +++ /dev/null @@ -1,67 +0,0 @@ -#[=======================================================================[.rst: -Finduhid -------- - -Finds the usbhid library. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module provides the following imported targets, if found: - -``uhid::uhid`` - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``uhid_FOUND`` - True if the system has uhid. -``uhid_LIBRARIES`` - The location of the usbhid library. -``uhid_INCLUDE_DIR`` - Include directories needed to use uhid. - -#]=======================================================================] - -include(FindPackageHandleStandardArgs) - -find_path( - uhid_INCLUDE_DIR - NAMES usbhid.h /dev/usb/usbhid.h - PATHS /usr/include /usr/local/include - DOC "uhid include directory" -) - -find_library( - uhid_LIBRARIES - NAMES usbhid - PATHS /usr/lib /usr/local/lib - DOC "uhid location" -) - -set(uhid_VERSION ${CMAKE_HOST_SYSTEM_VERSION}) - -find_package_handle_standard_args( - uhid - REQUIRED_VARS uhid_INCLUDE_DIR uhid_LIBRARIES - VERSION_VAR uhid_VERSION - REASON_FAILURE_MESSAGE "Ensure that uhid is installed on the system." -) -mark_as_advanced(uhid_INCLUDE_DIR uhid_LIBRARY) - -if(uhid_FOUND) - if(NOT TARGET uhid::uhid) - add_library(uhid::uhid MODULE IMPORTED) - set_property(TARGET uhid::uhid PROPERTY IMPORTED_LOCATION "${uhid_LIBRARIES}") - - set_target_properties( - uhid::uhid - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${uhid_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${uhid_LIBRARIES}" - VERSION ${uhid_VERSION} - ) - endif() -endif() diff --git a/cmake/finders/Findusbhid.cmake b/cmake/finders/Findusbhid.cmake new file mode 100644 index 000000000..a36a4a267 --- /dev/null +++ b/cmake/finders/Findusbhid.cmake @@ -0,0 +1,67 @@ +#[=======================================================================[.rst: +Findusbhid +------- + +Finds the usbhid library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``usbhid::usbhid`` + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``usbhid_FOUND`` + True if the system has usbhid. +``usbhid_LIBRARIES`` + The location of the usbhid library. +``usbhid_INCLUDE_DIR`` + Include directories needed to use usbhid. + +#]=======================================================================] + +include(FindPackageHandleStandardArgs) + +find_path( + usbhid_INCLUDE_DIR + NAMES usbhid.h /dev/usb/usbhid.h + PATHS /usr/include /usr/local/include + DOC "usbhid include directory" +) + +find_library( + usbhid_LIBRARIES + NAMES usbhid + PATHS /usr/lib /usr/local/lib + DOC "usbhid location" +) + +set(usbhid_VERSION ${CMAKE_HOST_SYSTEM_VERSION}) + +find_package_handle_standard_args( + usbhid + REQUIRED_VARS usbhid_INCLUDE_DIR usbhid_LIBRARIES + VERSION_VAR usbhid_VERSION + REASON_FAILURE_MESSAGE "Ensure that usbhid is installed on the system." +) +mark_as_advanced(usbhid_INCLUDE_DIR usbhid_LIBRARY) + +if(usbhid_FOUND) + if(NOT TARGET usbhid::usbhid) + add_library(usbhid::usbhid MODULE IMPORTED) + set_property(TARGET usbhid::usbhid PROPERTY IMPORTED_LOCATION "${usbhid_LIBRARIES}") + + set_target_properties( + usbhid::usbhid + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${usbhid_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${usbhid_LIBRARIES}" + VERSION ${usbhid_VERSION} + ) + endif() +endif() diff --git a/ruby/cmake/os-linux.cmake b/ruby/cmake/os-linux.cmake index 67ec6beeb..5fb9002fe 100644 --- a/ruby/cmake/os-linux.cmake +++ b/ruby/cmake/os-linux.cmake @@ -117,14 +117,14 @@ else() target_disable_feature(ruby "udev input driver") endif() -option(ARES_ENABLE_UHID "Enable the uhid input driver" ON) -if(ARES_ENABLE_UHID) - find_package(uhid) +option(ARES_ENABLE_USBHID "Enable the usbhid input driver" ON) +if(ARES_ENABLE_USBHID) + find_package(usbhid) endif() -if(uhid_FOUND) - target_enable_feature(ruby "uhid input driver" INPUT_UHID) +if(usbhid_FOUND) + target_enable_feature(ruby "usbhid input driver" INPUT_UHID) else() - target_disable_feature(ruby "uhid input driver") + target_disable_feature(ruby "usbhid input driver") endif() target_link_libraries( @@ -139,5 +139,5 @@ target_link_libraries( $<$:PulseAudio::PulseAudioSimple> $<$:AO::AO> $<$:udev::udev> - $<$:uhid::uhid> + $<$:usbhid::usbhid> )