1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
7 IF(COMMAND CMAKE_POLICY)
8 CMAKE_POLICY(SET CMP0003 NEW)
9 CMAKE_POLICY(SET CMP0005 NEW)
10 ENDIF(COMMAND CMAKE_POLICY)
12 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
14 INCLUDE(CheckFunctionExists)
15 INCLUDE(CheckLibraryExists)
16 INCLUDE(CheckSharedFunctionExists)
17 INCLUDE(CheckIncludeFile)
18 INCLUDE(CheckIncludeFiles)
19 INCLUDE(CheckSymbolExists)
20 INCLUDE(CheckCCompilerFlag)
21 INCLUDE(CheckCSourceCompiles)
22 INCLUDE(CheckTypeSize)
25 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
28 OPTION(ALSOFT_CPUEXT_SSE "Check for SSE/SSE2 support" ON)
29 OPTION(ALSOFT_CPUEXT_NEON "Check for ARM Neon support" ON)
31 OPTION(ALSOFT_REQUIRE_SSE "Require SSE/SSE2 support" OFF)
32 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
35 # This option is mainly for static linking OpenAL Soft into another project
36 # that already defines the IDs. It is up to that project to ensure all
37 # required IDs are defined.
38 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
42 OPTION(ALSOFT_BACKEND_ALSA "Check for ALSA backend" ON)
43 OPTION(ALSOFT_BACKEND_OSS "Check for OSS backend" ON)
44 OPTION(ALSOFT_BACKEND_SOLARIS "Check for Solaris backend" ON)
45 OPTION(ALSOFT_BACKEND_SNDIO "Check for SndIO backend" ON)
46 OPTION(ALSOFT_BACKEND_QSA "Check for QSA backend" ON)
47 OPTION(ALSOFT_BACKEND_MMDEVAPI "Check for MMDevApi backend" ON)
48 OPTION(ALSOFT_BACKEND_DSOUND "Check for DirectSound backend" ON)
49 OPTION(ALSOFT_BACKEND_WINMM "Check for Windows Multimedia backend" ON)
50 OPTION(ALSOFT_BACKEND_PORTAUDIO "Check for PortAudio backend" ON)
51 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Check for PulseAudio backend" ON)
52 OPTION(ALSOFT_BACKEND_COREAUDIO "Check for CoreAudio backend" ON)
53 OPTION(ALSOFT_BACKEND_OPENSL "Check for OpenSL backend" ON)
54 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
56 OPTION(ALSOFT_MIDI_FLUIDSYNTH "Check for FluidSynth MIDI" ON)
58 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
59 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
60 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
61 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
62 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
63 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi" OFF)
64 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
65 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
66 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
67 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
68 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
69 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
71 OPTION(ALSOFT_REQUIRE_FLUIDSYNTH "Require FluidSynth MIDI" OFF)
73 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
75 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
77 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
78 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
80 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
82 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
87 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0501")
92 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
93 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
94 ADD_DEFINITIONS("-I/usr/include")
95 SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
102 SET(LIB_MAJOR_VERSION "1")
103 SET(LIB_MINOR_VERSION "15")
104 SET(LIB_REVISION "1")
105 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
111 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
112 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
115 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
117 SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
120 # MSVC may need workarounds for C99 restrict and inline
122 # TODO: Once we truly require C99, these restrict and inline checks should go
124 CHECK_C_SOURCE_COMPILES("int *restrict foo;
125 int main() {return 0;}" HAVE_RESTRICT)
126 IF(NOT HAVE_RESTRICT)
127 # Slightly convoluted way to do this, because MSVC may barf if restrict is
128 # defined to __restrict.
129 CHECK_C_SOURCE_COMPILES("#define restrict __restrict
132 int main() {return 0;}" HAVE___RESTRICT)
134 ADD_DEFINITIONS(-Drestrict=__restrict)
135 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=__restrict")
137 ADD_DEFINITIONS("-Drestrict=")
138 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
142 CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
143 int main() {return 0;}" HAVE_INLINE)
145 CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
146 int main() {return 0;}" HAVE___INLINE)
147 IF(NOT HAVE___INLINE)
148 MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
151 ADD_DEFINITIONS(-Dinline=__inline)
152 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
156 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
157 IF(CMAKE_COMPILER_IS_GNUCC)
158 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
159 # Force no inlining for the next test.
160 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
162 CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
163 int main() {return foo();}" INLINE_IS_C99)
164 IF(NOT INLINE_IS_C99)
165 MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
166 Please update your compiler for better C99 compliance.")
169 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
172 # Add definitions, compiler switches, etc.
173 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
174 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
175 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
176 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
177 ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
181 IF(NOT CMAKE_BUILD_TYPE)
182 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
183 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
186 IF(NOT CMAKE_DEBUG_POSTFIX)
187 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
188 "Library postfix for debug builds. Normally left blank."
194 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
195 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
196 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
197 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
198 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
199 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
200 ADD_DEFINITIONS("/wd4098")
203 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
205 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
208 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
209 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
210 INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
211 LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
214 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
215 IF(FORCE_STATIC_VCRT)
217 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
218 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
219 IF(${flag_var} MATCHES "/MD")
220 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
225 ADD_DEFINITIONS(-Winline -Wall)
226 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
228 ADD_DEFINITIONS(-Wextra)
232 ADD_DEFINITIONS(-Werror)
235 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
236 "Flags used by the compiler during Release with Debug Info builds."
238 SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
239 "Flags used by the compiler during release minsize builds."
241 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
242 "Flags used by the compiler during release builds"
244 SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
245 "Flags used by the compiler during debug builds."
248 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
249 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
252 # Set visibility/export options if available
254 SET(EXPORT_DECL "__declspec(dllexport)")
256 SET(ALIGN_DECL "__declspec(align(x))")
258 SET(ALIGN_DECL "__declspec(aligned(x))")
261 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
262 # Yes GCC, really don't accept visibility modes you don't support
263 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
265 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
266 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
267 IF(HAVE_GCC_PROTECTED_VISIBILITY)
268 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
270 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
271 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
272 IF(HAVE_GCC_DEFAULT_VISIBILITY)
273 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
277 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
278 CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
279 IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
280 ADD_DEFINITIONS(-fvisibility=internal)
282 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
283 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
284 ADD_DEFINITIONS(-fvisibility=hidden)
289 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
290 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
291 IF(HAVE_ATTRIBUTE_ALIGNED)
292 SET(ALIGN_DECL "__attribute__((aligned(x)))")
295 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
300 CHECK_C_COMPILER_FLAG(/arch:SSE HAVE_ARCHSSE_SWITCH)
301 IF(HAVE_ARCHSSE_SWITCH)
302 SET(SSE_SWITCH "/arch:SSE")
306 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
308 SET(SSE_SWITCH "-msse")
312 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
313 int main() {return 0;}" HAVE_GCC_FORMAT)
315 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
316 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
317 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
318 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
319 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
320 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
321 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
322 IF(NOT HAVE_GUIDDEF_H)
323 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
326 # Some systems need libm for some of the following math functions to work
327 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
329 SET(EXTRA_LIBS m ${EXTRA_LIBS})
330 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
334 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
335 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
336 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
337 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
340 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
341 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
344 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
345 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
346 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
347 IF(NOT HAVE_STRCASECMP)
348 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
349 IF(NOT HAVE__STRICMP)
350 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
353 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
356 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
357 IF(NOT HAVE_STRNCASECMP)
358 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
359 IF(NOT HAVE__STRNICMP)
360 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
363 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
366 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
367 IF(NOT HAVE_SNPRINTF)
368 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
369 IF(NOT HAVE__SNPRINTF)
370 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
373 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
376 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
377 IF(NOT HAVE_ISFINITE)
378 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
380 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
382 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
384 ADD_DEFINITIONS(-Disfinite=_finite)
386 ADD_DEFINITIONS(-Disfinite=finite)
390 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
392 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
394 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
397 ADD_DEFINITIONS(-Disnan=_isnan)
401 # Check for the dlopen API (for dynamicly loading backend libs)
403 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
405 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
407 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
412 # Check if we have Windows headers
413 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501)
414 IF(NOT HAVE_WINDOWS_H)
415 # These are needed on some systems for extra features
416 ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700)
417 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700")
419 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
420 IF(NOT HAVE_GETTIMEOFDAY)
421 MESSAGE(FATAL_ERROR "No timing function found!")
424 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
425 IF(NOT HAVE_NANOSLEEP)
426 MESSAGE(FATAL_ERROR "No sleep function found!")
429 # We need pthreads outside of Windows
430 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
431 IF(NOT HAVE_PTHREAD_H)
432 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
434 # Some systems need pthread_np.h to get recursive mutexes
435 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
437 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
439 ADD_DEFINITIONS(-pthread)
440 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
441 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
444 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
446 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
449 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
451 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
452 IF(NOT HAVE_PTHREAD_SETNAME_NP)
453 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
456 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
458 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
462 # Check for a 64-bit type
463 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
464 IF(NOT HAVE_STDINT_H)
466 CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0501
469 int main() {return 0;}" HAVE___INT64)
472 IF(NOT SIZEOF_LONG MATCHES "8")
473 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
474 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
480 # Windows needs winmm for timeGetTime, even if the backend is disabled
481 CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
483 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
484 SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
488 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
492 OpenAL32/alExtension.c
494 OpenAL32/alFontsound.c
495 OpenAL32/alListener.c
498 OpenAL32/alSoundfont.c
503 SET(ALC_OBJS Alc/ALc.c
508 Alc/effects/autowah.c
510 Alc/effects/compressor.c
511 Alc/effects/dedicated.c
512 Alc/effects/distortion.c
514 Alc/effects/equalizer.c
515 Alc/effects/flanger.c
516 Alc/effects/modulator.c
528 SET(CPU_EXTS "Default")
532 # Check for SSE support
533 IF(ALSOFT_CPUEXT_SSE AND ALIGN_DECL)
534 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
537 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
539 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
540 COMPILE_FLAGS "${SSE_SWITCH}")
542 SET(CPU_EXTS "${CPU_EXTS}, SSE")
545 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
546 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
549 # Check for ARM Neon support
550 IF(ALSOFT_CPUEXT_NEON)
551 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
554 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
555 SET(CPU_EXTS "${CPU_EXTS}, Neon")
558 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
559 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
563 SET(ALC_OBJS ${ALC_OBJS}
566 Alc/midi/fluidsynth.c
569 SET(HAVE_FLUIDSYNTH 0)
571 # Check for FluidSynth support
572 IF(ALSOFT_MIDI_FLUIDSYNTH)
573 FIND_PACKAGE(FluidSynth)
575 SET(HAVE_FLUIDSYNTH 1)
576 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
577 INCLUDE_DIRECTORIES(${FLUIDSYNTH_INCLUDE_DIR})
579 SET(EXTRA_LIBS ${FLUIDSYNTH_LIBRARIES} ${EXTRA_LIBS})
582 IF(ALSOFT_REQUIRE_FLUIDSYNTH AND NOT HAVE_FLUIDSYNTH)
583 MESSAGE(FATAL_ERROR "Failed to enabled required FluidSynth support")
587 SET(ALC_OBJS ${ALC_OBJS}
589 # Default backends, always available
590 Alc/backends/loopback.c
603 SET(HAVE_PORTAUDIO 0)
604 SET(HAVE_PULSEAUDIO 0)
605 SET(HAVE_COREAUDIO 0)
610 IF(ALSOFT_BACKEND_ALSA)
611 CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
612 IF(HAVE_ALSA_ASOUNDLIB_H)
613 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
614 IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
616 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
617 IF(HAVE_DLFCN_H OR WIN32)
618 SET(BACKENDS "${BACKENDS} ALSA,")
620 SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
621 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
626 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
627 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
631 IF(ALSOFT_BACKEND_OSS)
632 CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
633 IF(HAVE_SYS_SOUNDCARD_H)
635 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
636 SET(BACKENDS "${BACKENDS} OSS,")
639 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
640 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
643 # Check Solaris backend
644 IF(ALSOFT_BACKEND_SOLARIS)
645 CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
646 IF(HAVE_SYS_AUDIOIO_H)
648 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
649 SET(BACKENDS "${BACKENDS} Solaris,")
652 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
653 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
656 # Check SndIO backend
657 IF(ALSOFT_BACKEND_SNDIO)
658 CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
660 CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
663 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
664 SET(BACKENDS "${BACKENDS} SndIO \(linked\),")
665 SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
669 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
670 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
674 IF (ALSOFT_BACKEND_QSA AND "${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
675 CHECK_INCLUDE_FILE(sys/asoundlib.h HAVE_SYS_ASOUNDLIB_H)
676 IF(HAVE_SYS_ASOUNDLIB_H)
677 CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "sys/asoundlib.h" asound "" HAVE_LIBASOUND)
680 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
681 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
682 SET(BACKENDS "${BACKENDS} QSA \(linked\),")
686 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
687 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
690 # Check for MMDevApi backend
692 IF(ALSOFT_BACKEND_MMDEVAPI)
693 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
694 IF(HAVE_MMDEVICEAPI_H)
696 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
698 SET(BACKENDS "${BACKENDS} MMDevApi,")
702 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
703 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
706 # Check DSound/MMSystem backend
707 IF(ALSOFT_BACKEND_DSOUND)
708 CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
710 CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
711 IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
713 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
715 IF(HAVE_DLFCN_H OR WIN32)
716 SET(BACKENDS "${BACKENDS} DirectSound,")
718 SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
719 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
724 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
725 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
729 IF(ALSOFT_BACKEND_WINMM)
730 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0501)
731 IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
733 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
734 SET(BACKENDS "${BACKENDS} WinMM,")
738 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
739 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
742 # Check PortAudio backend
743 IF(ALSOFT_BACKEND_PORTAUDIO)
744 CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
746 CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
747 IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
748 SET(HAVE_PORTAUDIO 1)
749 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
750 IF(HAVE_DLFCN_H OR WIN32)
751 SET(BACKENDS "${BACKENDS} PortAudio,")
753 SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
754 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
759 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
760 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
763 # Check PulseAudio backend
764 IF(ALSOFT_BACKEND_PULSEAUDIO)
765 CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
766 IF(HAVE_PULSE_PULSEAUDIO_H)
767 CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
768 IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
769 SET(HAVE_PULSEAUDIO 1)
770 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
771 IF(HAVE_DLFCN_H OR WIN32)
772 SET(BACKENDS "${BACKENDS} PulseAudio,")
774 SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
775 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
780 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
781 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
784 # Check CoreAudio backend
785 IF(ALSOFT_BACKEND_COREAUDIO)
786 CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
787 IF(HAVE_COREAUDIO_FRAMEWORK)
788 SET(HAVE_COREAUDIO 1)
789 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
790 SET(BACKENDS "${BACKENDS} CoreAudio,")
791 SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
792 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
793 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
795 # Some versions of OSX may need the AudioToolbox framework. Add it if
797 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
799 PATHS ~/Library/Frameworks
801 /System/Library/Frameworks
803 IF(AUDIOTOOLBOX_LIBRARY)
804 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
808 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
809 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
812 # Check for OpenSL (Android) backend
813 IF(ALSOFT_BACKEND_OPENSL)
814 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
815 IF(HAVE_SLES_OPENSLES_ANDROID_H)
816 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
819 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
820 SET(BACKENDS "${BACKENDS} OpenSL,")
821 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
825 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
826 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
829 # Optionally enable the Wave Writer backend
830 IF(ALSOFT_BACKEND_WAVE)
832 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
833 SET(BACKENDS "${BACKENDS} WaveFile,")
836 # This is always available
837 SET(BACKENDS "${BACKENDS} Null")
839 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
840 add_subdirectory(utils/alsoft-config)
845 FIND_PACKAGE(SDL_sound)
846 IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
847 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
852 IF(LIBTYPE STREQUAL "STATIC")
853 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
854 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
857 # Needed for openal.pc.in
858 SET(prefix ${CMAKE_INSTALL_PREFIX})
859 SET(exec_prefix "\${prefix}")
860 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
861 SET(bindir "\${exec_prefix}/bin")
862 SET(includedir "\${prefix}/include")
863 SET(PACKAGE_VERSION "${LIB_VERSION}")
867 "${OpenAL_SOURCE_DIR}/config.h.in"
868 "${OpenAL_BINARY_DIR}/config.h")
870 "${OpenAL_SOURCE_DIR}/openal.pc.in"
871 "${OpenAL_BINARY_DIR}/openal.pc"
875 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
876 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
877 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
878 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
880 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
882 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${FLUIDSYNTH_INCLUDE_DIR})
884 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
885 SOVERSION ${LIB_MAJOR_VERSION})
886 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
887 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
890 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
892 # Add an install target here
893 INSTALL(TARGETS ${LIBNAME}
894 RUNTIME DESTINATION bin
895 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
896 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
898 INSTALL(FILES include/AL/al.h
902 include/AL/efx-creative.h
903 include/AL/efx-presets.h
904 DESTINATION include/AL
906 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
907 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
911 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
912 MESSAGE(STATUS " ${BACKENDS}")
914 MESSAGE(STATUS "Building with support for CPU extensions:")
915 MESSAGE(STATUS " ${CPU_EXTS}")
918 MESSAGE(STATUS "FluidSynth support for ALC_SOFT_midi_interface enabled")
924 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
925 MESSAGE(STATUS " This is probably NOT what you want!")
930 # Install alsoft.conf configuration file
932 INSTALL(FILES alsoftrc.sample
933 DESTINATION share/openal
935 MESSAGE(STATUS "Installing sample configuration")
940 ADD_EXECUTABLE(openal-info utils/openal-info.c)
941 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
943 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
945 TARGET_LINK_LIBRARIES(makehrtf m)
948 INSTALL(TARGETS openal-info makehrtf
949 RUNTIME DESTINATION bin
950 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
951 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
954 MESSAGE(STATUS "Building utility programs")
955 IF(TARGET alsoft-config)
956 MESSAGE(STATUS "Building configuration program")
962 IF(SDL_FOUND AND SDL_SOUND_FOUND)
963 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
964 examples/common/sdl_sound.c)
965 SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
967 ADD_EXECUTABLE(alstream examples/alstream.c)
968 TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
969 SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
971 ADD_EXECUTABLE(alreverb examples/alreverb.c)
972 TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
973 SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
975 ADD_EXECUTABLE(allatency examples/allatency.c)
976 TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
977 SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
979 ADD_EXECUTABLE(alloopback examples/alloopback.c)
980 TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL_LIBRARY} ${LIBNAME})
981 SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_INCLUDE_DIR}
982 ${SDL_SOUND_INCLUDE_DIR})
984 INSTALL(TARGETS alstream alreverb allatency alloopback
985 RUNTIME DESTINATION bin
986 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
987 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
990 MESSAGE(STATUS "Building example programs")