cmake: Move PulseAudio detection to AudioCommon

This commit is contained in:
Florent Castelli 2017-02-07 23:28:01 +01:00
parent 22fbcc67fc
commit c1dcd06043
3 changed files with 56 additions and 16 deletions

View File

@ -440,19 +440,6 @@ else()
message(STATUS "bluez explicitly disabled, disabling bluetooth support")
endif()
if(ENABLE_PULSEAUDIO)
check_lib(PULSEAUDIO libpulse pulse QUIET)
if(PULSEAUDIO_FOUND)
add_definitions(-DHAVE_PULSEAUDIO=1)
message(STATUS "PulseAudio found, enabling PulseAudio sound backend")
else()
add_definitions(-DHAVE_PULSEAUDIO=0)
message(STATUS "PulseAudio NOT found, disabling PulseAudio sound backend")
endif()
else()
message(STATUS "PulseAudio explicitly disabled, disabling PulseAudio sound backend")
endif()
if(ENABLE_LLVM)
find_package(LLVM)
if (LLVM_FOUND)

View File

@ -0,0 +1,42 @@
# - Find PulseAudio library
# This module defines
# PulseAudio_INCLUDE_DIR
# PulseAudio_LIBRARIES
# PulseAudio_FOUND
#
# vim: expandtab sw=4 ts=4 sts=4:
include(FindPkgConfig)
pkg_check_modules (PulseAudio_PKG QUIET libpulse)
find_path(PulseAudio_INCLUDE_DIR NAMES pulse/pulseaudio.h
PATHS
${PulseAudio_PKG_INCLUDE_DIRS}
/usr/include/pulse
/usr/include
/usr/local/include/pulse
/usr/local/include
)
find_library(PulseAudio_LIBRARIES NAMES pulse
PATHS
${PulseAudio_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PulseAudio
REQUIRED_VARS PulseAudio_LIBRARIES PulseAudio_INCLUDE_DIR)
if(PulseAudio_FOUND)
if(NOT TARGET PulseAudio::PulseAudio)
add_library(PulseAudio::PulseAudio UNKNOWN IMPORTED)
set_target_properties(PulseAudio::PulseAudio PROPERTIES
IMPORTED_LOCATION ${PulseAudio_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${PulseAudio_INCLUDE_DIR}
)
endif()
endif()
mark_as_advanced(PulseAudio_INCLUDE_DIR PulseAudio_LIBRARIES)

View File

@ -60,9 +60,20 @@ else()
message(STATUS "OpenAL explicitly disabled, disabling OpenAL sound backend")
endif()
if(PULSEAUDIO_FOUND)
target_sources(audiocommon PRIVATE PulseAudioStream.cpp)
target_link_libraries(audiocommon PRIVATE ${PULSEAUDIO_LIBRARIES})
if(ENABLE_PULSEAUDIO)
# PulseAudio ships with a PulseAudioConfig.cmake with no imported target
# So we use our own FindPulseAudio instead with "MODULE"
find_package(PulseAudio MODULE QUIET)
if(PULSEAUDIO_FOUND)
message(STATUS "PulseAudio found, enabling PulseAudio sound backend")
target_sources(audiocommon PRIVATE PulseAudioStream.cpp)
target_link_libraries(audiocommon PRIVATE PulseAudio::PulseAudio)
target_compile_definitions(audiocommon PRIVATE HAVE_PULSEAUDIO=1)
else()
message(STATUS "PulseAudio NOT found, disabling PulseAudio sound backend")
endif()
else()
message(STATUS "PulseAudio explicitly disabled, disabling PulseAudio sound backend")
endif()
if(WIN32)