diff options
author | fuzzard <fuzzard@kodi.tv> | 2023-09-10 15:44:36 +1000 |
---|---|---|
committer | fuzzard <fuzzard@kodi.tv> | 2023-09-27 19:09:18 +1000 |
commit | a30bb554690dac6120351cf7a4bc57841600445a (patch) | |
tree | ea4b122cdb6aac1c586e707627b7a35cb6cc3361 /cmake/modules | |
parent | 6c05fdeb469e5218427c3f6cd3a7699f8f76a2ac (diff) |
[cmake] FindPulseAudio migrate to full TARGET usage
Diffstat (limited to 'cmake/modules')
-rw-r--r-- | cmake/modules/FindPulseAudio.cmake | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/cmake/modules/FindPulseAudio.cmake b/cmake/modules/FindPulseAudio.cmake index ce70a5fd66..c35a405a79 100644 --- a/cmake/modules/FindPulseAudio.cmake +++ b/cmake/modules/FindPulseAudio.cmake @@ -3,68 +3,68 @@ # -------------- # Finds the PulseAudio library # -# This will define the following variables:: +# This will define the following target: # -# PULSEAUDIO_FOUND - system has the PulseAudio library -# PULSEAUDIO_INCLUDE_DIRS - the PulseAudio include directory -# PULSEAUDIO_LIBRARIES - the libraries needed to use PulseAudio -# PULSEAUDIO_DEFINITIONS - the definitions needed to use PulseAudio -# -# and the following imported targets:: -# -# PulseAudio::PulseAudio - The PulseAudio library +# PulseAudio::PulseAudio - The PulseAudio library +# PulseAudio::PulseAudioSimple - The PulseAudio simple library +# PulseAudio::PulseAudioMainloop - The PulseAudio mainloop library -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_PULSEAUDIO libpulse>=11.0.0 QUIET) - pkg_check_modules(PC_PULSEAUDIO_MAINLOOP libpulse-mainloop-glib>=11.0.0 QUIET) - pkg_check_modules(PC_PULSEAUDIO_SIMPLE libpulse-simple>=11.0.0 QUIET) -endif() +if(NOT TARGET PulseAudio::PulseAudio) + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_PULSEAUDIO libpulse>=11.0.0 QUIET) + pkg_check_modules(PC_PULSEAUDIO_MAINLOOP libpulse-mainloop-glib>=11.0.0 QUIET) + pkg_check_modules(PC_PULSEAUDIO_SIMPLE libpulse-simple>=11.0.0 QUIET) + endif() -find_path(PULSEAUDIO_INCLUDE_DIR NAMES pulse/pulseaudio.h pulse/simple.h - PATHS ${PC_PULSEAUDIO_INCLUDEDIR} ${PC_PULSEAUDIO_INCLUDE_DIRS}) + find_path(PULSEAUDIO_INCLUDE_DIR NAMES pulse/pulseaudio.h pulse/simple.h + HINTS ${PC_PULSEAUDIO_INCLUDEDIR} ${PC_PULSEAUDIO_INCLUDE_DIRS} + NO_CACHE) -find_library(PULSEAUDIO_LIBRARY NAMES pulse libpulse - PATHS ${PC_PULSEAUDIO_LIBDIR} ${PC_PULSEAUDIO_LIBRARY_DIRS}) + find_library(PULSEAUDIO_LIBRARY NAMES pulse libpulse + HINTS ${PC_PULSEAUDIO_LIBDIR} ${PC_PULSEAUDIO_LIBRARY_DIRS} + NO_CACHE) -find_library(PULSEAUDIO_SIMPLE_LIBRARY NAMES pulse-simple libpulse-simple - PATHS ${PC_PULSEAUDIO_LIBDIR} ${PC_PULSEAUDIO_LIBRARY_DIRS}) + find_library(PULSEAUDIO_SIMPLE_LIBRARY NAMES pulse-simple libpulse-simple + HINTS ${PC_PULSEAUDIO_LIBDIR} ${PC_PULSEAUDIO_LIBRARY_DIRS} + NO_CACHE) -find_library(PULSEAUDIO_MAINLOOP_LIBRARY NAMES pulse-mainloop pulse-mainloop-glib libpulse-mainloop-glib - PATHS ${PC_PULSEAUDIO_LIBDIR} ${PC_PULSEAUDIO_LIBRARY_DIRS}) + find_library(PULSEAUDIO_MAINLOOP_LIBRARY NAMES pulse-mainloop pulse-mainloop-glib libpulse-mainloop-glib + HINTS ${PC_PULSEAUDIO_LIBDIR} ${PC_PULSEAUDIO_LIBRARY_DIRS} + NO_CACHE) -if(PC_PULSEAUDIO_VERSION) - set(PULSEAUDIO_VERSION_STRING ${PC_PULSEAUDIO_VERSION}) -elseif(PULSEAUDIO_INCLUDE_DIR AND EXISTS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h") - file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulseaudio_version_str REGEX "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\).*") - string(REGEX REPLACE "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]+)\"\\).*" "\\1" PULSEAUDIO_VERSION_STRING "${pulseaudio_version_str}") - unset(pulseaudio_version_str) -endif() + if(PC_PULSEAUDIO_VERSION) + set(PULSEAUDIO_VERSION_STRING ${PC_PULSEAUDIO_VERSION}) + elseif(PULSEAUDIO_INCLUDE_DIR AND EXISTS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h") + file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulseaudio_version_str REGEX "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\).*") + string(REGEX REPLACE "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]+)\"\\).*" "\\1" PULSEAUDIO_VERSION_STRING "${pulseaudio_version_str}") + unset(pulseaudio_version_str) + endif() -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PulseAudio - REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_MAINLOOP_LIBRARY PULSEAUDIO_SIMPLE_LIBRARY PULSEAUDIO_INCLUDE_DIR - VERSION_VAR PULSEAUDIO_VERSION_STRING) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(PulseAudio + REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_MAINLOOP_LIBRARY PULSEAUDIO_SIMPLE_LIBRARY PULSEAUDIO_INCLUDE_DIR + VERSION_VAR PULSEAUDIO_VERSION_STRING) -if(PULSEAUDIO_FOUND) - set(PULSEAUDIO_INCLUDE_DIRS ${PULSEAUDIO_INCLUDE_DIR}) - set(PULSEAUDIO_LIBRARIES ${PULSEAUDIO_LIBRARY} ${PULSEAUDIO_MAINLOOP_LIBRARY} ${PULSEAUDIO_SIMPLE_LIBRARY}) - set(PULSEAUDIO_DEFINITIONS -DHAS_PULSEAUDIO=1) - list(APPEND AUDIO_BACKENDS_LIST "pulseaudio") - set(AUDIO_BACKENDS_LIST ${AUDIO_BACKENDS_LIST} PARENT_SCOPE) + if(PULSEAUDIO_FOUND) + list(APPEND AUDIO_BACKENDS_LIST "pulseaudio") + set(AUDIO_BACKENDS_LIST ${AUDIO_BACKENDS_LIST} PARENT_SCOPE) + + add_library(PulseAudio::PulseAudioSimple UNKNOWN IMPORTED) + set_target_properties(PulseAudio::PulseAudioSimple PROPERTIES + IMPORTED_LOCATION "${PULSEAUDIO_SIMPLE_LIBRARY}") - if(NOT TARGET PulseAudio::PulseAudioMainloop) add_library(PulseAudio::PulseAudioMainloop UNKNOWN IMPORTED) set_target_properties(PulseAudio::PulseAudioMainloop PROPERTIES IMPORTED_LOCATION "${PULSEAUDIO_MAINLOOP_LIBRARY}") - endif() - if(NOT TARGET PulseAudio::PulseAudio) + add_library(PulseAudio::PulseAudio UNKNOWN IMPORTED) set_target_properties(PulseAudio::PulseAudio PROPERTIES IMPORTED_LOCATION "${PULSEAUDIO_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${PULSEAUDIO_INCLUDE_DIR}" INTERFACE_COMPILE_DEFINITIONS HAVE_LIBPULSE=1 - INTERFACE_LINK_LIBRARIES PulseAudio::PulseAudioMainloop) + INTERFACE_LINK_LIBRARIES "PulseAudio::PulseAudioMainloop;PulseAudio::PulseAudioSimple") + + set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP PulseAudio::PulseAudio) endif() endif() - -mark_as_advanced(PULSEAUDIO_INCLUDE_DIR PULSEAUDIO_LIBRARY PULSEAUDIO_MAINLOOP_LIBRARY PULSEAUDIO_SIMPLE_LIBRARY) |