Skip to content

Commit

Permalink
Add PulseAudio find module
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 committed Nov 5, 2024
1 parent 57dc192 commit 2ef4db6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
59 changes: 59 additions & 0 deletions cmake/finders/FindPulseAudio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
include(FindPackageHandleStandardArgs)

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_search_module(PC_PulseAudio QUIET libpulse)
endif()

find_path(
PulseAudio_INCLUDE_DIR
NAMES pulse/pulseaudio.h
HINTS ${PC_PulseAudio_INCLUDE_DIRS}
PATHS /usr/include/ /usr/local/include
DOC "PulseAudio include directory"
)

find_library(
PulseAudio_LIBRARY
NAMES pulse
HINTS ${PC_PulseAudio_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib
DOC "PulseAudio location"
)

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

if(PulseAudio_FOUND)
if(NOT TARGET PulseAudio::PulseAudio)
if(IS_ABSOLUTE "${PulseAudio_LIBRARY}")
add_library(PulseAudio::PulseAudio UNKNOWN IMPORTED)
set_property(TARGET PulseAudio::PulseAudio PROPERTY IMPORTED_LOCATION "${PulseAudio_LIBRARY}")
else()
add_library(PulseAudio::PulseAudio INTERFACE IMPORTED)
set_property(TARGET PulseAudio::PulseAudio PROPERTY IMPORTED_LIBNAME "${PulseAudio_LIBRARY}")
endif()

set_target_properties(
PulseAudio::PulseAudio
PROPERTIES
INTERFACE_COMPILE_OPTIONS "${PC_PulseAudio_CFLAFGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${PulseAudio_INCLUDE_DIR}"
VERSION ${PulseAudio_VERSION}
)
endif()
endif()

include(FeatureSummary)
set_package_properties(
PulseAudio
PROPERTIES
URL "https://www.freedesktop.org/wiki/Software/PulseAudio/"
DESCRIPTION
"PulseAudio is a sound server system for POSIX OSes, meaning that it is a proxy for your sound applications."
)
2 changes: 1 addition & 1 deletion ruby/cmake/os-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ target_link_libraries(
$<$<BOOL:TRUE>:librashader::librashader>
$<$<BOOL:${OSS_FOUND}>:OSS::OSS>
$<$<BOOL:${ALSA_FOUND}>:ALSA::ALSA>
$<$<BOOL:${PulseAudio_FOUND}>:pulse>
$<$<BOOL:${PulseAudio_FOUND}>:PulseAudio::PulseAudio>
$<$<BOOL:${AO_FOUND}>:AO::AO>
)

0 comments on commit 2ef4db6

Please sign in to comment.