FindALSA: support version selection

This commit is contained in:
Rolf Eike Beer 2012-01-25 17:50:37 +01:00
parent 731f996ce0
commit 1de14ec56e
1 changed files with 11 additions and 1 deletions

View File

@ -8,6 +8,7 @@
# #
# ALSA_INCLUDE_DIR - where to find asoundlib.h, etc. # ALSA_INCLUDE_DIR - where to find asoundlib.h, etc.
# ALSA_LIBRARY - the asound library # ALSA_LIBRARY - the asound library
# ALSA_VERSION_STRING - the version of alsa found (since CMake 2.8.8)
# #
#============================================================================= #=============================================================================
@ -33,10 +34,19 @@ find_library(ALSA_LIBRARY NAMES asound
DOC "The ALSA (asound) library" DOC "The ALSA (asound) library"
) )
if(ALSA_INCLUDE_DIR AND EXISTS "${ALSA_INCLUDE_DIR}/version.h")
file(STRINGS "${ALSA_INCLUDE_DIR}/version.h" alsa_version_str REGEX "^#define[\t ]+SND_LIB_VERSION_STR[\t ]+\".*\"")
string(REGEX REPLACE "^.*SND_LIB_VERSION_STR[\t ]+\"([^\"]*)\".*$" "\\1" ALSA_VERSION_STRING "${alsa_version_str}")
unset(alsa_version_str)
endif()
# handle the QUIETLY and REQUIRED arguments and set ALSA_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set ALSA_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA DEFAULT_MSG ALSA_LIBRARY ALSA_INCLUDE_DIR) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA
REQUIRED_VARS ALSA_LIBRARY ALSA_INCLUDE_DIR
VERSION_VAR ALSA_VERSION_STRING)
if(ALSA_FOUND) if(ALSA_FOUND)
set( ALSA_LIBRARIES ${ALSA_LIBRARY} ) set( ALSA_LIBRARIES ${ALSA_LIBRARY} )