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(ALSA "Check for ALSA backend" ON)
30 OPTION(OSS "Check for OSS backend" ON)
31 OPTION(SOLARIS "Check for Solaris backend" ON)
32 OPTION(SNDIO "Check for SndIO backend" ON)
33 OPTION(MMDEVAPI "Check for MMDevApi" ON)
34 OPTION(DSOUND "Check for DirectSound backend" ON)
35 OPTION(WINMM "Check for Windows Multimedia backend" ON)
36 OPTION(PORTAUDIO "Check for PortAudio backend" ON)
37 OPTION(PULSEAUDIO "Check for PulseAudio backend" ON)
38 OPTION(COREAUDIO "Check for CoreAudio backend" ON)
39 OPTION(OPENSL "Check for OpenSL backend" ON)
40 OPTION(WAVE "Enable Wave Writer backend" ON)
42 OPTION(REQUIRE_ALSA "Require ALSA backend" OFF)
43 OPTION(REQUIRE_OSS "Require OSS backend" OFF)
44 OPTION(REQUIRE_SOLARIS "Require Solaris backend" OFF)
45 OPTION(REQUIRE_SNDIO "Require SndIO backend" OFF)
46 OPTION(REQUIRE_MMDEVAPI "Require MMDevApi" OFF)
47 OPTION(REQUIRE_DSOUND "Require DirectSound backend" OFF)
48 OPTION(REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
49 OPTION(REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
50 OPTION(REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
51 OPTION(REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
52 OPTION(REQUIRE_OPENSL "Require OpenSL backend" OFF)
54 OPTION(DLOPEN "Check for the dlopen API for loading optional libs" ON)
56 OPTION(WERROR "Treat compile warnings as errors" OFF)
58 OPTION(UTILS "Build and install utility programs" ON)
60 OPTION(EXAMPLES "Build and install example programs" ON)
62 OPTION(ALSOFT_CONFIG "Install alsoft.conf configuration file" OFF)
67 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0501")
76 SET(LIB_MAJOR_VERSION "1")
77 SET(LIB_MINOR_VERSION "14")
78 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}")
83 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
84 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
87 CHECK_C_SOURCE_COMPILES("int *restrict foo;
88 int main() {return 0;}" HAVE_RESTRICT)
89 CHECK_C_SOURCE_COMPILES("int *__restrict foo;
90 int main() {return 0;}" HAVE___RESTRICT)
93 # Add definitions, compiler switches, etc.
94 INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}")
96 IF(NOT CMAKE_BUILD_TYPE)
97 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
98 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
101 IF(NOT CMAKE_DEBUG_POSTFIX)
102 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
103 "Library postfix for debug builds. Normally left blank."
109 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
110 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
111 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
112 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
113 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
114 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
117 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
119 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
122 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
123 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
124 INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
125 LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
128 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
129 IF(FORCE_STATIC_VCRT)
131 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
132 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
133 IF(${flag_var} MATCHES "/MD")
134 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
139 ADD_DEFINITIONS(-Winline -Wall)
140 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
142 ADD_DEFINITIONS(-Wextra)
146 ADD_DEFINITIONS(-Werror)
149 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
150 "Flags used by the compiler during Release with Debug Info builds."
152 SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
153 "Flags used by the compiler during release minsize builds."
155 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
156 "Flags used by the compiler during release builds"
158 SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
159 "Flags used by the compiler during debug builds."
162 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
163 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
166 # Set visibility/export options if available
168 SET(EXPORT_DECL "__declspec(dllexport)")
170 OPTION(WINE "Enable use of Wine headers when compiling" OFF)
172 FIND_PATH(WINE_INCLUDE_DIR library.h
175 /usr/local/include/wine
176 CMAKE_FIND_ROOT_PATH_BOTH)
178 MESSAGE(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" )
179 INCLUDE_DIRECTORIES("${WINE_INCLUDE_DIR}/windows")
180 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${WINE_INCLUDE_DIR}/windows")
182 MESSAGE(STATUS "Could not find Wine header files" )
186 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
187 # Yes GCC, really don't accept visibility modes you don't support
188 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
190 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
191 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
192 IF(HAVE_GCC_PROTECTED_VISIBILITY)
193 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
195 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
196 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
197 IF(HAVE_GCC_DEFAULT_VISIBILITY)
198 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
202 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
203 CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
204 IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
205 ADD_DEFINITIONS(-fvisibility=internal)
207 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
208 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
209 ADD_DEFINITIONS(-fvisibility=hidden)
214 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
217 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
218 int main() {return 0;}" HAVE_GCC_FORMAT)
220 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
221 CHECK_INCLUDE_FILE(fpu_control.h HAVE_FPU_CONTROL_H)
222 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
223 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
224 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
225 IF(NOT HAVE_GUIDDEF_H)
226 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
228 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
230 # Some systems need libm for some of the following math functions to work
231 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
233 SET(EXTRA_LIBS m ${EXTRA_LIBS})
234 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
238 CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF)
239 CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF)
240 CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF)
241 CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF)
242 CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF)
243 CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF)
244 CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF)
245 CHECK_SYMBOL_EXISTS(atan2f math.h HAVE_ATAN2F)
246 CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF)
247 CHECK_SYMBOL_EXISTS(log10f math.h HAVE_LOG10F)
248 CHECK_SYMBOL_EXISTS(floorf math.h HAVE_FLOORF)
251 CHECK_SYMBOL_EXISTS(fesetround fenv.h HAVE_FESETROUND)
254 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
255 CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP)
257 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
258 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
259 IF(NOT HAVE_STRCASECMP)
260 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
261 IF(NOT HAVE__STRICMP)
262 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
265 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
268 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
269 IF(NOT HAVE_STRNCASECMP)
270 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
271 IF(NOT HAVE__STRNICMP)
272 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
275 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
278 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
279 IF(NOT HAVE_SNPRINTF)
280 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
281 IF(NOT HAVE__SNPRINTF)
282 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
285 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
288 CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
289 IF(NOT HAVE_VSNPRINTF)
290 CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF)
291 IF(NOT HAVE__VSNPRINTF)
292 MESSAGE(FATAL_ERROR "No vsnprintf function found, please report!")
295 ADD_DEFINITIONS(-Dvsnprintf=_vsnprintf)
298 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
299 IF(NOT HAVE_ISFINITE)
300 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
302 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
304 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
306 ADD_DEFINITIONS(-Disfinite=_finite)
308 ADD_DEFINITIONS(-Disfinite=finite)
312 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
314 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
316 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
319 ADD_DEFINITIONS(-Disnan=_isnan)
323 # Check for the dlopen API (for dynamicly loading backend libs)
325 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
327 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
329 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
334 # Check if we have Windows headers
335 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501)
336 IF(NOT HAVE_WINDOWS_H)
337 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
338 IF(NOT HAVE_GETTIMEOFDAY)
339 MESSAGE(FATAL_ERROR "No timing function found!")
342 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
343 IF(NOT HAVE_NANOSLEEP)
344 MESSAGE(FATAL_ERROR "No sleep function found!")
347 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
349 ADD_DEFINITIONS(-pthread)
350 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
353 # We need pthreads outside of Windows
354 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
355 IF(NOT HAVE_PTHREAD_H)
356 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
358 # Some systems need pthread_np.h to get recursive mutexes
359 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
361 # _GNU_SOURCE is needed on some systems for extra attributes, and
362 # _REENTRANT is needed for libc thread-safety
363 ADD_DEFINITIONS(-D_GNU_SOURCE=1)
364 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
366 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
369 CHECK_LIBRARY_EXISTS(pthread pthread_setschedparam "" HAVE_PTHREAD_SETSCHEDPARAM)
371 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
373 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
377 # Check for a 64-bit type
378 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
379 IF(NOT HAVE_STDINT_H)
381 CHECK_C_SOURCE_COMPILES("\#define _WIN32_WINNT 0x0501
382 \#include <windows.h>
384 int main() {return 0;}" HAVE___INT64)
387 IF(NOT SIZEOF_LONG MATCHES "8")
388 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
389 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
395 # Windows needs winmm for timeGetTime, even if the backend is disabled
396 CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
398 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
399 SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
403 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
407 OpenAL32/alExtension.c
409 OpenAL32/alListener.c
414 SET(ALC_OBJS Alc/ALc.c
428 # Default backends, always available
429 Alc/backends/loopback.c
441 SET(HAVE_PORTAUDIO 0)
442 SET(HAVE_PULSEAUDIO 0)
443 SET(HAVE_COREAUDIO 0)
449 CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
450 IF(HAVE_ALSA_ASOUNDLIB_H)
451 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
452 IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
454 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
455 IF(HAVE_DLFCN_H OR WIN32)
456 SET(BACKENDS "${BACKENDS} ALSA,")
458 SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
459 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
464 IF(REQUIRE_ALSA AND NOT HAVE_ALSA)
465 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
470 CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
471 IF(HAVE_SYS_SOUNDCARD_H)
473 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
474 SET(BACKENDS "${BACKENDS} OSS,")
477 IF(REQUIRE_OSS AND NOT HAVE_OSS)
478 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
481 # Check Solaris backend
483 CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
484 IF(HAVE_SYS_AUDIOIO_H)
486 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
487 SET(BACKENDS "${BACKENDS} Solaris,")
490 IF(REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
491 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
494 # Check SndIO backend
496 CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
498 CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
499 IF(HAVE_LIBSNDIO OR HAVE_DLFCN_H OR WIN32)
501 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
502 IF(HAVE_DLFCN_H OR WIN32)
503 SET(BACKENDS "${BACKENDS} SndIO,")
505 SET(BACKENDS "${BACKENDS} SndIO \(linked\),")
506 SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
511 IF(REQUIRE_SNDIO AND NOT HAVE_SNDIO)
512 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
515 # Check for MMDevApi backend
518 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
519 IF(HAVE_MMDEVICEAPI_H)
521 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
523 SET(BACKENDS "${BACKENDS} MMDevApi,")
527 IF(REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
528 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
531 # Check DSound/MMSystem backend
533 CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
535 CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
536 IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
538 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
540 IF(HAVE_DLFCN_H OR WIN32)
541 SET(BACKENDS "${BACKENDS} DirectSound,")
543 SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
544 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
549 IF(REQUIRE_DSOUND AND NOT HAVE_DSOUND)
550 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
555 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0501)
556 IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
558 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
559 SET(BACKENDS "${BACKENDS} WinMM,")
563 IF(REQUIRE_WINMM AND NOT HAVE_WINMM)
564 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
567 # Check PortAudio backend
569 CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
571 CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
572 IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
573 SET(HAVE_PORTAUDIO 1)
574 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
575 IF(HAVE_DLFCN_H OR WIN32)
576 SET(BACKENDS "${BACKENDS} PortAudio,")
578 SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
579 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
584 IF(REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
585 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
588 # Check PulseAudio backend
590 CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
591 IF(HAVE_PULSE_PULSEAUDIO_H)
592 CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
593 IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
594 SET(HAVE_PULSEAUDIO 1)
595 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
596 IF(HAVE_DLFCN_H OR WIN32)
597 SET(BACKENDS "${BACKENDS} PulseAudio,")
599 SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
600 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
605 IF(REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
606 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
609 # Check CoreAudio backend
611 CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
612 IF(HAVE_COREAUDIO_FRAMEWORK)
613 SET(HAVE_COREAUDIO 1)
614 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
615 SET(BACKENDS "${BACKENDS} CoreAudio,")
616 SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
617 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
618 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
620 # Some versions of OSX may need the AudioToolbox framework. Add it if
622 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
624 PATHS ~/Library/Frameworks
626 /System/Library/Frameworks
628 IF(AUDIOTOOLBOX_LIBRARY)
629 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
633 IF(REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
634 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
637 # Check for OpenSL (Android) backend
639 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
640 IF(HAVE_SLES_OPENSLES_ANDROID_H)
641 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
644 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
645 SET(BACKENDS "${BACKENDS} OpenSL,")
646 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
650 IF(REQUIRE_OPENSL AND NOT HAVE_OPENSL)
651 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
654 # Optionally enable the Wave Writer backend
657 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
658 SET(BACKENDS "${BACKENDS} WaveFile,")
661 # This is always available
662 SET(BACKENDS "${BACKENDS} Null")
665 # Might be able to use earlier versions, but these definitely work
666 PKG_CHECK_MODULES(FFMPEG libavcodec>=52.123.0 libavformat>=52.111.0 libavutil>=51.9.1)
669 IF(LIBTYPE STREQUAL "STATIC")
670 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
671 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
674 # Needed for openal.pc.in
675 SET(prefix ${CMAKE_INSTALL_PREFIX})
676 SET(exec_prefix "\${prefix}")
677 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
678 SET(bindir "\${exec_prefix}/bin")
679 SET(includedir "\${prefix}/include")
680 SET(PACKAGE_VERSION "${LIB_VERSION}")
684 "${OpenAL_SOURCE_DIR}/config.h.in"
685 "${OpenAL_BINARY_DIR}/config.h")
687 "${OpenAL_SOURCE_DIR}/openal.pc.in"
688 "${OpenAL_BINARY_DIR}/openal.pc"
692 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
693 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY
694 COMPILE_FLAGS -DAL_ALEXT_PROTOTYPES
695 VERSION ${LIB_VERSION}.0
696 SOVERSION ${LIB_MAJOR_VERSION})
697 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
698 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
701 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
703 # Add an install target here
704 INSTALL(TARGETS ${LIBNAME}
705 RUNTIME DESTINATION bin
706 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
707 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
709 INSTALL(FILES include/AL/al.h
713 include/AL/efx-creative.h
714 include/AL/efx-presets.h
715 DESTINATION include/AL
717 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
718 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
722 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
723 MESSAGE(STATUS " ${BACKENDS}")
728 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
729 MESSAGE(STATUS " This is probably NOT what you want!")
734 # Install alsoft.conf configuration file
736 INSTALL(FILES alsoftrc.sample
737 DESTINATION /etc/openal
740 MESSAGE(STATUS "Installing sample alsoft.conf")
745 ADD_EXECUTABLE(openal-info utils/openal-info.c)
746 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
748 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
750 TARGET_LINK_LIBRARIES(makehrtf m)
753 INSTALL(TARGETS openal-info makehrtf
754 RUNTIME DESTINATION bin
755 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
756 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
758 MESSAGE(STATUS "Building utility programs")
764 ADD_EXECUTABLE(alstream examples/alhelpers.c examples/alffmpeg.c examples/alstream.c)
765 TARGET_LINK_LIBRARIES(alstream ${FFMPEG_LIBRARIES} ${LIBNAME})
766 SET_TARGET_PROPERTIES(alstream PROPERTIES COMPILE_FLAGS "${FFMPEG_CFLAGS}")
767 INSTALL(TARGETS alstream
768 RUNTIME DESTINATION bin
769 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
770 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
773 MESSAGE(STATUS "Building ffmpeg example programs")