cmake: fix PulseAudio.cmake version detection

This commit is contained in:
Marc-André Moreau 2014-12-04 14:06:25 -05:00
parent d5414c33a5
commit ae4a8bdc70

View File

@ -11,14 +11,14 @@ find_library(PULSE_LIBRARY pulse PATHS ${PULSE_LIBRARY_DIRS})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pulse DEFAULT_MSG PULSE_INCLUDE_DIR PULSE_LIBRARY) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pulse DEFAULT_MSG PULSE_INCLUDE_DIR PULSE_LIBRARY)
if(PULSE_LIBRARY) if(PULSE_LIBRARY)
execute_process(COMMAND "pactl" "--version" OUTPUT_VARIABLE PULSE_VERSION_OUTPUT) file(STRINGS "${PULSE_INCLUDE_DIR}/pulse/version.h" STR1 REGEX "PA_MAJOR")
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" PULSE_VERSION "${PULSE_VERSION_OUTPUT}") file(STRINGS "${PULSE_INCLUDE_DIR}/pulse/version.h" STR2 REGEX "PA_MINOR")
if(NOT PULSE_VERSION) file(STRINGS "${PULSE_INCLUDE_DIR}/pulse/version.h" STR3 REGEX "PA_MICRO")
message(FATAL_ERROR "PulseAudio is not installed")
endif() string(REGEX MATCHALL "[0-9]+" PULSE_VERSION_MAJOR ${STR1})
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" PULSE_VERSION_MAJOR "${PULSE_VERSION}") string(REGEX MATCHALL "[0-9]+" PULSE_VERSION_MINOR ${STR2})
STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" PULSE_VERSION_MINOR "${PULSE_VERSION}") string(REGEX MATCHALL "[0-9]+" PULSE_VERSION_PATCH ${STR3})
STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" PULSE_VERSION_PATCH "${PULSE_VERSION}")
if(PULSE_VERSION_PATCH EQUAL 0) if(PULSE_VERSION_PATCH EQUAL 0)
set(PULSE_VERSION "${PULSE_VERSION_MAJOR}.${PULSE_VERSION_MINOR}") set(PULSE_VERSION "${PULSE_VERSION_MAJOR}.${PULSE_VERSION_MINOR}")
else() else()