FindAlsa.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Alsa check, based on libkmid/configure.in.in.
  2. # Only the support for Alsa >= 0.9.x was included; 0.5.x was dropped (but feel free to re-add it if you need it)
  3. # It defines ...
  4. # It offers the following macros:
  5. # ALSA_CONFIGURE_FILE(config_header) - generate a config.h, typical usage:
  6. # ALSA_CONFIGURE_FILE(${CMAKE_BINARY_DIR}/config-alsa.h)
  7. # ALSA_VERSION_STRING(version_string) looks for alsa/version.h and reads the version string into
  8. # the first argument passed to the macro
  9. # Copyright (c) 2006, David Faure, <faure@kde.org>
  10. # Copyright (c) 2007, Matthias Kretz <kretz@kde.org>
  11. #
  12. # Redistribution and use is allowed according to the terms of the BSD license.
  13. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  14. include(CheckIncludeFiles)
  15. include(CheckIncludeFileCXX)
  16. include(CheckLibraryExists)
  17. # Already done by toplevel
  18. find_library(ASOUND_LIBRARY asound)
  19. set(ASOUND_LIBRARY_DIR "")
  20. if(ASOUND_LIBRARY)
  21. get_filename_component(ASOUND_LIBRARY_DIR ${ASOUND_LIBRARY} PATH)
  22. endif(ASOUND_LIBRARY)
  23. check_library_exists(asound snd_seq_create_simple_port "${ASOUND_LIBRARY_DIR}" HAVE_LIBASOUND2)
  24. if(HAVE_LIBASOUND2)
  25. message(STATUS "Found ALSA: ${ASOUND_LIBRARY}")
  26. else(HAVE_LIBASOUND2)
  27. message(STATUS "ALSA not found")
  28. endif(HAVE_LIBASOUND2)
  29. set(ALSA_FOUND ${HAVE_LIBASOUND2})
  30. find_path(ALSA_INCLUDES alsa/version.h)
  31. macro(ALSA_VERSION_STRING _result)
  32. # check for version in alsa/version.h
  33. if(ALSA_INCLUDES)
  34. file(READ "${ALSA_INCLUDES}/alsa/version.h" _ALSA_VERSION_CONTENT)
  35. string(REGEX REPLACE ".*SND_LIB_VERSION_STR.*\"(.*)\".*" "\\1" ${_result} ${_ALSA_VERSION_CONTENT})
  36. else(ALSA_INCLUDES)
  37. message(STATUS "ALSA version not known. ALSA output will probably not work correctly.")
  38. endif(ALSA_INCLUDES)
  39. endmacro(ALSA_VERSION_STRING _result)
  40. check_include_files(sys/soundcard.h LMMS_HAVE_SYS_SOUNDCARD_H)
  41. check_include_files(machine/soundcard.h LMMS_HAVE_MACHINE_SOUNDCARD_H)
  42. check_include_files(linux/awe_voice.h LMMS_HAVE_LINUX_AWE_VOICE_H)
  43. check_include_files(awe_voice.h LMMS_HAVE_AWE_VOICE_H)
  44. check_include_files(/usr/src/sys/i386/isa/sound/awe_voice.h LMMS_HAVE__USR_SRC_SYS_I386_ISA_SOUND_AWE_VOICE_H)
  45. check_include_files(/usr/src/sys/gnu/i386/isa/sound/awe_voice.h LMMS_HAVE__USR_SRC_SYS_GNU_I386_ISA_SOUND_AWE_VOICE_H)
  46. check_include_file_cxx(sys/asoundlib.h LMMS_HAVE_SYS_ASOUNDLIB_H)
  47. check_include_file_cxx(alsa/asoundlib.h LMMS_HAVE_ALSA_ASOUNDLIB_H)
  48. check_library_exists(asound snd_pcm_resume "${ASOUND_LIBRARY_DIR}" ASOUND_HAS_SND_PCM_RESUME)
  49. if(ASOUND_HAS_SND_PCM_RESUME)
  50. set(HAVE_SND_PCM_RESUME 1)
  51. endif(ASOUND_HAS_SND_PCM_RESUME)
  52. mark_as_advanced(ALSA_INCLUDES ASOUND_LIBRARY)