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(float.h HAVE_FLOAT_H)
244 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
245 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
246 IF(NOT HAVE_GUIDDEF_H)
247 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
250 # Some systems need libm for some of the following math functions to work
251 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
253 SET(EXTRA_LIBS m ${EXTRA_LIBS})
254 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
258 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
259 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
260 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
261 CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF)
262 CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF)
263 CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF)
264 CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF)
265 CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF)
266 CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF)
267 CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF)
268 CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF)
269 CHECK_SYMBOL_EXISTS(atan2f math.h HAVE_ATAN2F)
270 CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF)
271 CHECK_SYMBOL_EXISTS(log10f math.h HAVE_LOG10F)
272 CHECK_SYMBOL_EXISTS(floorf math.h HAVE_FLOORF)
275 CHECK_SYMBOL_EXISTS(fesetround fenv.h HAVE_FESETROUND)
278 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
279 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
282 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
283 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
284 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
285 IF(NOT HAVE_STRCASECMP)
286 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
287 IF(NOT HAVE__STRICMP)
288 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
291 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
294 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
295 IF(NOT HAVE_STRNCASECMP)
296 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
297 IF(NOT HAVE__STRNICMP)
298 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
301 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
304 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
305 IF(NOT HAVE_SNPRINTF)
306 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
307 IF(NOT HAVE__SNPRINTF)
308 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
311 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
314 CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
315 IF(NOT HAVE_VSNPRINTF)
316 CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF)
317 IF(NOT HAVE__VSNPRINTF)
318 MESSAGE(FATAL_ERROR "No vsnprintf function found, please report!")
321 ADD_DEFINITIONS(-Dvsnprintf=_vsnprintf)
324 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
325 IF(NOT HAVE_ISFINITE)
326 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
328 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
330 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
332 ADD_DEFINITIONS(-Disfinite=_finite)
334 ADD_DEFINITIONS(-Disfinite=finite)
338 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
340 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
342 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
345 ADD_DEFINITIONS(-Disnan=_isnan)
349 # Check for the dlopen API (for dynamicly loading backend libs)
351 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
353 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
355 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
360 # Check if we have Windows headers
361 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501)
362 IF(NOT HAVE_WINDOWS_H)
363 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
364 IF(NOT HAVE_GETTIMEOFDAY)
365 MESSAGE(FATAL_ERROR "No timing function found!")
368 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
369 IF(NOT HAVE_NANOSLEEP)
370 MESSAGE(FATAL_ERROR "No sleep function found!")
373 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
375 ADD_DEFINITIONS(-pthread)
376 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
379 # We need pthreads outside of Windows
380 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
381 IF(NOT HAVE_PTHREAD_H)
382 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
384 # Some systems need pthread_np.h to get recursive mutexes
385 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
387 # _GNU_SOURCE is needed on some systems for extra attributes
388 ADD_DEFINITIONS(-D_GNU_SOURCE=1)
389 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
391 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
394 CHECK_LIBRARY_EXISTS(pthread pthread_setschedparam "" HAVE_PTHREAD_SETSCHEDPARAM)
396 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
398 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
402 # Check for a 64-bit type
403 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
404 IF(NOT HAVE_STDINT_H)
406 CHECK_C_SOURCE_COMPILES("\#define _WIN32_WINNT 0x0501
407 \#include <windows.h>
409 int main() {return 0;}" HAVE___INT64)
412 IF(NOT SIZEOF_LONG MATCHES "8")
413 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
414 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
420 # Windows needs winmm for timeGetTime, even if the backend is disabled
421 CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
423 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
424 SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
428 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
432 OpenAL32/alExtension.c
434 OpenAL32/alListener.c
439 SET(ALC_OBJS Alc/ALc.c
457 SET(CPU_EXTS "Default")
461 # Check for SSE support
463 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
466 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
468 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
469 COMPILE_FLAGS "${SSE_SWITCH}")
471 SET(CPU_EXTS "${CPU_EXTS}, SSE")
474 IF(REQUIRE_SSE AND NOT HAVE_SSE)
475 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
478 # Check for ARM Neon support
480 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
483 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
484 SET(CPU_EXTS "${CPU_EXTS}, Neon")
487 IF(REQUIRE_NEON AND NOT HAVE_NEON)
488 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
492 SET(ALC_OBJS ${ALC_OBJS}
493 # Default backends, always available
494 Alc/backends/loopback.c
506 SET(HAVE_PORTAUDIO 0)
507 SET(HAVE_PULSEAUDIO 0)
508 SET(HAVE_COREAUDIO 0)
514 CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
515 IF(HAVE_ALSA_ASOUNDLIB_H)
516 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
517 IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
519 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
520 IF(HAVE_DLFCN_H OR WIN32)
521 SET(BACKENDS "${BACKENDS} ALSA,")
523 SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
524 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
529 IF(REQUIRE_ALSA AND NOT HAVE_ALSA)
530 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
535 CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
536 IF(HAVE_SYS_SOUNDCARD_H)
538 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
539 SET(BACKENDS "${BACKENDS} OSS,")
542 IF(REQUIRE_OSS AND NOT HAVE_OSS)
543 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
546 # Check Solaris backend
548 CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
549 IF(HAVE_SYS_AUDIOIO_H)
551 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
552 SET(BACKENDS "${BACKENDS} Solaris,")
555 IF(REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
556 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
559 # Check SndIO backend
561 CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
563 CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
566 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
567 SET(BACKENDS "${BACKENDS} SndIO \(linked\),")
568 SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
572 IF(REQUIRE_SNDIO AND NOT HAVE_SNDIO)
573 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
576 # Check for MMDevApi backend
579 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
580 IF(HAVE_MMDEVICEAPI_H)
582 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
584 SET(BACKENDS "${BACKENDS} MMDevApi,")
588 IF(REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
589 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
592 # Check DSound/MMSystem backend
594 CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
596 CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
597 IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
599 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
601 IF(HAVE_DLFCN_H OR WIN32)
602 SET(BACKENDS "${BACKENDS} DirectSound,")
604 SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
605 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
610 IF(REQUIRE_DSOUND AND NOT HAVE_DSOUND)
611 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
616 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0501)
617 IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
619 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
620 SET(BACKENDS "${BACKENDS} WinMM,")
624 IF(REQUIRE_WINMM AND NOT HAVE_WINMM)
625 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
628 # Check PortAudio backend
630 CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
632 CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
633 IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
634 SET(HAVE_PORTAUDIO 1)
635 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
636 IF(HAVE_DLFCN_H OR WIN32)
637 SET(BACKENDS "${BACKENDS} PortAudio,")
639 SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
640 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
645 IF(REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
646 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
649 # Check PulseAudio backend
651 CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
652 IF(HAVE_PULSE_PULSEAUDIO_H)
653 CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
654 IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
655 SET(HAVE_PULSEAUDIO 1)
656 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
657 IF(HAVE_DLFCN_H OR WIN32)
658 SET(BACKENDS "${BACKENDS} PulseAudio,")
660 SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
661 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
666 IF(REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
667 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
670 # Check CoreAudio backend
672 CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
673 IF(HAVE_COREAUDIO_FRAMEWORK)
674 SET(HAVE_COREAUDIO 1)
675 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
676 SET(BACKENDS "${BACKENDS} CoreAudio,")
677 SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
678 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
679 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
681 # Some versions of OSX may need the AudioToolbox framework. Add it if
683 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
685 PATHS ~/Library/Frameworks
687 /System/Library/Frameworks
689 IF(AUDIOTOOLBOX_LIBRARY)
690 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
694 IF(REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
695 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
698 # Check for OpenSL (Android) backend
700 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
701 IF(HAVE_SLES_OPENSLES_ANDROID_H)
702 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
705 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
706 SET(BACKENDS "${BACKENDS} OpenSL,")
707 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
711 IF(REQUIRE_OPENSL AND NOT HAVE_OPENSL)
712 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
715 # Optionally enable the Wave Writer backend
718 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
719 SET(BACKENDS "${BACKENDS} WaveFile,")
722 # This is always available
723 SET(BACKENDS "${BACKENDS} Null")
726 # Might be able to use earlier versions, but these definitely work
727 PKG_CHECK_MODULES(FFMPEG libavcodec>=52.123.0 libavformat>=52.111.0 libavutil>=51.9.1)
730 IF(LIBTYPE STREQUAL "STATIC")
731 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
732 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
735 # Needed for openal.pc.in
736 SET(prefix ${CMAKE_INSTALL_PREFIX})
737 SET(exec_prefix "\${prefix}")
738 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
739 SET(bindir "\${exec_prefix}/bin")
740 SET(includedir "\${prefix}/include")
741 SET(PACKAGE_VERSION "${LIB_VERSION}")
745 "${OpenAL_SOURCE_DIR}/config.h.in"
746 "${OpenAL_BINARY_DIR}/config.h")
748 "${OpenAL_SOURCE_DIR}/openal.pc.in"
749 "${OpenAL_BINARY_DIR}/openal.pc"
753 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
754 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY
755 COMPILE_FLAGS -DAL_ALEXT_PROTOTYPES
756 VERSION ${LIB_VERSION}.0
757 SOVERSION ${LIB_MAJOR_VERSION})
758 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
759 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
762 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
764 # Add an install target here
765 INSTALL(TARGETS ${LIBNAME}
766 RUNTIME DESTINATION bin
767 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
768 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
770 INSTALL(FILES include/AL/al.h
774 include/AL/efx-creative.h
775 include/AL/efx-presets.h
776 DESTINATION include/AL
778 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
779 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
783 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
784 MESSAGE(STATUS " ${BACKENDS}")
786 MESSAGE(STATUS "Building with support for CPU extensions:")
787 MESSAGE(STATUS " ${CPU_EXTS}")
792 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
793 MESSAGE(STATUS " This is probably NOT what you want!")
798 # Install alsoft.conf configuration file
800 INSTALL(FILES alsoftrc.sample
801 DESTINATION /etc/openal
804 MESSAGE(STATUS "Installing sample alsoft.conf")
809 ADD_EXECUTABLE(openal-info utils/openal-info.c)
810 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
812 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
814 TARGET_LINK_LIBRARIES(makehrtf m)
817 INSTALL(TARGETS openal-info makehrtf
818 RUNTIME DESTINATION bin
819 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
820 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
822 MESSAGE(STATUS "Building utility programs")
828 ADD_EXECUTABLE(alstream examples/alhelpers.c examples/alffmpeg.c examples/alstream.c)
829 TARGET_LINK_LIBRARIES(alstream ${FFMPEG_LIBRARIES} ${LIBNAME})
830 SET_TARGET_PROPERTIES(alstream PROPERTIES COMPILE_FLAGS "${FFMPEG_CFLAGS}")
831 INSTALL(TARGETS alstream
832 RUNTIME DESTINATION bin
833 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
834 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
837 MESSAGE(STATUS "Building ffmpeg example programs")