1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
7 IF(COMMAND CMAKE_POLICY)
8 CMAKE_POLICY(SET CMP0003 NEW)
9 CMAKE_POLICY(SET CMP0005 NEW)
10 ENDIF(COMMAND CMAKE_POLICY)
12 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
14 INCLUDE(CheckFunctionExists)
15 INCLUDE(CheckLibraryExists)
16 INCLUDE(CheckSharedFunctionExists)
17 INCLUDE(CheckIncludeFile)
18 INCLUDE(CheckIncludeFiles)
19 INCLUDE(CheckSymbolExists)
20 INCLUDE(CheckCCompilerFlag)
21 INCLUDE(CheckCSourceCompiles)
22 INCLUDE(CheckTypeSize)
25 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
28 OPTION(ALSOFT_CPUEXT_SSE "Check for SSE/SSE2 support" ON)
29 OPTION(ALSOFT_CPUEXT_NEON "Check for ARM Neon support" ON)
31 OPTION(ALSOFT_REQUIRE_SSE "Require SSE/SSE2 support" OFF)
32 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
35 # This option is mainly for static linking OpenAL Soft into another project
36 # that already defines the IDs. It is up to that project to ensure all
37 # required IDs are defined.
38 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
42 OPTION(ALSOFT_BACKEND_ALSA "Check for ALSA backend" ON)
43 OPTION(ALSOFT_BACKEND_OSS "Check for OSS backend" ON)
44 OPTION(ALSOFT_BACKEND_SOLARIS "Check for Solaris backend" ON)
45 OPTION(ALSOFT_BACKEND_SNDIO "Check for SndIO backend" ON)
46 OPTION(ALSOFT_BACKEND_QSA "Check for QSA backend" ON)
47 OPTION(ALSOFT_BACKEND_MMDEVAPI "Check for MMDevApi backend" ON)
48 OPTION(ALSOFT_BACKEND_DSOUND "Check for DirectSound backend" ON)
49 OPTION(ALSOFT_BACKEND_WINMM "Check for Windows Multimedia backend" ON)
50 OPTION(ALSOFT_BACKEND_PORTAUDIO "Check for PortAudio backend" ON)
51 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Check for PulseAudio backend" ON)
52 OPTION(ALSOFT_BACKEND_COREAUDIO "Check for CoreAudio backend" ON)
53 OPTION(ALSOFT_BACKEND_OPENSL "Check for OpenSL backend" ON)
54 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
56 OPTION(ALSOFT_MIDI_FLUIDSYNTH "Check for FluidSynth MIDI" ON)
58 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
59 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
60 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
61 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
62 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
63 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi" OFF)
64 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
65 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
66 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
67 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
68 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
69 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
71 OPTION(ALSOFT_REQUIRE_FLUIDSYNTH "Require FluidSynth MIDI" OFF)
73 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
75 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
77 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
78 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
80 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
82 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
83 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
88 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0501")
93 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
94 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
95 ADD_DEFINITIONS("-I/usr/include")
96 SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
103 SET(LIB_MAJOR_VERSION "1")
104 SET(LIB_MINOR_VERSION "15")
105 SET(LIB_REVISION "1")
106 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
112 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
113 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
116 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
118 SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
121 # MSVC may need workarounds for C99 restrict and inline
123 # TODO: Once we truly require C99, these restrict and inline checks should go
125 CHECK_C_SOURCE_COMPILES("int *restrict foo;
126 int main() {return 0;}" HAVE_RESTRICT)
127 IF(NOT HAVE_RESTRICT)
128 ADD_DEFINITIONS("-Drestrict=")
129 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
132 CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
133 int main() {return 0;}" HAVE_INLINE)
135 CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
136 int main() {return 0;}" HAVE___INLINE)
137 IF(NOT HAVE___INLINE)
138 MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
141 ADD_DEFINITIONS(-Dinline=__inline)
142 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
146 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
147 IF(CMAKE_COMPILER_IS_GNUCC)
148 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
149 # Force no inlining for the next test.
150 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
152 CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
153 int main() {return foo();}" INLINE_IS_C99)
154 IF(NOT INLINE_IS_C99)
155 MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
156 Please update your compiler for better C99 compliance.")
159 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
162 # Check if we have C99 variable length arrays
163 CHECK_C_SOURCE_COMPILES(
164 "int main(int argc, char *argv[])
166 volatile int tmp[argc];
173 # Add definitions, compiler switches, etc.
174 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
175 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
176 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
177 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
178 ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
182 IF(NOT CMAKE_BUILD_TYPE)
183 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
184 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
187 IF(NOT CMAKE_DEBUG_POSTFIX)
188 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
189 "Library postfix for debug builds. Normally left blank."
195 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
196 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
197 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
198 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
199 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
200 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
201 ADD_DEFINITIONS("/wd4098")
204 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
206 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
209 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
210 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
211 INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
212 LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
215 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
216 IF(FORCE_STATIC_VCRT)
218 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
219 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
220 IF(${flag_var} MATCHES "/MD")
221 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
226 ADD_DEFINITIONS(-Winline -Wall)
227 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
229 ADD_DEFINITIONS(-Wextra)
233 ADD_DEFINITIONS(-Werror)
236 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
237 "Flags used by the compiler during Release with Debug Info builds."
239 SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
240 "Flags used by the compiler during release minsize builds."
242 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
243 "Flags used by the compiler during release builds"
245 SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
246 "Flags used by the compiler during debug builds."
249 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
250 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
253 # Set visibility/export options if available
255 SET(EXPORT_DECL "__declspec(dllexport)")
257 SET(ALIGN_DECL "__declspec(align(x))")
259 SET(ALIGN_DECL "__declspec(aligned(x))")
262 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
263 # Yes GCC, really don't accept visibility modes you don't support
264 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
266 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
267 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
268 IF(HAVE_GCC_PROTECTED_VISIBILITY)
269 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
271 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
272 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
273 IF(HAVE_GCC_DEFAULT_VISIBILITY)
274 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
278 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
279 CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
280 IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
281 ADD_DEFINITIONS(-fvisibility=internal)
283 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
284 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
285 ADD_DEFINITIONS(-fvisibility=hidden)
290 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
291 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
292 IF(HAVE_ATTRIBUTE_ALIGNED)
293 SET(ALIGN_DECL "__attribute__((aligned(x)))")
296 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
301 CHECK_C_COMPILER_FLAG(/arch:SSE HAVE_ARCHSSE_SWITCH)
302 IF(HAVE_ARCHSSE_SWITCH)
303 SET(SSE_SWITCH "/arch:SSE")
307 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
309 SET(SSE_SWITCH "-msse")
313 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
314 int main() {return 0;}" HAVE_GCC_FORMAT)
317 CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
319 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
320 CHECK_INCLUDE_FILE(ftw.h HAVE_FTW_H)
321 CHECK_INCLUDE_FILE(io.h HAVE_IO_H)
322 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
323 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
324 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
325 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
326 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
327 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
328 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
329 IF(NOT HAVE_GUIDDEF_H)
330 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
333 # Some systems need libm for some of the following math functions to work
334 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
336 SET(EXTRA_LIBS m ${EXTRA_LIBS})
337 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
341 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
342 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
343 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
344 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
347 CHECK_SYMBOL_EXISTS(alloca alloca.h HAVE_ALLOCA)
348 ELSEIF(HAVE_MALLOC_H)
349 CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
352 CHECK_SYMBOL_EXISTS(_alloca malloc.h HAVE__ALLOCA)
354 MESSAGE(FATAL_ERROR "No alloca function found, please report!")
357 ADD_DEFINITIONS(-Dalloca=_alloca)
362 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
363 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
366 CHECK_SYMBOL_EXISTS(ftw ftw.h HAVE_FTW)
369 CHECK_SYMBOL_EXISTS(_wfindfirst io.h HAVE__WFINDFIRST)
372 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
373 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
374 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
375 IF(NOT HAVE_STRCASECMP)
376 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
377 IF(NOT HAVE__STRICMP)
378 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
381 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
384 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
385 IF(NOT HAVE_STRNCASECMP)
386 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
387 IF(NOT HAVE__STRNICMP)
388 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
391 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
394 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
395 IF(NOT HAVE_SNPRINTF)
396 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
397 IF(NOT HAVE__SNPRINTF)
398 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
401 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
404 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
405 IF(NOT HAVE_ISFINITE)
406 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
408 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
410 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
412 ADD_DEFINITIONS(-Disfinite=_finite)
414 ADD_DEFINITIONS(-Disfinite=finite)
418 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
420 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
422 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
425 ADD_DEFINITIONS(-Disnan=_isnan)
429 # Check for the dlopen API (for dynamicly loading backend libs)
431 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
433 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
435 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
440 # Check if we have Windows headers
441 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501)
442 IF(NOT HAVE_WINDOWS_H)
443 # These are needed on some systems for extra features
444 ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700)
445 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700")
447 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
448 IF(NOT HAVE_GETTIMEOFDAY)
449 MESSAGE(FATAL_ERROR "No timing function found!")
452 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
453 IF(NOT HAVE_NANOSLEEP)
454 MESSAGE(FATAL_ERROR "No sleep function found!")
457 # We need pthreads outside of Windows
458 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
459 IF(NOT HAVE_PTHREAD_H)
460 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
462 # Some systems need pthread_np.h to get recursive mutexes
463 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
465 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
467 ADD_DEFINITIONS(-pthread)
468 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
469 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
472 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
474 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
477 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
479 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
480 IF(NOT HAVE_PTHREAD_SETNAME_NP)
481 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
484 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
486 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
490 # Check for a 64-bit type
491 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
492 IF(NOT HAVE_STDINT_H)
494 CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0501
497 int main() {return 0;}" HAVE___INT64)
500 IF(NOT SIZEOF_LONG MATCHES "8")
501 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
502 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
508 # Windows needs winmm for timeGetTime, even if the backend is disabled
509 CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
511 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
512 SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
516 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
520 OpenAL32/alExtension.c
522 OpenAL32/alFontsound.c
523 OpenAL32/alListener.c
526 OpenAL32/alSoundfont.c
530 OpenAL32/sample_cvt.c
532 SET(ALC_OBJS Alc/ALc.c
537 Alc/effects/autowah.c
539 Alc/effects/compressor.c
540 Alc/effects/dedicated.c
541 Alc/effects/distortion.c
543 Alc/effects/equalizer.c
544 Alc/effects/flanger.c
545 Alc/effects/modulator.c
557 SET(CPU_EXTS "Default")
561 # Check for SSE support
562 IF(ALSOFT_CPUEXT_SSE AND ALIGN_DECL)
563 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
566 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
568 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
569 COMPILE_FLAGS "${SSE_SWITCH}")
571 SET(CPU_EXTS "${CPU_EXTS}, SSE")
574 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
575 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
578 # Check for ARM Neon support
579 IF(ALSOFT_CPUEXT_NEON)
580 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
583 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
584 SET(CPU_EXTS "${CPU_EXTS}, Neon")
587 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
588 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
592 SET(ALC_OBJS ${ALC_OBJS}
596 Alc/midi/fluidsynth.c
600 SET(HAVE_FLUIDSYNTH 0)
602 # Check for FluidSynth support
603 IF(ALSOFT_MIDI_FLUIDSYNTH)
604 FIND_PACKAGE(FluidSynth)
606 SET(HAVE_FLUIDSYNTH 1)
607 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
608 INCLUDE_DIRECTORIES(${FLUIDSYNTH_INCLUDE_DIR})
610 SET(EXTRA_LIBS ${FLUIDSYNTH_LIBRARIES} ${EXTRA_LIBS})
613 IF(ALSOFT_REQUIRE_FLUIDSYNTH AND NOT HAVE_FLUIDSYNTH)
614 MESSAGE(FATAL_ERROR "Failed to enabled required FluidSynth support")
618 SET(ALC_OBJS ${ALC_OBJS}
620 # Default backends, always available
621 Alc/backends/loopback.c
634 SET(HAVE_PORTAUDIO 0)
635 SET(HAVE_PULSEAUDIO 0)
636 SET(HAVE_COREAUDIO 0)
641 IF(ALSOFT_BACKEND_ALSA)
642 CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
643 IF(HAVE_ALSA_ASOUNDLIB_H)
644 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
645 IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
647 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
648 IF(HAVE_DLFCN_H OR WIN32)
649 SET(BACKENDS "${BACKENDS} ALSA,")
651 SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
652 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
657 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
658 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
662 IF(ALSOFT_BACKEND_OSS)
663 CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
664 IF(HAVE_SYS_SOUNDCARD_H)
666 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
667 SET(BACKENDS "${BACKENDS} OSS,")
670 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
671 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
674 # Check Solaris backend
675 IF(ALSOFT_BACKEND_SOLARIS)
676 CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
677 IF(HAVE_SYS_AUDIOIO_H)
679 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
680 SET(BACKENDS "${BACKENDS} Solaris,")
683 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
684 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
687 # Check SndIO backend
688 IF(ALSOFT_BACKEND_SNDIO)
689 CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
691 CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
694 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
695 SET(BACKENDS "${BACKENDS} SndIO \(linked\),")
696 SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
700 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
701 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
705 IF (ALSOFT_BACKEND_QSA AND "${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
706 CHECK_INCLUDE_FILE(sys/asoundlib.h HAVE_SYS_ASOUNDLIB_H)
707 IF(HAVE_SYS_ASOUNDLIB_H)
708 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "sys/asoundlib.h" asound "" HAVE_LIBASOUND)
711 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
712 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
713 SET(BACKENDS "${BACKENDS} QSA \(linked\),")
717 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
718 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
721 # Check for MMDevApi backend
723 IF(ALSOFT_BACKEND_MMDEVAPI)
724 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
725 IF(HAVE_MMDEVICEAPI_H)
727 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
729 SET(BACKENDS "${BACKENDS} MMDevApi,")
733 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
734 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
737 # Check DSound/MMSystem backend
738 IF(ALSOFT_BACKEND_DSOUND)
739 CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
741 CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
742 IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
744 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
746 IF(HAVE_DLFCN_H OR WIN32)
747 SET(BACKENDS "${BACKENDS} DirectSound,")
749 SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
750 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
755 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
756 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
760 IF(ALSOFT_BACKEND_WINMM)
761 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0501)
762 IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
764 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
765 SET(BACKENDS "${BACKENDS} WinMM,")
769 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
770 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
773 # Check PortAudio backend
774 IF(ALSOFT_BACKEND_PORTAUDIO)
775 CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
777 CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
778 IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
779 SET(HAVE_PORTAUDIO 1)
780 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
781 IF(HAVE_DLFCN_H OR WIN32)
782 SET(BACKENDS "${BACKENDS} PortAudio,")
784 SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
785 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
790 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
791 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
794 # Check PulseAudio backend
795 IF(ALSOFT_BACKEND_PULSEAUDIO)
796 CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
797 IF(HAVE_PULSE_PULSEAUDIO_H)
798 CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
799 IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
800 SET(HAVE_PULSEAUDIO 1)
801 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
802 IF(HAVE_DLFCN_H OR WIN32)
803 SET(BACKENDS "${BACKENDS} PulseAudio,")
805 SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
806 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
811 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
812 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
815 # Check CoreAudio backend
816 IF(ALSOFT_BACKEND_COREAUDIO)
817 CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
818 IF(HAVE_COREAUDIO_FRAMEWORK)
819 SET(HAVE_COREAUDIO 1)
820 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
821 SET(BACKENDS "${BACKENDS} CoreAudio,")
822 SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
823 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
824 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
826 # Some versions of OSX may need the AudioToolbox framework. Add it if
828 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
830 PATHS ~/Library/Frameworks
832 /System/Library/Frameworks
834 IF(AUDIOTOOLBOX_LIBRARY)
835 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
839 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
840 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
843 # Check for OpenSL (Android) backend
844 IF(ALSOFT_BACKEND_OPENSL)
845 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
846 IF(HAVE_SLES_OPENSLES_ANDROID_H)
847 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
850 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
851 SET(BACKENDS "${BACKENDS} OpenSL,")
852 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
856 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
857 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
860 # Optionally enable the Wave Writer backend
861 IF(ALSOFT_BACKEND_WAVE)
863 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
864 SET(BACKENDS "${BACKENDS} WaveFile,")
867 # This is always available
868 SET(BACKENDS "${BACKENDS} Null")
870 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
871 add_subdirectory(utils/alsoft-config)
876 FIND_PACKAGE(SDL_sound)
877 IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
878 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
883 IF(LIBTYPE STREQUAL "STATIC")
884 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
885 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
888 # Needed for openal.pc.in
889 SET(prefix ${CMAKE_INSTALL_PREFIX})
890 SET(exec_prefix "\${prefix}")
891 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
892 SET(bindir "\${exec_prefix}/bin")
893 SET(includedir "\${prefix}/include")
894 SET(PACKAGE_VERSION "${LIB_VERSION}")
898 "${OpenAL_SOURCE_DIR}/config.h.in"
899 "${OpenAL_BINARY_DIR}/config.h")
901 "${OpenAL_SOURCE_DIR}/openal.pc.in"
902 "${OpenAL_BINARY_DIR}/openal.pc"
906 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
907 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
908 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
909 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
911 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
913 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${FLUIDSYNTH_INCLUDE_DIR})
915 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
916 SOVERSION ${LIB_MAJOR_VERSION})
917 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
918 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
921 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
923 # Add an install target here
924 INSTALL(TARGETS ${LIBNAME}
925 RUNTIME DESTINATION bin
926 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
927 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
929 INSTALL(FILES include/AL/al.h
933 include/AL/efx-creative.h
934 include/AL/efx-presets.h
935 DESTINATION include/AL
937 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
938 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
942 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
943 MESSAGE(STATUS " ${BACKENDS}")
945 MESSAGE(STATUS "Building with support for CPU extensions:")
946 MESSAGE(STATUS " ${CPU_EXTS}")
949 MESSAGE(STATUS "FluidSynth support for ALC_SOFT_midi_interface enabled")
955 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
956 MESSAGE(STATUS " This is probably NOT what you want!")
961 # Install alsoft.conf configuration file
963 INSTALL(FILES alsoftrc.sample
964 DESTINATION share/openal
966 MESSAGE(STATUS "Installing sample configuration")
970 # Install HRTF definitions
972 INSTALL(FILES hrtf/default-44100.mhr
973 DESTINATION share/openal/hrtf
975 MESSAGE(STATUS "Installing HRTF definitions")
980 ADD_EXECUTABLE(openal-info utils/openal-info.c)
981 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
983 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
985 TARGET_LINK_LIBRARIES(makehrtf m)
988 INSTALL(TARGETS openal-info makehrtf
989 RUNTIME DESTINATION bin
990 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
991 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
994 MESSAGE(STATUS "Building utility programs")
995 IF(TARGET alsoft-config)
996 MESSAGE(STATUS "Building configuration program")
1002 IF(SDL_FOUND AND SDL_SOUND_FOUND)
1003 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1004 examples/common/sdl_sound.c)
1005 SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1007 ADD_EXECUTABLE(alstream examples/alstream.c)
1008 TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1009 SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1011 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1012 TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1013 SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1015 ADD_EXECUTABLE(allatency examples/allatency.c)
1016 TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1017 SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1019 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1020 TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL_LIBRARY} ${LIBNAME})
1021 SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_INCLUDE_DIR}
1022 ${SDL_SOUND_INCLUDE_DIR})
1024 INSTALL(TARGETS alstream alreverb allatency alloopback
1025 RUNTIME DESTINATION bin
1026 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1027 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1030 MESSAGE(STATUS "Building example programs")