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)
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
10 # Copyright (c) 2006, David Faure, <faure@kde.org>
11 # Copyright (c) 2007, Matthias Kretz <kretz@kde.org>
13 # Redistribution and use is allowed according to the terms of the BSD license.
14 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
16 include(CheckIncludeFiles)
17 include(CheckIncludeFileCXX)
18 include(CheckLibraryExists)
20 # Already done by toplevel
21 find_library(ASOUND_LIBRARY asound)
22 set(ASOUND_LIBRARY_DIR "")
24 get_filename_component(ASOUND_LIBRARY_DIR ${ASOUND_LIBRARY} PATH)
27 check_library_exists(asound snd_seq_create_simple_port "${ASOUND_LIBRARY_DIR}" HAVE_LIBASOUND2)
29 message(STATUS "Found ALSA: ${ASOUND_LIBRARY}")
31 message(STATUS "ALSA not found")
32 endif(HAVE_LIBASOUND2)
33 set(ALSA_FOUND ${HAVE_LIBASOUND2})
35 find_path(ALSA_INCLUDES alsa/version.h)
37 macro(ALSA_VERSION_STRING _result)
38 # check for version in alsa/version.h
40 file(READ "${ALSA_INCLUDES}/alsa/version.h" _ALSA_VERSION_CONTENT)
41 string(REGEX REPLACE ".*SND_LIB_VERSION_STR.*\"(.*)\".*" "\\1" ${_result} ${_ALSA_VERSION_CONTENT})
43 message(STATUS "ALSA version not known. ALSA output will probably not work correctly.")
45 endmacro(ALSA_VERSION_STRING _result)
48 get_filename_component(_FIND_ALSA_MODULE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
49 macro(ALSA_CONFIGURE_FILE _destFile)
50 check_include_files(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
51 check_include_files(machine/soundcard.h HAVE_MACHINE_SOUNDCARD_H)
53 check_include_files(linux/awe_voice.h HAVE_LINUX_AWE_VOICE_H)
54 check_include_files(awe_voice.h HAVE_AWE_VOICE_H)
55 check_include_files(/usr/src/sys/i386/isa/sound/awe_voice.h HAVE__USR_SRC_SYS_I386_ISA_SOUND_AWE_VOICE_H)
56 check_include_files(/usr/src/sys/gnu/i386/isa/sound/awe_voice.h HAVE__USR_SRC_SYS_GNU_I386_ISA_SOUND_AWE_VOICE_H)
58 check_include_file_cxx(sys/asoundlib.h HAVE_SYS_ASOUNDLIB_H)
59 check_include_file_cxx(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
61 check_library_exists(asound snd_pcm_resume "${ASOUND_LIBRARY_DIR}" ASOUND_HAS_SND_PCM_RESUME)
62 if(ASOUND_HAS_SND_PCM_RESUME)
63 set(HAVE_SND_PCM_RESUME 1)
64 endif(ASOUND_HAS_SND_PCM_RESUME)
66 configure_file(${_FIND_ALSA_MODULE_DIR}/config-alsa.h.cmake ${_destFile})
67 endmacro(ALSA_CONFIGURE_FILE _destFile)
69 mark_as_advanced(ALSA_INCLUDES ASOUND_LIBRARY)