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)
25 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
28 OPTION(ALSA "Check for ALSA backend" ON)
29 OPTION(OSS "Check for OSS backend" ON)
30 OPTION(SOLARIS "Check for Solaris backend" ON)
31 OPTION(SNDIO "Check for SndIO backend" ON)
32 OPTION(MMDEVAPI "Check for MMDevApi" ON)
33 OPTION(DSOUND "Check for DirectSound backend" ON)
34 OPTION(WINMM "Check for Windows Multimedia backend" ON)
35 OPTION(PORTAUDIO "Check for PortAudio backend" ON)
36 OPTION(PULSEAUDIO "Check for PulseAudio backend" ON)
37 OPTION(COREAUDIO "Check for CoreAudio backend" ON)
38 OPTION(OPENSL "Check for OpenSL backend" ON)
39 OPTION(WAVE "Enable Wave Writer backend" ON)
41 OPTION(REQUIRE_ALSA "Require ALSA backend" OFF)
42 OPTION(REQUIRE_OSS "Require OSS backend" OFF)
43 OPTION(REQUIRE_SOLARIS "Require Solaris backend" OFF)
44 OPTION(REQUIRE_SNDIO "Require SndIO backend" OFF)
45 OPTION(REQUIRE_MMDEVAPI "Require MMDevApi" OFF)
46 OPTION(REQUIRE_DSOUND "Require DirectSound backend" OFF)
47 OPTION(REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
48 OPTION(REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
49 OPTION(REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
50 OPTION(REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
51 OPTION(REQUIRE_OPENSL "Require OpenSL backend" OFF)
53 OPTION(DLOPEN "Check for the dlopen API for loading optional libs" ON)
55 OPTION(WERROR "Treat compile warnings as errors" OFF)
57 OPTION(UTILS "Build and install utility programs" ON)
59 OPTION(ALSOFT_CONFIG "Install alsoft.conf configuration file" OFF)
64 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0500")
73 SET(LIB_MAJOR_VERSION "1")
74 SET(LIB_MINOR_VERSION "13")
75 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}")
80 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
81 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
84 CHECK_C_SOURCE_COMPILES("int *restrict foo;
85 int main() {return 0;}" HAVE_RESTRICT)
86 CHECK_C_SOURCE_COMPILES("int *__restrict foo;
87 int main() {return 0;}" HAVE___RESTRICT)
90 # Add definitions, compiler switches, etc.
91 INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}")
93 IF(NOT CMAKE_BUILD_TYPE)
94 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
95 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
98 IF(NOT CMAKE_DEBUG_POSTFIX)
99 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
100 "Library postfix for debug builds. Normally left blank."
106 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
107 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
108 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
109 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
110 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
111 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
114 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
116 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
119 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
120 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
121 INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
122 LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
125 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
126 IF(FORCE_STATIC_VCRT)
128 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
129 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
130 IF(${flag_var} MATCHES "/MD")
131 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
136 ADD_DEFINITIONS(-Winline -Wall)
137 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
139 ADD_DEFINITIONS(-Wextra)
143 ADD_DEFINITIONS(-Werror)
146 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
147 "Flags used by the compiler during Release with Debug Info builds."
149 SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
150 "Flags used by the compiler during release minsize builds."
152 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
153 "Flags used by the compiler during release builds"
155 SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
156 "Flags used by the compiler during debug builds."
159 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
160 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
163 # Set visibility/export options if available
165 SET(EXPORT_DECL "__declspec(dllexport)")
167 OPTION(WINE "Enable use of Wine headers when compiling" OFF)
169 FIND_PATH(WINE_INCLUDE_DIR library.h
172 /usr/local/include/wine
173 CMAKE_FIND_ROOT_PATH_BOTH)
175 MESSAGE(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" )
176 INCLUDE_DIRECTORIES("${WINE_INCLUDE_DIR}/windows")
177 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${WINE_INCLUDE_DIR}/windows")
179 MESSAGE(STATUS "Could not find Wine header files" )
183 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
184 # Yes GCC, really don't accept visibility modes you don't support
185 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
187 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
188 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
189 IF(HAVE_GCC_PROTECTED_VISIBILITY)
190 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
192 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
193 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
194 IF(HAVE_GCC_DEFAULT_VISIBILITY)
195 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
199 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
200 CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
201 IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
202 ADD_DEFINITIONS(-fvisibility=internal)
204 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
205 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
206 ADD_DEFINITIONS(-fvisibility=hidden)
211 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
214 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
215 int main() {return 0;}" HAVE_GCC_FORMAT)
217 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
218 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
219 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
220 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
221 IF(NOT HAVE_GUIDDEF_H)
222 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
224 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
226 # Some systems need libm for some of the following math functions to work
227 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
229 SET(EXTRA_LIBS m ${EXTRA_LIBS})
230 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
234 CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF)
235 CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF)
236 CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF)
237 CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF)
238 CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF)
239 CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF)
240 CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF)
241 CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF)
244 CHECK_SYMBOL_EXISTS(fesetround fenv.h HAVE_FESETROUND)
247 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
248 CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP)
250 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
251 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
252 IF(NOT HAVE_STRCASECMP)
253 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
254 IF(NOT HAVE__STRICMP)
255 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
258 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
261 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
262 IF(NOT HAVE_STRNCASECMP)
263 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
264 IF(NOT HAVE__STRNICMP)
265 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
268 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
271 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
272 IF(NOT HAVE_SNPRINTF)
273 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
274 IF(NOT HAVE__SNPRINTF)
275 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
278 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
281 CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
282 IF(NOT HAVE_VSNPRINTF)
283 CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF)
284 IF(NOT HAVE__VSNPRINTF)
285 MESSAGE(FATAL_ERROR "No vsnprintf function found, please report!")
288 ADD_DEFINITIONS(-Dvsnprintf=_vsnprintf)
291 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
292 IF(NOT HAVE_ISFINITE)
293 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
295 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
297 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
299 ADD_DEFINITIONS(-Disfinite=_finite)
301 ADD_DEFINITIONS(-Disfinite=finite)
305 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
307 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
309 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
312 ADD_DEFINITIONS(-Disnan=_isnan)
316 # Check for the dlopen API (for dynamicly loading backend libs)
318 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
320 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
322 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
327 # Check if we have Windows headers
328 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0500)
329 IF(NOT HAVE_WINDOWS_H)
330 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
331 IF(NOT HAVE_GETTIMEOFDAY)
332 MESSAGE(FATAL_ERROR "No timing function found!")
335 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
336 IF(NOT HAVE_NANOSLEEP)
337 MESSAGE(FATAL_ERROR "No sleep function found!")
340 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
342 ADD_DEFINITIONS(-pthread)
343 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
346 # We need pthreads outside of Windows
347 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
348 IF(NOT HAVE_PTHREAD_H)
349 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
351 # Some systems need pthread_np.h to get recursive mutexes
352 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
354 # _GNU_SOURCE is needed on some systems for extra attributes, and
355 # _REENTRANT is needed for libc thread-safety
356 ADD_DEFINITIONS(-D_GNU_SOURCE=1)
357 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
359 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
362 CHECK_LIBRARY_EXISTS(pthread pthread_setschedparam "" HAVE_PTHREAD_SETSCHEDPARAM)
364 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
366 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
370 # Check for a 64-bit type
371 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
372 IF(NOT HAVE_STDINT_H)
374 CHECK_C_SOURCE_COMPILES("\#define _WIN32_WINNT 0x0500
375 \#include <windows.h>
377 int main() {return 0;}" HAVE___INT64)
380 IF(NOT SIZEOF_LONG MATCHES "8")
381 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
382 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
388 # Windows needs winmm for timeGetTime, even if the backend is disabled
389 CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
391 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
392 SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
396 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
400 OpenAL32/alExtension.c
402 OpenAL32/alListener.c
407 SET(ALC_OBJS Alc/ALc.c
421 # Default backends, always available
422 Alc/backends/loopback.c
433 SET(HAVE_PORTAUDIO 0)
434 SET(HAVE_PULSEAUDIO 0)
435 SET(HAVE_COREAUDIO 0)
441 CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
442 IF(HAVE_ALSA_ASOUNDLIB_H)
443 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
444 IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
446 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
447 IF(HAVE_DLFCN_H OR WIN32)
448 SET(BACKENDS "${BACKENDS} ALSA,")
450 SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
451 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
456 IF(REQUIRE_ALSA AND NOT HAVE_ALSA)
457 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
462 CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
463 IF(HAVE_SYS_SOUNDCARD_H)
465 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
466 SET(BACKENDS "${BACKENDS} OSS,")
469 IF(REQUIRE_OSS AND NOT HAVE_OSS)
470 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
473 # Check Solaris backend
475 CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
476 IF(HAVE_SYS_AUDIOIO_H)
478 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
479 SET(BACKENDS "${BACKENDS} Solaris,")
482 IF(REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
483 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
486 # Check SndIO backend
488 CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
490 CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
491 IF(HAVE_LIBSNDIO OR HAVE_DLFCN_H OR WIN32)
493 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
494 IF(HAVE_DLFCN_H OR WIN32)
495 SET(BACKENDS "${BACKENDS} SndIO,")
497 SET(BACKENDS "${BACKENDS} SndIO \(linked\),")
498 SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
503 IF(REQUIRE_SNDIO AND NOT HAVE_SNDIO)
504 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
507 # Check for MMDevApi backend
510 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
511 IF(HAVE_MMDEVICEAPI_H)
513 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
515 SET(BACKENDS "${BACKENDS} MMDevApi,")
519 IF(REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
520 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
523 # Check DSound/MMSystem backend
525 CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
527 CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
528 IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
530 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
532 IF(HAVE_DLFCN_H OR WIN32)
533 SET(BACKENDS "${BACKENDS} DirectSound,")
535 SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
536 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
541 IF(REQUIRE_DSOUND AND NOT HAVE_DSOUND)
542 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
547 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0500)
548 IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
550 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
551 SET(BACKENDS "${BACKENDS} WinMM,")
555 IF(REQUIRE_WINMM AND NOT HAVE_WINMM)
556 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
559 # Check PortAudio backend
561 CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
563 CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
564 IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
565 SET(HAVE_PORTAUDIO 1)
566 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
567 IF(HAVE_DLFCN_H OR WIN32)
568 SET(BACKENDS "${BACKENDS} PortAudio,")
570 SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
571 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
576 IF(REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
577 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
580 # Check PulseAudio backend
582 CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
583 IF(HAVE_PULSE_PULSEAUDIO_H)
584 CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
585 IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
586 SET(HAVE_PULSEAUDIO 1)
587 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
588 IF(HAVE_DLFCN_H OR WIN32)
589 SET(BACKENDS "${BACKENDS} PulseAudio,")
591 SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
592 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
597 IF(REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
598 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
601 # Check CoreAudio backend
603 CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
604 IF(HAVE_COREAUDIO_FRAMEWORK)
605 SET(HAVE_COREAUDIO 1)
606 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
607 SET(BACKENDS "${BACKENDS} CoreAudio,")
608 SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
609 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
610 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
613 IF(REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
614 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
617 # Check for OpenSL (Android) backend
619 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
620 IF(HAVE_SLES_OPENSLES_ANDROID_H)
621 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
624 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
625 SET(BACKENDS "${BACKENDS} OpenSL,")
626 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
630 IF(REQUIRE_OPENSL AND NOT HAVE_OPENSL)
631 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
634 # Optionally enable the Wave Writer backend
637 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
638 SET(BACKENDS "${BACKENDS} WaveFile,")
641 # This is always available
642 SET(BACKENDS "${BACKENDS} Null")
644 IF(LIBTYPE STREQUAL "STATIC")
645 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
646 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
649 # Needed for openal.pc.in
650 SET(prefix ${CMAKE_INSTALL_PREFIX})
651 SET(exec_prefix "\${prefix}")
652 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
653 SET(bindir "\${exec_prefix}/bin")
654 SET(includedir "\${prefix}/include")
655 SET(PACKAGE_VERSION "${LIB_VERSION}")
659 "${OpenAL_SOURCE_DIR}/config.h.in"
660 "${OpenAL_BINARY_DIR}/config.h")
662 "${OpenAL_SOURCE_DIR}/openal.pc.in"
663 "${OpenAL_BINARY_DIR}/openal.pc"
667 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
668 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY
669 COMPILE_FLAGS -DAL_ALEXT_PROTOTYPES
670 VERSION ${LIB_VERSION}.0
671 SOVERSION ${LIB_MAJOR_VERSION})
672 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
673 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
676 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
678 # Add an install target here
679 INSTALL(TARGETS ${LIBNAME}
680 RUNTIME DESTINATION bin
681 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
682 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
684 INSTALL(FILES include/AL/al.h
688 include/AL/efx-creative.h
689 DESTINATION include/AL
691 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
692 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
696 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
697 MESSAGE(STATUS " ${BACKENDS}")
702 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
703 MESSAGE(STATUS " This is probably NOT what you want!")
708 # Install alsoft.conf configuration file
710 INSTALL(FILES alsoftrc.sample
711 DESTINATION /etc/openal
714 MESSAGE(STATUS "Installing sample alsoft.conf")
719 ADD_EXECUTABLE(openal-info utils/openal-info.c)
720 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
721 INSTALL(TARGETS openal-info
722 RUNTIME DESTINATION bin
723 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
724 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
726 MESSAGE(STATUS "Building utility programs")