FindALSA.cmake 2.2 KB

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