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=0x0500")
76 SET(LIB_MAJOR_VERSION "1")
77 SET(LIB_MINOR_VERSION "13")
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=0x0500)
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 0x0500
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
440 SET(HAVE_PORTAUDIO 0)
441 SET(HAVE_PULSEAUDIO 0)
442 SET(HAVE_COREAUDIO 0)
448 CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
449 IF(HAVE_ALSA_ASOUNDLIB_H)
450 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
451 IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
453 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
454 IF(HAVE_DLFCN_H OR WIN32)
455 SET(BACKENDS "${BACKENDS} ALSA,")
457 SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
458 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
463 IF(REQUIRE_ALSA AND NOT HAVE_ALSA)
464 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
469 CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
470 IF(HAVE_SYS_SOUNDCARD_H)
472 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
473 SET(BACKENDS "${BACKENDS} OSS,")
476 IF(REQUIRE_OSS AND NOT HAVE_OSS)
477 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
480 # Check Solaris backend
482 CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
483 IF(HAVE_SYS_AUDIOIO_H)
485 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
486 SET(BACKENDS "${BACKENDS} Solaris,")
489 IF(REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
490 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
493 # Check SndIO backend
495 CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
497 CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
498 IF(HAVE_LIBSNDIO OR HAVE_DLFCN_H OR WIN32)
500 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
501 IF(HAVE_DLFCN_H OR WIN32)
502 SET(BACKENDS "${BACKENDS} SndIO,")
504 SET(BACKENDS "${BACKENDS} SndIO \(linked\),")
505 SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
510 IF(REQUIRE_SNDIO AND NOT HAVE_SNDIO)
511 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
514 # Check for MMDevApi backend
517 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
518 IF(HAVE_MMDEVICEAPI_H)
520 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
522 SET(BACKENDS "${BACKENDS} MMDevApi,")
526 IF(REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
527 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
530 # Check DSound/MMSystem backend
532 CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
534 CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
535 IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
537 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
539 IF(HAVE_DLFCN_H OR WIN32)
540 SET(BACKENDS "${BACKENDS} DirectSound,")
542 SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
543 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
548 IF(REQUIRE_DSOUND AND NOT HAVE_DSOUND)
549 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
554 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0500)
555 IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
557 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
558 SET(BACKENDS "${BACKENDS} WinMM,")
562 IF(REQUIRE_WINMM AND NOT HAVE_WINMM)
563 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
566 # Check PortAudio backend
568 CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
570 CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
571 IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
572 SET(HAVE_PORTAUDIO 1)
573 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
574 IF(HAVE_DLFCN_H OR WIN32)
575 SET(BACKENDS "${BACKENDS} PortAudio,")
577 SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
578 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
583 IF(REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
584 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
587 # Check PulseAudio backend
589 CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
590 IF(HAVE_PULSE_PULSEAUDIO_H)
591 CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
592 IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
593 SET(HAVE_PULSEAUDIO 1)
594 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
595 IF(HAVE_DLFCN_H OR WIN32)
596 SET(BACKENDS "${BACKENDS} PulseAudio,")
598 SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
599 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
604 IF(REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
605 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
608 # Check CoreAudio backend
610 CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
611 IF(HAVE_COREAUDIO_FRAMEWORK)
612 SET(HAVE_COREAUDIO 1)
613 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
614 SET(BACKENDS "${BACKENDS} CoreAudio,")
615 SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
616 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
617 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
619 # Some versions of OSX may need the AudioToolbox framework. Add it if
621 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
623 PATHS ~/Library/Frameworks
625 /System/Library/Frameworks
627 IF(AUDIOTOOLBOX_LIBRARY)
628 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
632 IF(REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
633 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
636 # Check for OpenSL (Android) backend
638 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
639 IF(HAVE_SLES_OPENSLES_ANDROID_H)
640 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
643 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
644 SET(BACKENDS "${BACKENDS} OpenSL,")
645 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
649 IF(REQUIRE_OPENSL AND NOT HAVE_OPENSL)
650 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
653 # Optionally enable the Wave Writer backend
656 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
657 SET(BACKENDS "${BACKENDS} WaveFile,")
660 # This is always available
661 SET(BACKENDS "${BACKENDS} Null")
664 PKG_CHECK_MODULES(FFMPEG libavcodec libavformat)
667 IF(LIBTYPE STREQUAL "STATIC")
668 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
669 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
672 # Needed for openal.pc.in
673 SET(prefix ${CMAKE_INSTALL_PREFIX})
674 SET(exec_prefix "\${prefix}")
675 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
676 SET(bindir "\${exec_prefix}/bin")
677 SET(includedir "\${prefix}/include")
678 SET(PACKAGE_VERSION "${LIB_VERSION}")
682 "${OpenAL_SOURCE_DIR}/config.h.in"
683 "${OpenAL_BINARY_DIR}/config.h")
685 "${OpenAL_SOURCE_DIR}/openal.pc.in"
686 "${OpenAL_BINARY_DIR}/openal.pc"
690 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
691 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY
692 COMPILE_FLAGS -DAL_ALEXT_PROTOTYPES
693 VERSION ${LIB_VERSION}.0
694 SOVERSION ${LIB_MAJOR_VERSION})
695 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
696 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
699 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
701 # Add an install target here
702 INSTALL(TARGETS ${LIBNAME}
703 RUNTIME DESTINATION bin
704 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
705 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
707 INSTALL(FILES include/AL/al.h
711 include/AL/efx-creative.h
712 include/AL/efx-presets.h
713 DESTINATION include/AL
715 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
716 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
720 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
721 MESSAGE(STATUS " ${BACKENDS}")
726 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
727 MESSAGE(STATUS " This is probably NOT what you want!")
732 # Install alsoft.conf configuration file
734 INSTALL(FILES alsoftrc.sample
735 DESTINATION /etc/openal
738 MESSAGE(STATUS "Installing sample alsoft.conf")
743 ADD_EXECUTABLE(openal-info utils/openal-info.c)
744 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
745 INSTALL(TARGETS openal-info
746 RUNTIME DESTINATION bin
747 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
748 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
750 MESSAGE(STATUS "Building utility programs")
756 ADD_EXECUTABLE(alstream examples/alhelpers.c examples/alffmpeg.c examples/alstream.c)
757 TARGET_LINK_LIBRARIES(alstream ${FFMPEG_LIBRARIES} ${LIBNAME})
758 SET_TARGET_PROPERTIES(alstream PROPERTIES COMPILE_FLAGS "${FFMPEG_CFLAGS}")
759 INSTALL(TARGETS alstream
760 RUNTIME DESTINATION bin
761 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
762 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
765 MESSAGE(STATUS "Building ffmpeg example programs")