FindALSA.cmake 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # - Find alsa
  2. # Find the alsa libraries (asound)
  3. #
  4. # This module defines the following variables:
  5. # ALSA_FOUND - True if ALSA_INCLUDE_DIR & ALSA_LIBRARY are found
  6. # ALSA_LIBRARIES - Set when ALSA_LIBRARY is found
  7. # ALSA_INCLUDE_DIRS - Set when ALSA_INCLUDE_DIR is found
  8. #
  9. # ALSA_INCLUDE_DIR - where to find asoundlib.h, etc.
  10. # ALSA_LIBRARY - the asound library
  11. # ALSA_VERSION_STRING - the version of alsa found (since CMake 2.8.8)
  12. #
  13. #=============================================================================
  14. # Copyright 2009-2011 Kitware, Inc.
  15. # Copyright 2009-2011 Philip Lowman <[email protected]>
  16. #
  17. # Distributed under the OSI-approved BSD License (the "License");
  18. # see accompanying file Copyright.txt for details.
  19. #
  20. # This software is distributed WITHOUT ANY WARRANTY; without even the
  21. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  22. # See the License for more information.
  23. #=============================================================================
  24. # (To distribute this file outside of CMake, substitute the full
  25. # License text for the above reference.)
  26. find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h
  27. DOC "The ALSA (asound) include directory"
  28. )
  29. find_library(ALSA_LIBRARY NAMES asound
  30. DOC "The ALSA (asound) library"
  31. )
  32. if(ALSA_INCLUDE_DIR AND EXISTS "${ALSA_INCLUDE_DIR}/alsa/version.h")
  33. file(STRINGS "${ALSA_INCLUDE_DIR}/alsa/version.h" alsa_version_str REGEX "^#define[\t ]+SND_LIB_VERSION_STR[\t ]+\".*\"")
  34. string(REGEX REPLACE "^.*SND_LIB_VERSION_STR[\t ]+\"([^\"]*)\".*$" "\\1" ALSA_VERSION_STRING "${alsa_version_str}")
  35. unset(alsa_version_str)
  36. endif()
  37. # handle the QUIETLY and REQUIRED arguments and set ALSA_FOUND to TRUE if
  38. # all listed variables are TRUE
  39. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  40. FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA
  41. REQUIRED_VARS ALSA_LIBRARY ALSA_INCLUDE_DIR
  42. VERSION_VAR ALSA_VERSION_STRING)
  43. if(ALSA_FOUND)
  44. set( ALSA_LIBRARIES ${ALSA_LIBRARY} )
  45. set( ALSA_INCLUDE_DIRS ${ALSA_INCLUDE_DIR} )
  46. endif()
  47. mark_as_advanced(ALSA_INCLUDE_DIR ALSA_LIBRARY)