1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
5 IF(COMMAND CMAKE_POLICY)
6 CMAKE_POLICY(SET CMP0003 NEW)
7 ENDIF(COMMAND CMAKE_POLICY)
9 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
11 INCLUDE(CheckFunctionExists)
12 INCLUDE(CheckLibraryExists)
13 INCLUDE(CheckSharedFunctionExists)
14 INCLUDE(CheckIncludeFile)
15 INCLUDE(CheckIncludeFiles)
16 INCLUDE(CheckSymbolExists)
17 INCLUDE(CheckCCompilerFlag)
18 INCLUDE(CheckCSourceCompiles)
19 INCLUDE(CheckTypeSize)
20 INCLUDE(FindPkgConfig)
26 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
29 OPTION(SSE "Check for SSE CPU extensions" ON)
30 OPTION(NEON "Check for ARM Neon CPU extensions" ON)
32 OPTION(REQUIRE_SSE "Require SSE CPU extensions" OFF)
33 OPTION(REQUIRE_NEON "Require ARM Neon CPU extensions" OFF)
36 OPTION(ALSA "Check for ALSA backend" ON)
37 OPTION(OSS "Check for OSS backend" ON)
38 OPTION(SOLARIS "Check for Solaris backend" ON)
39 OPTION(SNDIO "Check for SndIO backend" ON)
40 OPTION(MMDEVAPI "Check for MMDevApi" ON)
41 OPTION(DSOUND "Check for DirectSound backend" ON)
42 OPTION(WINMM "Check for Windows Multimedia backend" ON)
43 OPTION(PORTAUDIO "Check for PortAudio backend" ON)
44 OPTION(PULSEAUDIO "Check for PulseAudio backend" ON)
45 OPTION(COREAUDIO "Check for CoreAudio backend" ON)
46 OPTION(OPENSL "Check for OpenSL backend" ON)
47 OPTION(WAVE "Enable Wave Writer backend" ON)
49 OPTION(REQUIRE_ALSA "Require ALSA backend" OFF)
50 OPTION(REQUIRE_OSS "Require OSS backend" OFF)
51 OPTION(REQUIRE_SOLARIS "Require Solaris backend" OFF)
52 OPTION(REQUIRE_SNDIO "Require SndIO backend" OFF)
53 OPTION(REQUIRE_MMDEVAPI "Require MMDevApi" OFF)
54 OPTION(REQUIRE_DSOUND "Require DirectSound backend" OFF)
55 OPTION(REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
56 OPTION(REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
57 OPTION(REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
58 OPTION(REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
59 OPTION(REQUIRE_OPENSL "Require OpenSL backend" OFF)
61 OPTION(DLOPEN "Check for the dlopen API for loading optional libs" ON)
63 OPTION(WERROR "Treat compile warnings as errors" OFF)
65 OPTION(UTILS "Build and install utility programs" ON)
67 OPTION(EXAMPLES "Build and install example programs" ON)
69 OPTION(ALSOFT_CONFIG "Install alsoft.conf configuration file" OFF)
74 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0501")
83 SET(LIB_MAJOR_VERSION "1")
84 SET(LIB_MINOR_VERSION "14")
85 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}")
91 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
92 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
95 CHECK_C_SOURCE_COMPILES("int *restrict foo;
96 int main() {return 0;}" HAVE_RESTRICT)
97 CHECK_C_SOURCE_COMPILES("int *__restrict foo;
98 int main() {return 0;}" HAVE___RESTRICT)
101 # Add definitions, compiler switches, etc.
102 INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}")
104 IF(NOT CMAKE_BUILD_TYPE)
105 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
106 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
109 IF(NOT CMAKE_DEBUG_POSTFIX)
110 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
111 "Library postfix for debug builds. Normally left blank."
117 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
118 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
119 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
120 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
121 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
122 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
125 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
127 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
130 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
131 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
132 INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
133 LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
136 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
137 IF(FORCE_STATIC_VCRT)
139 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
140 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
141 IF(${flag_var} MATCHES "/MD")
142 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
147 ADD_DEFINITIONS(-Winline -Wall)
148 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
150 ADD_DEFINITIONS(-Wextra)
154 ADD_DEFINITIONS(-Werror)
157 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
158 "Flags used by the compiler during Release with Debug Info builds."
160 SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
161 "Flags used by the compiler during release minsize builds."
163 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
164 "Flags used by the compiler during release builds"
166 SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
167 "Flags used by the compiler during debug builds."
170 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
171 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
174 # Set visibility/export options if available
176 SET(EXPORT_DECL "__declspec(dllexport)")
177 SET(ALIGN_DECL "__declspec(align(x))")
179 OPTION(WINE "Enable use of Wine headers when compiling" OFF)
181 FIND_PATH(WINE_INCLUDE_DIR library.h
184 /usr/local/include/wine
185 CMAKE_FIND_ROOT_PATH_BOTH)
187 MESSAGE(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" )
188 INCLUDE_DIRECTORIES("${WINE_INCLUDE_DIR}/windows")
189 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${WINE_INCLUDE_DIR}/windows")
191 MESSAGE(STATUS "Could not find Wine header files" )
195 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
196 # Yes GCC, really don't accept visibility modes you don't support
197 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
199 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
200 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
201 IF(HAVE_GCC_PROTECTED_VISIBILITY)
202 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
204 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
205 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
206 IF(HAVE_GCC_DEFAULT_VISIBILITY)
207 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
211 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
212 CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
213 IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
214 ADD_DEFINITIONS(-fvisibility=internal)
216 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
217 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
218 ADD_DEFINITIONS(-fvisibility=hidden)
223 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
224 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
225 IF(HAVE_ATTRIBUTE_ALIGNED)
226 SET(ALIGN_DECL "__attribute__((aligned(x)))")
229 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
233 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
235 SET(SSE_SWITCH "-msse")
238 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
239 int main() {return 0;}" HAVE_GCC_FORMAT)
241 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
242 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
243 CHECK_INCLUDE_FILE(fpu_control.h HAVE_FPU_CONTROL_H)
244 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
245 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
246 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
247 IF(NOT HAVE_GUIDDEF_H)
248 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
251 # Some systems need libm for some of the following math functions to work
252 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
254 SET(EXTRA_LIBS m ${EXTRA_LIBS})
255 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
259 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
260 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
261 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
262 CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF)
263 CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF)
264 CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF)
265 CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF)
266 CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF)
267 CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF)
268 CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF)
269 CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF)
270 CHECK_SYMBOL_EXISTS(atan2f math.h HAVE_ATAN2F)
271 CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF)
272 CHECK_SYMBOL_EXISTS(log10f math.h HAVE_LOG10F)
273 CHECK_SYMBOL_EXISTS(floorf math.h HAVE_FLOORF)
276 CHECK_SYMBOL_EXISTS(fesetround fenv.h HAVE_FESETROUND)
279 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
280 CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP)
282 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
283 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
284 IF(NOT HAVE_STRCASECMP)
285 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
286 IF(NOT HAVE__STRICMP)
287 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
290 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
293 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
294 IF(NOT HAVE_STRNCASECMP)
295 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
296 IF(NOT HAVE__STRNICMP)
297 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
300 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
303 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
304 IF(NOT HAVE_SNPRINTF)
305 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
306 IF(NOT HAVE__SNPRINTF)
307 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
310 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
313 CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
314 IF(NOT HAVE_VSNPRINTF)
315 CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF)
316 IF(NOT HAVE__VSNPRINTF)
317 MESSAGE(FATAL_ERROR "No vsnprintf function found, please report!")
320 ADD_DEFINITIONS(-Dvsnprintf=_vsnprintf)
323 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
324 IF(NOT HAVE_ISFINITE)
325 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
327 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
329 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
331 ADD_DEFINITIONS(-Disfinite=_finite)
333 ADD_DEFINITIONS(-Disfinite=finite)
337 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
339 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
341 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
344 ADD_DEFINITIONS(-Disnan=_isnan)
348 # Check for the dlopen API (for dynamicly loading backend libs)
350 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
352 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
354 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
359 # Check if we have Windows headers
360 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501)
361 IF(NOT HAVE_WINDOWS_H)
362 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
363 IF(NOT HAVE_GETTIMEOFDAY)
364 MESSAGE(FATAL_ERROR "No timing function found!")
367 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
368 IF(NOT HAVE_NANOSLEEP)
369 MESSAGE(FATAL_ERROR "No sleep function found!")
372 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
374 ADD_DEFINITIONS(-pthread)
375 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
378 # We need pthreads outside of Windows
379 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
380 IF(NOT HAVE_PTHREAD_H)
381 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
383 # Some systems need pthread_np.h to get recursive mutexes
384 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
386 # _GNU_SOURCE is needed on some systems for extra attributes
387 ADD_DEFINITIONS(-D_GNU_SOURCE=1)
388 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
390 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
393 CHECK_LIBRARY_EXISTS(pthread pthread_setschedparam "" HAVE_PTHREAD_SETSCHEDPARAM)
395 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
397 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
401 # Check for a 64-bit type
402 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
403 IF(NOT HAVE_STDINT_H)
405 CHECK_C_SOURCE_COMPILES("\#define _WIN32_WINNT 0x0501
406 \#include <windows.h>
408 int main() {return 0;}" HAVE___INT64)
411 IF(NOT SIZEOF_LONG MATCHES "8")
412 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
413 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
419 # Windows needs winmm for timeGetTime, even if the backend is disabled
420 CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
422 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
423 SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
427 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
431 OpenAL32/alExtension.c
433 OpenAL32/alListener.c
438 SET(ALC_OBJS Alc/ALc.c
456 SET(CPU_EXTS "Default")
460 # Check for SSE support
462 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
465 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
467 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
468 COMPILE_FLAGS "${SSE_SWITCH}")
470 SET(CPU_EXTS "${CPU_EXTS}, SSE")
473 IF(REQUIRE_SSE AND NOT HAVE_SSE)
474 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
477 # Check for ARM Neon support
479 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
482 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
483 SET(CPU_EXTS "${CPU_EXTS}, Neon")
486 IF(REQUIRE_NEON AND NOT HAVE_NEON)
487 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
491 SET(ALC_OBJS ${ALC_OBJS}
492 # Default backends, always available
493 Alc/backends/loopback.c
505 SET(HAVE_PORTAUDIO 0)
506 SET(HAVE_PULSEAUDIO 0)
507 SET(HAVE_COREAUDIO 0)
513 CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
514 IF(HAVE_ALSA_ASOUNDLIB_H)
515 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
516 IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
518 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
519 IF(HAVE_DLFCN_H OR WIN32)
520 SET(BACKENDS "${BACKENDS} ALSA,")
522 SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
523 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
528 IF(REQUIRE_ALSA AND NOT HAVE_ALSA)
529 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
534 CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
535 IF(HAVE_SYS_SOUNDCARD_H)
537 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
538 SET(BACKENDS "${BACKENDS} OSS,")
541 IF(REQUIRE_OSS AND NOT HAVE_OSS)
542 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
545 # Check Solaris backend
547 CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
548 IF(HAVE_SYS_AUDIOIO_H)
550 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
551 SET(BACKENDS "${BACKENDS} Solaris,")
554 IF(REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
555 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
558 # Check SndIO backend
560 CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
562 CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
565 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
566 SET(BACKENDS "${BACKENDS} SndIO \(linked\),")
567 SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
571 IF(REQUIRE_SNDIO AND NOT HAVE_SNDIO)
572 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
575 # Check for MMDevApi backend
578 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
579 IF(HAVE_MMDEVICEAPI_H)
581 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
583 SET(BACKENDS "${BACKENDS} MMDevApi,")
587 IF(REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
588 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
591 # Check DSound/MMSystem backend
593 CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
595 CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
596 IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
598 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
600 IF(HAVE_DLFCN_H OR WIN32)
601 SET(BACKENDS "${BACKENDS} DirectSound,")
603 SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
604 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
609 IF(REQUIRE_DSOUND AND NOT HAVE_DSOUND)
610 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
615 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0501)
616 IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
618 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
619 SET(BACKENDS "${BACKENDS} WinMM,")
623 IF(REQUIRE_WINMM AND NOT HAVE_WINMM)
624 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
627 # Check PortAudio backend
629 CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
631 CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
632 IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
633 SET(HAVE_PORTAUDIO 1)
634 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
635 IF(HAVE_DLFCN_H OR WIN32)
636 SET(BACKENDS "${BACKENDS} PortAudio,")
638 SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
639 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
644 IF(REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
645 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
648 # Check PulseAudio backend
650 CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
651 IF(HAVE_PULSE_PULSEAUDIO_H)
652 CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
653 IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
654 SET(HAVE_PULSEAUDIO 1)
655 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
656 IF(HAVE_DLFCN_H OR WIN32)
657 SET(BACKENDS "${BACKENDS} PulseAudio,")
659 SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
660 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
665 IF(REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
666 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
669 # Check CoreAudio backend
671 CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
672 IF(HAVE_COREAUDIO_FRAMEWORK)
673 SET(HAVE_COREAUDIO 1)
674 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
675 SET(BACKENDS "${BACKENDS} CoreAudio,")
676 SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
677 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
678 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
680 # Some versions of OSX may need the AudioToolbox framework. Add it if
682 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
684 PATHS ~/Library/Frameworks
686 /System/Library/Frameworks
688 IF(AUDIOTOOLBOX_LIBRARY)
689 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
693 IF(REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
694 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
697 # Check for OpenSL (Android) backend
699 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
700 IF(HAVE_SLES_OPENSLES_ANDROID_H)
701 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
704 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
705 SET(BACKENDS "${BACKENDS} OpenSL,")
706 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
710 IF(REQUIRE_OPENSL AND NOT HAVE_OPENSL)
711 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
714 # Optionally enable the Wave Writer backend
717 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
718 SET(BACKENDS "${BACKENDS} WaveFile,")
721 # This is always available
722 SET(BACKENDS "${BACKENDS} Null")
725 # Might be able to use earlier versions, but these definitely work
726 PKG_CHECK_MODULES(FFMPEG libavcodec>=52.123.0 libavformat>=52.111.0 libavutil>=51.9.1)
729 IF(LIBTYPE STREQUAL "STATIC")
730 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
731 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
734 # Needed for openal.pc.in
735 SET(prefix ${CMAKE_INSTALL_PREFIX})
736 SET(exec_prefix "\${prefix}")
737 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
738 SET(bindir "\${exec_prefix}/bin")
739 SET(includedir "\${prefix}/include")
740 SET(PACKAGE_VERSION "${LIB_VERSION}")
744 "${OpenAL_SOURCE_DIR}/config.h.in"
745 "${OpenAL_BINARY_DIR}/config.h")
747 "${OpenAL_SOURCE_DIR}/openal.pc.in"
748 "${OpenAL_BINARY_DIR}/openal.pc"
752 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
753 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY
754 COMPILE_FLAGS -DAL_ALEXT_PROTOTYPES
755 VERSION ${LIB_VERSION}.0
756 SOVERSION ${LIB_MAJOR_VERSION})
757 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
758 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
761 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
763 # Add an install target here
764 INSTALL(TARGETS ${LIBNAME}
765 RUNTIME DESTINATION bin
766 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
767 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
769 INSTALL(FILES include/AL/al.h
773 include/AL/efx-creative.h
774 include/AL/efx-presets.h
775 DESTINATION include/AL
777 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
778 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
782 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
783 MESSAGE(STATUS " ${BACKENDS}")
785 MESSAGE(STATUS "Building with support for CPU extensions:")
786 MESSAGE(STATUS " ${CPU_EXTS}")
791 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
792 MESSAGE(STATUS " This is probably NOT what you want!")
797 # Install alsoft.conf configuration file
799 INSTALL(FILES alsoftrc.sample
800 DESTINATION /etc/openal
803 MESSAGE(STATUS "Installing sample alsoft.conf")
808 ADD_EXECUTABLE(openal-info utils/openal-info.c)
809 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
811 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
813 TARGET_LINK_LIBRARIES(makehrtf m)
816 INSTALL(TARGETS openal-info makehrtf
817 RUNTIME DESTINATION bin
818 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
819 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
821 MESSAGE(STATUS "Building utility programs")
827 ADD_EXECUTABLE(alstream examples/alhelpers.c examples/alffmpeg.c examples/alstream.c)
828 TARGET_LINK_LIBRARIES(alstream ${FFMPEG_LIBRARIES} ${LIBNAME})
829 SET_TARGET_PROPERTIES(alstream PROPERTIES COMPILE_FLAGS "${FFMPEG_CFLAGS}")
830 INSTALL(TARGETS alstream
831 RUNTIME DESTINATION bin
832 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
833 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
836 MESSAGE(STATUS "Building ffmpeg example programs")