| 1 |
option(WANT_ALSA "Enable ALSA digital audio driver (Unix)" on) |
| 2 |
option(WANT_OSS "Enable OSS digital audio driver (Unix)" on) |
| 3 |
option(WANT_PULSEAUDIO "Enable PulseAudio audio driver (Unix)" on) |
| 4 |
option(WANT_OPENAL "Enable OpenAL digital audio driver" on) |
| 5 |
option(WANT_OPENSL "Enable OpenSL digital audio driver (Android)" on) |
| 6 |
option(WANT_DSOUND "Enable DSound digital audio driver (Windows)" on) |
| 7 |
option(WANT_AQUEUE "Enable AudioQueue digital audio driver (Mac)" on) |
| 8 |
|
| 9 |
set(AUDIO_SOURCES |
| 10 |
audio.c |
| 11 |
audio_io.c |
| 12 |
kcm_dtor.c |
| 13 |
kcm_instance.c |
| 14 |
kcm_mixer.c |
| 15 |
kcm_sample.c |
| 16 |
kcm_stream.c |
| 17 |
kcm_voice.c |
| 18 |
recorder.c |
| 19 |
) |
| 20 |
|
| 21 |
set(AUDIO_INCLUDE_FILES allegro5/allegro_audio.h) |
| 22 |
|
| 23 |
set_our_header_properties(${AUDIO_INCLUDE_FILES}) |
| 24 |
|
| 25 |
set(AUDIO_CONFIGURATION_SUMMARY "") |
| 26 |
|
| 27 |
function(audio_summary msg yesno) |
| 28 |
if(${yesno}) |
| 29 |
set(yesno "yes") |
| 30 |
else() |
| 31 |
# No's are more important, so shout them. |
| 32 |
set(yesno "NO") |
| 33 |
endif() |
| 34 |
set(AUDIO_CONFIGURATION_SUMMARY "${AUDIO_CONFIGURATION_SUMMARY}${msg}: ${yesno}\n" PARENT_SCOPE) |
| 35 |
endfunction() |
| 36 |
|
| 37 |
# The platform conditions are not really necessary but prevent confusing the |
| 38 |
# user, e.g. it's pretty weird to get a warning about missing DSound on Unix. |
| 39 |
|
| 40 |
if(WANT_OSS AND ALLEGRO_UNIX) |
| 41 |
include(AllegroFindOSS) |
| 42 |
if(OSS_FOUND) |
| 43 |
set(SUPPORT_OSS 1) |
| 44 |
endif(OSS_FOUND) |
| 45 |
endif(WANT_OSS AND ALLEGRO_UNIX) |
| 46 |
|
| 47 |
if(SUPPORT_OSS) |
| 48 |
set(ALLEGRO_CFG_KCM_OSS 1) |
| 49 |
list(APPEND AUDIO_SOURCES oss.c) |
| 50 |
set(SUPPORT_AUDIO 1) |
| 51 |
endif(SUPPORT_OSS) |
| 52 |
|
| 53 |
if(ALLEGRO_UNIX) |
| 54 |
audio_summary(" - OSS" SUPPORT_OSS) |
| 55 |
endif() |
| 56 |
|
| 57 |
if(WANT_PULSEAUDIO AND ALLEGRO_UNIX) |
| 58 |
pkg_check_modules(PULSEAUDIO libpulse-simple) |
| 59 |
if(PULSEAUDIO_FOUND) |
| 60 |
set(CMAKE_REQUIRED_INCLUDES ${PULSEAUDIO_INCLUDE_DIRS}) |
| 61 |
run_c_compile_test(" |
| 62 |
#include <pulse/simple.h> |
| 63 |
#include <pulse/error.h> |
| 64 |
#include <pulse/introspect.h> |
| 65 |
#include <pulse/mainloop.h> |
| 66 |
int main(void) |
| 67 |
{ |
| 68 |
/* Require pulseaudio 0.9.15 */ |
| 69 |
pa_context *c; |
| 70 |
pa_sink_info *si; |
| 71 |
pa_sink_state_t *ss; |
| 72 |
return 0; |
| 73 |
}" |
| 74 |
PULSEAUDIO_COMPILES) |
| 75 |
set(CMAKE_REQUIRED_INCLUDES) |
| 76 |
set(SUPPORT_PULSEAUDIO ${PULSEAUDIO_COMPILES}) |
| 77 |
if(NOT SUPPORT_PULSEAUDIO) |
| 78 |
message("WARNING: PulseAudio compile test failed, disabling support") |
| 79 |
endif() |
| 80 |
endif(PULSEAUDIO_FOUND) |
| 81 |
endif(WANT_PULSEAUDIO AND ALLEGRO_UNIX) |
| 82 |
|
| 83 |
if(SUPPORT_PULSEAUDIO) |
| 84 |
set(ALLEGRO_CFG_KCM_PULSEAUDIO 1) |
| 85 |
list(APPEND AUDIO_SOURCES pulseaudio.c) |
| 86 |
list(APPEND AUDIO_LIBRARIES ${PULSEAUDIO_LIBRARIES}) |
| 87 |
list(APPEND AUDIO_INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS}) |
| 88 |
list(APPEND AUDIO_LINK_DIRECTORIES ${PULSEAUDIO_LIBRARY_DIRS}) |
| 89 |
set(SUPPORT_AUDIO 1) |
| 90 |
endif(SUPPORT_PULSEAUDIO) |
| 91 |
|
| 92 |
if(ALLEGRO_UNIX) |
| 93 |
audio_summary(" - PulseAudio" SUPPORT_PULSEAUDIO) |
| 94 |
endif() |
| 95 |
|
| 96 |
if(WANT_ALSA AND ALLEGRO_UNIX) |
| 97 |
pkg_check_modules(ALSA alsa) |
| 98 |
if(ALSA_FOUND) |
| 99 |
set(SUPPORT_ALSA 1) |
| 100 |
endif(ALSA_FOUND) |
| 101 |
endif(WANT_ALSA AND ALLEGRO_UNIX) |
| 102 |
|
| 103 |
if(SUPPORT_ALSA) |
| 104 |
set(ALLEGRO_CFG_KCM_ALSA 1) |
| 105 |
list(APPEND AUDIO_SOURCES alsa.c) |
| 106 |
list(APPEND AUDIO_LIBRARIES ${ALSA_LIBRARIES}) |
| 107 |
list(APPEND AUDIO_INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS}) |
| 108 |
set(SUPPORT_AUDIO 1) |
| 109 |
endif(SUPPORT_ALSA) |
| 110 |
|
| 111 |
if(ALLEGRO_UNIX) |
| 112 |
audio_summary(" - ALSA" SUPPORT_ALSA) |
| 113 |
endif() |
| 114 |
|
| 115 |
if(WANT_DSOUND AND WIN32) |
| 116 |
find_package(DirectX) |
| 117 |
if(DSOUND_FOUND) |
| 118 |
set(SUPPORT_DSOUND 1) |
| 119 |
endif(DSOUND_FOUND) |
| 120 |
endif(WANT_DSOUND AND WIN32) |
| 121 |
|
| 122 |
if(SUPPORT_DSOUND) |
| 123 |
set(ALLEGRO_CFG_KCM_DSOUND 1) |
| 124 |
list(APPEND AUDIO_SOURCES dsound.cpp) |
| 125 |
list(APPEND AUDIO_LIBRARIES ${DSOUND_LIBRARIES}) |
| 126 |
list(APPEND AUDIO_INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIR}) |
| 127 |
set(SUPPORT_AUDIO 1) |
| 128 |
endif(SUPPORT_DSOUND) |
| 129 |
|
| 130 |
if(WIN32) |
| 131 |
audio_summary(" - DirectSound" SUPPORT_DSOUND) |
| 132 |
endif() |
| 133 |
|
| 134 |
if(WANT_AQUEUE AND MACOSX) |
| 135 |
# Should check the presence just to be sure. |
| 136 |
find_library(AUDIO_TOOLBOX_LIB NAMES AudioToolbox) |
| 137 |
if(AUDIO_TOOLBOX_LIB) |
| 138 |
find_path(AQUEUE_INCLUDE_DIR AudioToolbox/AudioQueue.h) |
| 139 |
if(AQUEUE_INCLUDE_DIR) |
| 140 |
set(SUPPORT_AQUEUE 1) |
| 141 |
endif(AQUEUE_INCLUDE_DIR) |
| 142 |
endif(AUDIO_TOOLBOX_LIB) |
| 143 |
|
| 144 |
if(NOT SUPPORT_AQUEUE) |
| 145 |
message("WARNING: could not find AudioQueue. (This is normal on OS X 10.4)") |
| 146 |
endif(NOT SUPPORT_AQUEUE) |
| 147 |
endif(WANT_AQUEUE AND MACOSX) |
| 148 |
|
| 149 |
if(SUPPORT_AQUEUE) |
| 150 |
set(ALLEGRO_CFG_KCM_AQUEUE 1) |
| 151 |
list(APPEND AUDIO_SOURCES aqueue.m) |
| 152 |
list(APPEND AUDIO_LIBRARIES ${AUDIO_TOOLBOX_LIB}) |
| 153 |
set(SUPPORT_AUDIO 1) |
| 154 |
endif(SUPPORT_AQUEUE) |
| 155 |
|
| 156 |
if(MACOSX) |
| 157 |
audio_summary(" - AudioQueue" SUPPORT_AQUEUE) |
| 158 |
endif() |
| 159 |
|
| 160 |
if(WANT_OPENAL) |
| 161 |
find_package(OpenAL) |
| 162 |
mark_as_advanced(OPENAL_INCLUDE_DIR OPENAL_LIBRARY) |
| 163 |
if(OPENAL_FOUND) |
| 164 |
set(SUPPORT_OPENAL 1) |
| 165 |
endif(OPENAL_FOUND) |
| 166 |
endif(WANT_OPENAL) |
| 167 |
|
| 168 |
if(SUPPORT_OPENAL) |
| 169 |
set(ALLEGRO_CFG_KCM_OPENAL 1) |
| 170 |
list(APPEND AUDIO_SOURCES openal.c) |
| 171 |
list(APPEND AUDIO_LIBRARIES ${OPENAL_LIBRARY}) |
| 172 |
list(APPEND AUDIO_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR}) |
| 173 |
set(SUPPORT_AUDIO 1) |
| 174 |
endif(SUPPORT_OPENAL) |
| 175 |
|
| 176 |
audio_summary(" - OpenAL" SUPPORT_OPENAL) |
| 177 |
|
| 178 |
if(WANT_OPENSL) |
| 179 |
find_package(OpenSL) |
| 180 |
if(OPENSL_FOUND) |
| 181 |
set(SUPPORT_OPENSL 1) |
| 182 |
endif(OPENSL_FOUND) |
| 183 |
endif(WANT_OPENSL) |
| 184 |
|
| 185 |
if(SUPPORT_OPENSL) |
| 186 |
set(ALLEGRO_CFG_KCM_OPENSL 1) |
| 187 |
list(APPEND AUDIO_SOURCES opensl.c) |
| 188 |
list(APPEND AUDIO_LIBRARIES ${OPENSL_LIBRARY}) |
| 189 |
list(APPEND AUDIO_INCLUDE_DIRECTORIES ${OPENSL_INCLUDE_DIR}) |
| 190 |
set(SUPPORT_AUDIO 1) |
| 191 |
endif(SUPPORT_OPENSL) |
| 192 |
|
| 193 |
audio_summary(" - OpenSL" SUPPORT_OPENSL) |
| 194 |
|
| 195 |
if(ALLEGRO_SDL) |
| 196 |
set(ALLEGRO_CFG_KCM_SDL 1) |
| 197 |
list(APPEND AUDIO_SOURCES sdl_audio.c) |
| 198 |
list(APPEND AUDIO_LIBRARIES ${SDL2_LIBRARIES} ) |
| 199 |
list(APPEND AUDIO_INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}) |
| 200 |
set(SUPPORT_AUDIO 1) |
| 201 |
endif(ALLEGRO_SDL) |
| 202 |
|
| 203 |
configure_file( |
| 204 |
allegro5/internal/aintern_audio_cfg.h.cmake |
| 205 |
${PROJECT_BINARY_DIR}/include/allegro5/internal/aintern_audio_cfg.h |
| 206 |
) |
| 207 |
|
| 208 |
if(NOT SUPPORT_AUDIO) |
| 209 |
message("WARNING: allegro_audio wanted but no supported backend found") |
| 210 |
return() |
| 211 |
endif(NOT SUPPORT_AUDIO) |
| 212 |
|
| 213 |
include_directories(SYSTEM ${AUDIO_INCLUDE_DIRECTORIES}) |
| 214 |
link_directories(${AUDIO_LINK_DIRECTORIES}) |
| 215 |
add_our_addon_library(allegro_audio |
| 216 |
AllegroAudio-${ALLEGRO_SOVERSION} |
| 217 |
"${AUDIO_SOURCES};${AUDIO_INCLUDE_FILES}" |
| 218 |
"-DALLEGRO_KCM_AUDIO_SRC" |
| 219 |
"${ALLEGRO_LINK_WITH};${AUDIO_LIBRARIES}" |
| 220 |
) |
| 221 |
|
| 222 |
install_our_headers(${AUDIO_INCLUDE_FILES}) |
| 223 |
|
| 224 |
add_addon(audio) |
| 225 |
|
| 226 |
set(AUDIO_CONFIGURATION_SUMMARY "${AUDIO_CONFIGURATION_SUMMARY}" PARENT_SCOPE) |
| 227 |
|
| 228 |
#-----------------------------------------------------------------------------# |
| 229 |
# vi: set ts=8 sts=4 sw=4 et: |