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)
29 # This option is mainly for static linking OpenAL Soft into another project
30 # that already defines the IDs. It is up to that project to ensure all
31 # required IDs are defined.
32 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
34 # These are needed on non-Windows systems for extra features
35 ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700)
36 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700")
40 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
42 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
44 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
45 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
47 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
49 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
50 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
55 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
60 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
61 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
62 ADD_DEFINITIONS("-I/usr/include")
63 SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
70 SET(LIB_MAJOR_VERSION "1")
71 SET(LIB_MINOR_VERSION "15")
73 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
79 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
80 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
83 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
85 SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
88 # MSVC may need workarounds for C99 restrict and inline
90 # TODO: Once we truly require C99, these restrict and inline checks should go
92 CHECK_C_SOURCE_COMPILES("int *restrict foo;
93 int main() {return 0;}" HAVE_RESTRICT)
95 ADD_DEFINITIONS("-Drestrict=")
96 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
99 CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
100 int main() {return 0;}" HAVE_INLINE)
102 CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
103 int main() {return 0;}" HAVE___INLINE)
104 IF(NOT HAVE___INLINE)
105 MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
108 ADD_DEFINITIONS(-Dinline=__inline)
109 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
113 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
114 IF(CMAKE_COMPILER_IS_GNUCC)
115 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
116 # Force no inlining for the next test.
117 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
119 CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
120 int main() {return foo();}" INLINE_IS_C99)
121 IF(NOT INLINE_IS_C99)
122 MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
123 Please update your compiler for better C99 compliance.")
126 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
129 # Check if we have C99 variable length arrays
130 CHECK_C_SOURCE_COMPILES(
131 "int main(int argc, char *argv[])
133 volatile int tmp[argc];
139 # Check if we have C99 bool
140 CHECK_C_SOURCE_COMPILES(
141 "int main(int argc, char *argv[])
144 ret = (argc > 1) ? 1 : 0;
149 # Check if we have C11 static_assert
150 CHECK_C_SOURCE_COMPILES(
153 _Static_assert(sizeof(int) == sizeof(int), \"What\");
156 HAVE_C11_STATIC_ASSERT)
158 # Check if we have C11 alignas
159 CHECK_C_SOURCE_COMPILES(
160 "_Alignas(16) int foo;
167 # Add definitions, compiler switches, etc.
168 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
169 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
170 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
171 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
172 ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
176 IF(NOT CMAKE_BUILD_TYPE)
177 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
178 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
181 IF(NOT CMAKE_DEBUG_POSTFIX)
182 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
183 "Library postfix for debug builds. Normally left blank."
189 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
190 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
191 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
192 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
193 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
194 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
195 ADD_DEFINITIONS("/wd4098")
198 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
200 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
203 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
204 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
205 INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
206 LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
209 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
210 IF(FORCE_STATIC_VCRT)
212 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
213 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
214 IF(${flag_var} MATCHES "/MD")
215 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
220 ADD_DEFINITIONS(-Winline -Wall)
221 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
223 ADD_DEFINITIONS(-Wextra)
227 ADD_DEFINITIONS(-Werror)
230 # Force enable PIC if available. The static common library will be linked
231 # into the dynamic openal library, which requires all its code to be
232 # position-independent, and CMake doesn't automatically enable PIC for
233 # static library targets (Windows code is always position-independent).
234 CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
235 IF(HAVE_FPIC_SWITCH AND NOT WIN32)
236 ADD_DEFINITIONS(-fPIC)
239 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
240 "Flags used by the compiler during Release with Debug Info builds."
242 SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
243 "Flags used by the compiler during release minsize builds."
245 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
246 "Flags used by the compiler during release builds"
248 SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
249 "Flags used by the compiler during debug builds."
252 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
253 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
256 # Set visibility/export options if available
258 SET(EXPORT_DECL "__declspec(dllexport)")
260 SET(ALIGN_DECL "__declspec(align(x))")
262 SET(ALIGN_DECL "__declspec(aligned(x))")
265 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
266 # Yes GCC, really don't accept visibility modes you don't support
267 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
269 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
270 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
271 IF(HAVE_GCC_PROTECTED_VISIBILITY)
272 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
274 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
275 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
276 IF(HAVE_GCC_DEFAULT_VISIBILITY)
277 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
281 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
282 CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
283 IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
284 ADD_DEFINITIONS(-fvisibility=internal)
286 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
287 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
288 ADD_DEFINITIONS(-fvisibility=hidden)
293 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
294 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
295 IF(HAVE_ATTRIBUTE_ALIGNED)
296 SET(ALIGN_DECL "__attribute__((aligned(x)))")
299 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
304 CHECK_C_COMPILER_FLAG(/arch:SSE HAVE_ARCHSSE_SWITCH)
305 IF(HAVE_ARCHSSE_SWITCH)
306 SET(SSE_SWITCH "/arch:SSE")
310 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
312 SET(SSE_SWITCH "-msse")
316 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
317 int main() {return 0;}" HAVE_GCC_FORMAT)
319 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
320 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
322 CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
324 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
325 CHECK_INCLUDE_FILE(ftw.h HAVE_FTW_H)
326 CHECK_INCLUDE_FILE(io.h HAVE_IO_H)
327 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
328 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
329 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
330 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
331 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
332 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
333 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
334 IF(NOT HAVE_GUIDDEF_H)
335 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
338 # Some systems need libm for some of the following math functions to work
339 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
341 SET(EXTRA_LIBS m ${EXTRA_LIBS})
342 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
346 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
347 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
348 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
349 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
352 CHECK_SYMBOL_EXISTS(alloca alloca.h HAVE_ALLOCA)
353 ELSEIF(HAVE_MALLOC_H)
354 CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
357 MESSAGE(FATAL_ERROR "No alloca function found, please report!")
362 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
363 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
366 CHECK_SYMBOL_EXISTS(ftw ftw.h HAVE_FTW)
369 CHECK_SYMBOL_EXISTS(_wfindfirst io.h HAVE__WFINDFIRST)
372 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
373 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
374 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
375 IF(NOT HAVE_STRCASECMP)
376 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
377 IF(NOT HAVE__STRICMP)
378 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
381 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
384 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
385 IF(NOT HAVE_STRNCASECMP)
386 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
387 IF(NOT HAVE__STRNICMP)
388 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
391 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
394 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
395 IF(NOT HAVE_SNPRINTF)
396 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
397 IF(NOT HAVE__SNPRINTF)
398 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
401 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
404 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
405 IF(NOT HAVE_ISFINITE)
406 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
408 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
410 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
412 ADD_DEFINITIONS(-Disfinite=_finite)
414 ADD_DEFINITIONS(-Disfinite=finite)
418 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
420 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
422 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
425 ADD_DEFINITIONS(-Disnan=_isnan)
429 # Check for the dlopen API (for dynamicly loading backend libs)
431 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
433 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
435 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
440 # Check if we have Windows headers
441 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
442 IF(NOT HAVE_WINDOWS_H)
443 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
444 IF(NOT HAVE_GETTIMEOFDAY)
445 MESSAGE(FATAL_ERROR "No timing function found!")
448 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
449 IF(NOT HAVE_NANOSLEEP)
450 MESSAGE(FATAL_ERROR "No sleep function found!")
453 # We need pthreads outside of Windows
454 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
455 IF(NOT HAVE_PTHREAD_H)
456 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
458 # Some systems need pthread_np.h to get recursive mutexes
459 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
461 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
463 ADD_DEFINITIONS(-pthread)
464 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
465 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
468 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
470 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
473 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
475 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
476 IF(NOT HAVE_PTHREAD_SETNAME_NP)
477 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
479 IF(HAVE_PTHREAD_NP_H)
480 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
483 CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
485 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
487 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
491 # Check for a 64-bit type
492 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
493 IF(NOT HAVE_STDINT_H)
495 CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
498 int main() {return 0;}" HAVE___INT64)
501 IF(NOT SIZEOF_LONG MATCHES "8")
502 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
503 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
510 SET(COMMON_OBJS common/atomic.c
515 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
519 OpenAL32/alExtension.c
521 OpenAL32/alFontsound.c
522 OpenAL32/alListener.c
525 OpenAL32/alSoundfont.c
529 OpenAL32/sample_cvt.c
531 SET(ALC_OBJS Alc/ALc.c
536 Alc/effects/autowah.c
538 Alc/effects/compressor.c
539 Alc/effects/dedicated.c
540 Alc/effects/distortion.c
542 Alc/effects/equalizer.c
543 Alc/effects/flanger.c
544 Alc/effects/modulator.c
555 SET(CPU_EXTS "Default")
559 # Check for SSE support
560 OPTION(ALSOFT_REQUIRE_SSE "Require SSE/SSE2 support" OFF)
561 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
563 OPTION(ALSOFT_CPUEXT_SSE "Enable SSE/SSE2 support" ON)
564 IF(ALSOFT_CPUEXT_SSE)
565 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
567 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
569 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
570 COMPILE_FLAGS "${SSE_SWITCH}")
572 SET(CPU_EXTS "${CPU_EXTS}, SSE")
576 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
577 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
580 # Check for ARM Neon support
581 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
582 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
584 OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
585 IF(ALSOFT_CPUEXT_NEON)
587 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
588 SET(CPU_EXTS "${CPU_EXTS}, Neon")
591 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
592 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
596 SET(ALC_OBJS ${ALC_OBJS}
600 Alc/midi/fluidsynth.c
604 SET(HAVE_FLUIDSYNTH 0)
606 # Check for FluidSynth support
607 OPTION(ALSOFT_REQUIRE_FLUIDSYNTH "Require FluidSynth MIDI" OFF)
608 FIND_PACKAGE(FluidSynth)
610 OPTION(ALSOFT_MIDI_FLUIDSYNTH "Enable FluidSynth MIDI" ON)
611 IF(ALSOFT_MIDI_FLUIDSYNTH)
612 SET(HAVE_FLUIDSYNTH 1)
613 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
614 INCLUDE_DIRECTORIES(${FLUIDSYNTH_INCLUDE_DIR})
616 SET(EXTRA_LIBS ${FLUIDSYNTH_LIBRARIES} ${EXTRA_LIBS})
619 IF(ALSOFT_REQUIRE_FLUIDSYNTH AND NOT HAVE_FLUIDSYNTH)
620 MESSAGE(FATAL_ERROR "Failed to enabled required FluidSynth support")
624 SET(ALC_OBJS ${ALC_OBJS}
626 # Default backends, always available
627 Alc/backends/loopback.c
640 SET(HAVE_PORTAUDIO 0)
641 SET(HAVE_PULSEAUDIO 0)
642 SET(HAVE_COREAUDIO 0)
645 IF(WIN32 OR HAVE_DLFCN_H)
647 MACRO(ADD_BACKEND_LIBS _LIBS)
650 SET(IS_LINKED " (linked)")
651 MACRO(ADD_BACKEND_LIBS _LIBS)
652 SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
657 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
660 OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
661 IF(ALSOFT_BACKEND_ALSA)
663 SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
664 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
665 ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
666 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
667 INCLUDE_DIRECTORIES(${ALSA_INCLUDE_DIRS})
671 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
672 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
676 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
679 OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
680 IF(ALSOFT_BACKEND_OSS)
682 SET(BACKENDS "${BACKENDS} OSS,")
683 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
684 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
685 INCLUDE_DIRECTORIES(${OSS_INCLUDE_DIRS})
689 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
690 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
693 # Check Solaris backend
694 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
695 FIND_PACKAGE(AudioIO)
697 OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
698 IF(ALSOFT_BACKEND_SOLARIS)
700 SET(BACKENDS "${BACKENDS} Solaris,")
701 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
702 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
703 INCLUDE_DIRECTORIES(${AUDIOIO_INCLUDE_DIRS})
707 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
708 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
711 # Check SndIO backend
712 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
713 FIND_PACKAGE(SoundIO)
715 OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
716 IF(ALSOFT_BACKEND_SNDIO)
718 SET(BACKENDS "${BACKENDS} SndIO (linked),")
719 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
720 SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
721 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
722 INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
726 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
727 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
731 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
734 OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
735 IF(ALSOFT_BACKEND_QSA)
737 SET(BACKENDS "${BACKENDS} QSA (linked),")
738 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
739 SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
740 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
741 INCLUDE_DIRECTORIES(${QSA_INCLUDE_DIRS})
745 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
746 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
749 # Check DSound backend
750 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
753 OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
754 IF(ALSOFT_BACKEND_DSOUND)
756 SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
757 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
758 ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
759 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
760 INCLUDE_DIRECTORIES(${DSOUND_INCLUDE_DIRS})
764 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
765 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
768 # Check for MMDevApi backend
769 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
771 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
772 IF(HAVE_MMDEVICEAPI_H)
773 OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
774 IF(ALSOFT_BACKEND_MMDEVAPI)
776 SET(BACKENDS "${BACKENDS} MMDevApi,")
777 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
781 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
782 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
785 # Check MMSystem backend
786 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
788 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
790 CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
792 OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
793 IF(ALSOFT_BACKEND_WINMM)
795 SET(BACKENDS "${BACKENDS} WinMM,")
796 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
797 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
802 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
803 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
806 # Check PortAudio backend
807 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
808 FIND_PACKAGE(PortAudio)
810 OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
811 IF(ALSOFT_BACKEND_PORTAUDIO)
812 SET(HAVE_PORTAUDIO 1)
813 SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
814 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
815 ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
816 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
817 INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
821 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
822 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
825 # Check PulseAudio backend
826 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
827 FIND_PACKAGE(PulseAudio)
829 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
830 IF(ALSOFT_BACKEND_PULSEAUDIO)
831 SET(HAVE_PULSEAUDIO 1)
832 SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
833 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
834 ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
835 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
836 INCLUDE_DIRECTORIES(${PULSEAUDIO_INCLUDE_DIRS})
840 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
841 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
844 # Check CoreAudio backend
845 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
846 FIND_LIBRARY(COREAUDIO_FRAMEWORK
848 PATHS /System/Library/Frameworks
850 IF(COREAUDIO_FRAMEWORK)
851 OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
852 IF(ALSOFT_BACKEND_COREAUDIO)
853 SET(HAVE_COREAUDIO 1)
854 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
855 SET(BACKENDS "${BACKENDS} CoreAudio,")
856 SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
857 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
858 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
860 # Some versions of OSX may need the AudioToolbox framework. Add it if
862 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
864 PATHS ~/Library/Frameworks
866 /System/Library/Frameworks
868 IF(AUDIOTOOLBOX_LIBRARY)
869 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
873 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
874 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
877 # Check for OpenSL (Android) backend
878 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
879 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
880 IF(HAVE_SLES_OPENSLES_ANDROID_H)
881 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
883 OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
884 IF(ALSOFT_BACKEND_OPENSL)
886 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
887 SET(BACKENDS "${BACKENDS} OpenSL,")
888 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
892 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
893 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
896 # Optionally enable the Wave Writer backend
897 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
898 IF(ALSOFT_BACKEND_WAVE)
900 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
901 SET(BACKENDS "${BACKENDS} WaveFile,")
904 # This is always available
905 SET(BACKENDS "${BACKENDS} Null")
907 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
908 add_subdirectory(utils/alsoft-config)
913 FIND_PACKAGE(SDL_sound)
914 IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
915 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
920 IF(LIBTYPE STREQUAL "STATIC")
921 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
922 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
925 # Needed for openal.pc.in
926 SET(prefix ${CMAKE_INSTALL_PREFIX})
927 SET(exec_prefix "\${prefix}")
928 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
929 SET(bindir "\${exec_prefix}/bin")
930 SET(includedir "\${prefix}/include")
931 SET(PACKAGE_VERSION "${LIB_VERSION}")
935 "${OpenAL_SOURCE_DIR}/config.h.in"
936 "${OpenAL_BINARY_DIR}/config.h")
938 "${OpenAL_SOURCE_DIR}/openal.pc.in"
939 "${OpenAL_BINARY_DIR}/openal.pc"
942 # Build a common library with reusable helpers
943 ADD_LIBRARY(common STATIC ${COMMON_OBJS})
946 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
947 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
948 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
949 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
951 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
953 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${FLUIDSYNTH_INCLUDE_DIR})
956 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
959 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
962 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
965 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
968 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
971 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
974 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
977 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
979 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
980 SOVERSION ${LIB_MAJOR_VERSION})
981 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
982 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
985 TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
987 # Add an install target here
988 INSTALL(TARGETS ${LIBNAME}
989 RUNTIME DESTINATION bin
990 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
991 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
993 INSTALL(FILES include/AL/al.h
997 include/AL/efx-creative.h
998 include/AL/efx-presets.h
999 DESTINATION include/AL
1001 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1002 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
1006 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1007 MESSAGE(STATUS " ${BACKENDS}")
1009 MESSAGE(STATUS "Building with support for CPU extensions:")
1010 MESSAGE(STATUS " ${CPU_EXTS}")
1013 MESSAGE(STATUS "FluidSynth support for ALC_SOFT_midi_interface enabled")
1019 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1020 MESSAGE(STATUS " This is probably NOT what you want!")
1025 # Install alsoft.conf configuration file
1027 INSTALL(FILES alsoftrc.sample
1028 DESTINATION share/openal
1030 MESSAGE(STATUS "Installing sample configuration")
1034 # Install HRTF definitions
1035 IF(ALSOFT_HRTF_DEFS)
1036 INSTALL(FILES hrtf/default-44100.mhr
1037 DESTINATION share/openal/hrtf
1039 MESSAGE(STATUS "Installing HRTF definitions")
1044 ADD_EXECUTABLE(openal-info utils/openal-info.c)
1045 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
1047 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1049 TARGET_LINK_LIBRARIES(makehrtf m)
1052 INSTALL(TARGETS openal-info makehrtf
1053 RUNTIME DESTINATION bin
1054 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1055 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1058 MESSAGE(STATUS "Building utility programs")
1059 IF(TARGET alsoft-config)
1060 MESSAGE(STATUS "Building configuration program")
1066 IF(SDL_FOUND AND SDL_SOUND_FOUND)
1067 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1068 examples/common/sdl_sound.c)
1069 SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1071 ADD_EXECUTABLE(alstream examples/alstream.c)
1072 TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1073 SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1075 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1076 TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1077 SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1079 ADD_EXECUTABLE(allatency examples/allatency.c)
1080 TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1081 SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1083 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1084 TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL_LIBRARY} ${LIBNAME})
1085 SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_INCLUDE_DIR}
1086 ${SDL_SOUND_INCLUDE_DIR})
1088 INSTALL(TARGETS alstream alreverb allatency alloopback
1089 RUNTIME DESTINATION bin
1090 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1091 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1094 MESSAGE(STATUS "Building example programs")