1# - Find PulseAudio includes and libraries
2#
3#   PULSEAUDIO_FOUND        - True if PULSEAUDIO_INCLUDE_DIR &
4#                             PULSEAUDIO_LIBRARY are found
5#   PULSEAUDIO_LIBRARIES    - Set when PULSEAUDIO_LIBRARY is found
6#   PULSEAUDIO_INCLUDE_DIRS - Set when PULSEAUDIO_INCLUDE_DIR is found
7#
8#   PULSEAUDIO_INCLUDE_DIR - where to find pulse/pulseaudio.h, etc.
9#   PULSEAUDIO_LIBRARY     - the pulse library
10#   PULSEAUDIO_VERSION_STRING - the version of PulseAudio found
11#
12
13find_path(PULSEAUDIO_INCLUDE_DIR
14          NAMES pulse/pulseaudio.h
15          DOC "The PulseAudio include directory"
16)
17
18find_library(PULSEAUDIO_LIBRARY
19             NAMES pulse
20             DOC "The PulseAudio library"
21)
22
23if(PULSEAUDIO_INCLUDE_DIR AND EXISTS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h")
24    file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulse_version_str
25         REGEX "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\)")
26
27    string(REGEX REPLACE "^.*pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]*)\"\\).*$" "\\1"
28           PULSEAUDIO_VERSION_STRING "${pulse_version_str}")
29    unset(pulse_version_str)
30endif()
31
32include(FindPackageHandleStandardArgs)
33find_package_handle_standard_args(PulseAudio
34    REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR
35    VERSION_VAR PULSEAUDIO_VERSION_STRING
36)
37
38if(PULSEAUDIO_FOUND)
39    set(PULSEAUDIO_LIBRARIES ${PULSEAUDIO_LIBRARY})
40    set(PULSEAUDIO_INCLUDE_DIRS ${PULSEAUDIO_INCLUDE_DIR})
41endif()
42
43mark_as_advanced(PULSEAUDIO_INCLUDE_DIR PULSEAUDIO_LIBRARY)
44