Skip to content

Commit

Permalink
build: Add missing Linux drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 committed Nov 12, 2024
1 parent 64d16e8 commit 863f50f
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ target_sources(
finders/FindAO.cmake
finders/FindOSS.cmake
finders/FindPulseAudio.cmake
finders/Findudev.cmake
finders/Finduhid.cmake
macos/dependencies.cmake
macos/compilerconfig.cmake
macos/defaults.cmake
Expand Down
2 changes: 1 addition & 1 deletion cmake/common/compiler_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include_guard(GLOBAL)
option(ARES_COMPILE_DEPRECATION_AS_WARNING "Downgrade deprecation warnings to actual warnings" FALSE)
mark_as_advanced(ARES_COMPILE_DEPRECATION_AS_WARNING)

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION $<$<CONFIG:RelWithDebInfo,Release>:TRUE>)

# Set C and C++ language standards to C17 and C++17
set(CMAKE_C_STANDARD 17)
Expand Down
1 change: 0 additions & 1 deletion cmake/finders/FindOSS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ include(FindPackageHandleStandardArgs)
find_path(
OSS_INCLUDE_DIR
NAMES sys/soundcard.h
HINTS ${PC_OSS_INCLUDE_DIRS}
PATHS /usr/include /usr/local/include
DOC "OSS include directory"
)
Expand Down
26 changes: 24 additions & 2 deletions cmake/finders/FindPulseAudio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ find_library(
DOC "PulseAudio location"
)

find_library(
PulseAudioSimple_LIBRARY
NAMES pulse-simple
HINTS ${PC_PulseAudio_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib
DOC "PulseAudioSimple location"
)

set(PulseAudio_VERSION ${PC_PulseAudio_VERSION})

find_package_handle_standard_args(
PulseAudio
REQUIRED_VARS PulseAudio_INCLUDE_DIR PulseAudio_LIBRARY
REQUIRED_VARS PulseAudio_INCLUDE_DIR PulseAudio_LIBRARY PulseAudioSimple_LIBRARY
VERSION_VAR PulseAudio_VERSION
REASON_FAILURE_MESSAGE "Ensure that PulseAudio is available in local library paths."
REASON_FAILURE_MESSAGE "Ensure that PulseAudio and PulseAudioSimple are available in local library paths."
)
mark_as_advanced(PulseAudio_INCLUDE_DIR PulseAudio_LIBRARY)

Expand All @@ -40,6 +48,13 @@ if(PulseAudio_FOUND)
add_library(PulseAudio::PulseAudio INTERFACE IMPORTED)
set_property(TARGET PulseAudio::PulseAudio PROPERTY IMPORTED_LIBNAME "${PulseAudio_LIBRARY}")
endif()
if(IS_ABSOLUTE "${PulseAudioSimple_LIBRARY}")
add_library(PulseAudio::PulseAudioSimple UNKNOWN IMPORTED)
set_property(TARGET PulseAudio::PulseAudioSimple PROPERTY IMPORTED_LOCATION "${PulseAudioSimple_LIBRARY}")
else()
add_library(PulseAudio::PulseAudioSimple INTERFACE IMPORTED)
set_property(TARGET PulseAudio::PulseAudioSimple PROPERTY IMPORTED_LIBNAME "${PulseAudioSimple_LIBRARY}")
endif()

set_target_properties(
PulseAudio::PulseAudio
Expand All @@ -48,6 +63,13 @@ if(PulseAudio_FOUND)
INTERFACE_INCLUDE_DIRECTORIES "${PulseAudio_INCLUDE_DIR}"
VERSION ${PulseAudio_VERSION}
)
set_target_properties(
PulseAudio::PulseAudioSimple
PROPERTIES
INTERFACE_COMPILE_OPTIONS "${PC_PulseAudio_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${PulseAudio_INCLUDE_DIR}"
VERSION ${PulseAudio_VERSION}
)
endif()
endif()

Expand Down
90 changes: 90 additions & 0 deletions cmake/finders/Findudev.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#[=======================================================================[.rst:
Findudev
-------
Finds the udev library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``udev::udev``
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``udev_FOUND``
True if the system has udev.
``udev_VERSION``
The version of udev which was found.
``udev_INCLUDE_DIR``
Include directories needed to use udev.
``udev_LIBRARIES``
Libraries needed to link to udev.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
.
``GTK_LIBRARY``
The path to the udev library.
#]=======================================================================]

include(FindPackageHandleStandardArgs)

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_udev QUIET udev)
endif()

find_path(
udev_INCLUDE_DIR
NAMES libudev.h
HINTS ${PC_udev_INCLUDE_DIRS}
PATHS /usr/include /usr/local/include
DOC "udev include directory"
)

find_library(
udev_LIBRARIES
NAMES udev
HINTS ${PC_udev_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib
DOC "udev location"
)

set(udev_VERSION ${PC_udev_VERSION})
set(udev_ERROR_REASON "Ensure udev libraries are available in local library paths.")

find_package_handle_standard_args(
udev
REQUIRED_VARS udev_LIBRARIES udev_INCLUDE_DIR
REASON_FAILURE_MESSAGE "${udev_ERROR_REASON}"
)
mark_as_advanced(udev_INCLUDE_DIR udev_LIBRARIES)
unset(udev_ERROR_REASON)

if(udev_FOUND)
if(NOT TARGET udev::udev)
add_library(udev::udev UNKNOWN IMPORTED)
set_property(TARGET udev::udev PROPERTY IMPORTED_LOCATION "${udev_LIBRARIES}")

message(AUTHOR_WARNING "udev libraries are ${udev_LIBRARIES}")
set_target_properties(
udev::udev
PROPERTIES
INTERFACE_COMPILE_OPTIONS "${PC_udev_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${PC_udev_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${udev_LIBRARIES}"
VERSION "${udev_VERSION}"
)
endif()
endif()

include(FeatureSummary)
set_package_properties(udev PROPERTIES URL "https://www.freedesktop.org/software/systemd/man/latest/libudev.html" DESCRIPTION "libudev.h provides an API to introspect and enumerate devices on the local system.")
67 changes: 67 additions & 0 deletions cmake/finders/Finduhid.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#[=======================================================================[.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()
25 changes: 24 additions & 1 deletion ruby/cmake/os-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if(ARES_ENABLE_PULSEAUDIO)
find_package(PulseAudio)
endif()
if(PulseAudio_FOUND)
target_enable_feature(ruby "PulseAudio audio driver" AUDIO_PULSEAUDIO)
target_enable_feature(ruby "PulseAudio audio driver" AUDIO_PULSEAUDIO AUDIO_PULSEAUDIOSIMPLE)
else()
target_disable_feature(ruby "PulseAudio audio driver")
endif()
Expand All @@ -107,6 +107,26 @@ else()
target_disable_feature(ruby "AO audio driver")
endif()

option(ARES_ENABLE_UDEV "Enable the udev input driver" ON)
if(ARES_ENABLE_UDEV)
find_package(udev)
endif()
if(udev_FOUND)
target_enable_feature(ruby "udev input driver" INPUT_UDEV)
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)
endif()
if(uhid_FOUND)
target_enable_feature(ruby "uhid input driver" INPUT_UHID)
else()
target_disable_feature(ruby "uhid input driver")
endif()

target_link_libraries(
ruby
PRIVATE
Expand All @@ -116,5 +136,8 @@ target_link_libraries(
$<$<BOOL:${OSS_FOUND}>:OSS::OSS>
$<$<BOOL:${ALSA_FOUND}>:ALSA::ALSA>
$<$<BOOL:${PulseAudio_FOUND}>:PulseAudio::PulseAudio>
$<$<BOOL:${PulseAudio_FOUND}>:PulseAudio::PulseAudioSimple>
$<$<BOOL:${AO_FOUND}>:AO::AO>
$<$<BOOL:${udev_FOUND}>:udev::udev>
$<$<BOOL:${uhid_FOUND}>:uhid::uhid>
)

0 comments on commit 863f50f

Please sign in to comment.