1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)
7 IF(COMMAND CMAKE_POLICY)
8 CMAKE_POLICY(SET CMP0003 NEW)
9 CMAKE_POLICY(SET CMP0005 NEW)
11 CMAKE_POLICY(SET CMP0020 NEW)
14 CMAKE_POLICY(SET CMP0042 NEW)
17 CMAKE_POLICY(SET CMP0054 NEW)
20 CMAKE_POLICY(SET CMP0075 NEW)
22 ENDIF(COMMAND CMAKE_POLICY)
24 IF(NOT CMAKE_BUILD_TYPE)
25 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
26 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
29 IF(NOT CMAKE_DEBUG_POSTFIX)
30 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
31 "Library postfix for debug builds. Normally left blank."
35 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
38 INCLUDE(CheckFunctionExists)
39 INCLUDE(CheckLibraryExists)
40 INCLUDE(CheckIncludeFile)
41 INCLUDE(CheckIncludeFiles)
42 INCLUDE(CheckSymbolExists)
43 INCLUDE(CheckCCompilerFlag)
44 INCLUDE(CheckCXXCompilerFlag)
45 INCLUDE(CheckCSourceCompiles)
46 INCLUDE(CheckCXXSourceCompiles)
47 INCLUDE(CheckTypeSize)
48 include(CheckStructHasMember)
49 include(GNUInstallDirs)
52 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
54 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
56 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
57 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
59 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
60 OPTION(ALSOFT_TESTS "Build and install test programs" ON)
62 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
63 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
64 OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
65 OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
67 if(DEFINED SHARE_INSTALL_DIR)
68 message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
69 set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
72 if(DEFINED LIB_SUFFIX)
73 message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
77 SET(CPP_DEFS ) # C pre-processor, not C++
84 SET(CPP_DEFS ${CPP_DEFS} _WIN32 _WIN32_WINNT=0x0502)
86 OPTION(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
88 # This option is mainly for static linking OpenAL Soft into another project
89 # that already defines the IDs. It is up to that project to ensure all
90 # required IDs are defined.
91 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
94 OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
97 SET(DLLTOOL "${HOST}-dlltool")
99 SET(DLLTOOL "dlltool")
106 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
107 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
108 SET(INC_PATHS ${INC_PATHS} /usr/include)
109 SET(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
116 SET(LIB_MAJOR_VERSION "1")
117 SET(LIB_MINOR_VERSION "20")
118 SET(LIB_REVISION "1")
119 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
120 SET(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0)
125 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
129 SET(CMAKE_CXX_STANDARD 11)
130 SET(CMAKE_CXX_STANDARD_REQUIRED TRUE)
132 # Prefer C11, but support C99 and C90 too.
133 SET(CMAKE_C_STANDARD 11)
137 # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
138 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
139 IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
140 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
141 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600")
142 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
143 IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
144 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
146 SET(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600)
149 UNSET(OLD_REQUIRED_FLAGS)
152 # C99 has restrict, but C++ does not, so we can only utilize __restrict.
154 CHECK_CXX_SOURCE_COMPILES("int *__restrict foo;
155 int main() { return 0; }" HAVE___RESTRICT)
157 SET(RESTRICT_DECL "__restrict")
160 # Some systems may need libatomic for atomic functions to work
161 SET(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
162 SET(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
163 CHECK_CXX_SOURCE_COMPILES("#include <atomic>
164 std::atomic<int> foo{0};
165 int main() { return foo.fetch_add(2); }"
167 IF(NOT HAVE_LIBATOMIC)
168 SET(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
170 SET(EXTRA_LIBS atomic ${EXTRA_LIBS})
172 UNSET(OLD_REQUIRED_LIBRARIES)
174 # Include liblog for Android logging
175 CHECK_LIBRARY_EXISTS(log __android_log_print "" HAVE_LIBLOG)
177 SET(EXTRA_LIBS log ${EXTRA_LIBS})
178 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
182 SET(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS NOMINMAX)
183 CHECK_CXX_COMPILER_FLAG(/permissive- HAVE_PERMISSIVE_SWITCH)
184 IF(HAVE_PERMISSIVE_SWITCH)
185 SET(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:/permissive->)
187 SET(C_FLAGS ${C_FLAGS} /W4 /w14640 /wd4065 /wd4268 /wd4324)
190 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
192 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
195 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
198 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
199 IF(FORCE_STATIC_VCRT)
201 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
202 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
203 IF(${flag_var} MATCHES "/MD")
204 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
209 SET(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align
211 $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>)
214 SET(C_FLAGS ${C_FLAGS} -Werror)
217 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
219 FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
220 IF(${flag_var} MATCHES "-DNDEBUG")
221 STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
225 CHECK_C_COMPILER_FLAG(-fno-math-errno HAVE_FNO_MATH_ERRNO)
226 IF(HAVE_FNO_MATH_ERRNO)
227 SET(C_FLAGS ${C_FLAGS} -fno-math-errno)
230 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
231 if(ALSOFT_STATIC_LIBGCC)
232 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
233 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
234 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBGCC_SWITCH)
235 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
236 unset(OLD_REQUIRED_LIBRARIES)
238 if(NOT HAVE_STATIC_LIBGCC_SWITCH)
239 message(FATAL_ERROR "Cannot static link libgcc")
241 set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
244 option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF)
245 if(ALSOFT_STATIC_STDCXX)
246 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
247 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
248 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBSTDCXX_SWITCH)
249 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
250 unset(OLD_REQUIRED_LIBRARIES)
252 if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH)
253 message(FATAL_ERROR "Cannot static link libstdc++")
255 set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
259 option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
260 if(ALSOFT_STATIC_WINPTHREAD)
261 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
262 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
263 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBWINPTHREAD_SWITCH)
264 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
265 unset(OLD_REQUIRED_LIBRARIES)
267 if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
268 message(FATAL_ERROR "Cannot static link libwinpthread")
270 set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
275 # Set visibility/export options if available
277 SET(EXPORT_DECL "__declspec(dllexport)")
279 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
280 # Yes GCC, really don't accept visibility modes you don't support
281 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
283 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
284 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
285 IF(HAVE_GCC_PROTECTED_VISIBILITY)
286 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
288 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
289 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
290 IF(HAVE_GCC_DEFAULT_VISIBILITY)
291 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
295 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
296 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
297 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
298 SET(C_FLAGS ${C_FLAGS} -fvisibility=hidden)
302 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
307 SET(SSE4_1_SWITCH "")
308 SET(FPU_NEON_SWITCH "")
310 CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
311 IF(HAVE_MSSE2_SWITCH)
312 SET(SSE2_SWITCH "-msse2")
314 CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
315 IF(HAVE_MSSE3_SWITCH)
316 SET(SSE3_SWITCH "-msse3")
318 CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
319 IF(HAVE_MSSE4_1_SWITCH)
320 SET(SSE4_1_SWITCH "-msse4.1")
322 CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_MFPU_NEON_SWITCH)
323 IF(HAVE_MFPU_NEON_SWITCH)
324 SET(FPU_NEON_SWITCH "-mfpu=neon")
327 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}")
328 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
329 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
330 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
331 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}")
335 IF(CMAKE_SIZEOF_VOID_P MATCHES "4")
336 IF(SSE2_SWITCH OR MSVC)
337 OPTION(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
340 IF(ALSOFT_ENABLE_SSE2_CODEGEN)
342 CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
343 IF(HAVE_MFPMATH_SSE_2)
344 SET(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
345 SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
349 CHECK_C_COMPILER_FLAG("/arch:SSE2" HAVE_ARCH_SSE2)
351 SET(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
352 SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
360 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
361 FOREACH(flag_var ${SSE_FLAGS})
362 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
365 CHECK_C_SOURCE_COMPILES("#include <emmintrin.h>
366 int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
368 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
372 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
373 int main() {return 0;}" HAVE_GCC_FORMAT)
375 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
376 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
377 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
378 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
379 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
380 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
381 IF(NOT HAVE_GUIDDEF_H)
382 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
385 # Some systems need libm for some math functions to work
387 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
389 SET(MATH_LIB ${MATH_LIB} m)
390 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
393 # Some systems need to link with -lrt for clock_gettime as used by the common
396 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
401 # Check for the dlopen API (for dynamicly loading backend libs)
403 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
404 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
406 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
407 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
411 # Check for a cpuid intrinsic
413 CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
416 unsigned int eax, ebx, ecx, edx;
417 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
418 }" HAVE_GCC_GET_CPUID)
421 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
427 }" HAVE_CPUID_INTRINSIC)
428 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
431 unsigned long idx = 0;
432 _BitScanForward64(&idx, 1);
434 }" HAVE_BITSCANFORWARD64_INTRINSIC)
435 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
438 unsigned long idx = 0;
439 _BitScanForward(&idx, 1);
441 }" HAVE_BITSCANFORWARD_INTRINSIC)
444 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
445 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
446 CHECK_SYMBOL_EXISTS(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
448 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
451 # We need pthreads outside of Windows, for semaphores. It's also used to
452 # set the priority and name of threads, when possible.
453 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
454 IF(NOT HAVE_PTHREAD_H)
455 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
458 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
460 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
461 SET(C_FLAGS ${C_FLAGS} -pthread)
462 SET(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
465 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
467 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
470 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
472 # Some systems need pthread_np.h to get pthread_setname_np
473 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
474 IF(HAVE_PTHREAD_NP_H)
475 CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
476 IF(NOT HAVE_PTHREAD_SETNAME_NP)
477 CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
479 CHECK_C_SOURCE_COMPILES("
481 #include <pthread_np.h>
484 pthread_setname_np(\"testname\");
487 PTHREAD_SETNAME_NP_ONE_PARAM
489 CHECK_C_SOURCE_COMPILES("
491 #include <pthread_np.h>
494 pthread_setname_np(pthread_self(), \"%s\", \"testname\");
497 PTHREAD_SETNAME_NP_THREE_PARAMS
501 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
502 IF(NOT HAVE_PTHREAD_SETNAME_NP)
503 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
505 CHECK_C_SOURCE_COMPILES("
509 pthread_setname_np(\"testname\");
512 PTHREAD_SETNAME_NP_ONE_PARAM
514 CHECK_C_SOURCE_COMPILES("
518 pthread_setname_np(pthread_self(), \"%s\", \"testname\");
521 PTHREAD_SETNAME_NP_THREE_PARAMS
527 CHECK_SYMBOL_EXISTS(getopt unistd.h HAVE_GETOPT)
530 # Common sources used by both the OpenAL implementation library and potentially
551 common/intrusive_ptr.h
554 common/polyphase_resampler.cpp
555 common/polyphase_resampler.h
604 alc/effects/autowah.cpp
605 alc/effects/chorus.cpp
606 alc/effects/compressor.cpp
607 alc/effects/dedicated.cpp
608 alc/effects/distortion.cpp
610 alc/effects/equalizer.cpp
611 alc/effects/fshifter.cpp
612 alc/effects/modulator.cpp
614 alc/effects/pshifter.cpp
615 alc/effects/reverb.cpp
616 alc/effects/vmorpher.cpp
618 alc/filters/biquad.cpp
621 alc/filters/splitter.cpp
622 alc/filters/splitter.h
641 alc/mixer/mixer_c.cpp
645 SET(CPU_EXTS "Default")
652 # Check for SSE+SSE2 support
653 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
654 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
655 IF(HAVE_XMMINTRIN_H AND HAVE_EMMINTRIN_H)
656 OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
657 OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
658 IF(ALSOFT_CPUEXT_SSE AND ALSOFT_CPUEXT_SSE2)
661 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp)
663 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp
664 PROPERTIES COMPILE_FLAGS "${SSE2_SWITCH}")
666 SET(CPU_EXTS "${CPU_EXTS}, SSE, SSE2")
669 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
670 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
672 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
673 MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
676 OPTION(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF)
678 OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
679 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
681 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse3.cpp)
683 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse3.cpp PROPERTIES
684 COMPILE_FLAGS "${SSE3_SWITCH}")
686 SET(CPU_EXTS "${CPU_EXTS}, SSE3")
689 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
690 MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
693 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
695 OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
696 IF(HAVE_SSE3 AND ALSOFT_CPUEXT_SSE4_1)
698 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse41.cpp)
700 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse41.cpp PROPERTIES
701 COMPILE_FLAGS "${SSE4_1_SWITCH}")
703 SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
706 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
707 MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
710 # Check for ARM Neon support
711 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
713 OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
714 IF(ALSOFT_CPUEXT_NEON)
716 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_neon.cpp)
718 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_neon.cpp PROPERTIES
719 COMPILE_FLAGS "${FPU_NEON_SWITCH}")
721 SET(CPU_EXTS "${CPU_EXTS}, Neon")
724 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
725 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
737 SET(HAVE_PORTAUDIO 0)
738 SET(HAVE_PULSEAUDIO 0)
739 SET(HAVE_COREAUDIO 0)
744 IF(WIN32 OR HAVE_DLFCN_H)
746 MACRO(ADD_BACKEND_LIBS _LIBS)
749 SET(IS_LINKED " (linked)")
750 MACRO(ADD_BACKEND_LIBS _LIBS)
751 SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
756 SET(ALC_OBJS ${ALC_OBJS}
757 alc/backends/base.cpp
759 # Default backends, always available
760 alc/backends/loopback.cpp
761 alc/backends/loopback.h
762 alc/backends/null.cpp
767 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
770 OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
771 IF(ALSOFT_BACKEND_ALSA)
773 SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
774 SET(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h)
775 ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
776 SET(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
779 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
780 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
784 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
787 OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
788 IF(ALSOFT_BACKEND_OSS)
790 SET(BACKENDS "${BACKENDS} OSS,")
791 SET(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h)
793 SET(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
795 SET(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
798 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
799 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
802 # Check Solaris backend
803 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
804 FIND_PACKAGE(AudioIO)
806 OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
807 IF(ALSOFT_BACKEND_SOLARIS)
809 SET(BACKENDS "${BACKENDS} Solaris,")
810 SET(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h)
811 SET(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
814 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
815 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
818 # Check SndIO backend
819 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
820 FIND_PACKAGE(SoundIO)
822 OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
823 IF(ALSOFT_BACKEND_SNDIO)
825 SET(BACKENDS "${BACKENDS} SndIO (linked),")
826 SET(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h)
827 SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
828 SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
831 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
832 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
836 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
839 OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
840 IF(ALSOFT_BACKEND_QSA)
842 SET(BACKENDS "${BACKENDS} QSA (linked),")
843 SET(ALC_OBJS ${ALC_OBJS} alc/backends/qsa.cpp alc/backends/qsa.h)
844 SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
845 SET(INC_PATHS ${INC_PATHS} ${QSA_INCLUDE_DIRS})
848 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
849 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
852 # Check Windows-only backends
853 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
854 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
855 OPTION(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
857 SET(WINSDK_LIB_DIRS )
858 SET(WINSDK_INCLUDE_DIRS )
859 FIND_PACKAGE(WindowsSDK)
861 get_windowssdk_library_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_LIB_DIRS)
862 get_windowssdk_include_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_INCLUDE_DIRS)
865 SET(OLD_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
866 SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0502)
868 # Check MMSystem backend
869 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
870 FIND_LIBRARY(WINMM_LIBRARY NAMES winmm
871 PATHS ${WINSDK_LIB_DIRS}
872 PATH_SUFFIXES lib lib/x86 lib/x64)
873 IF(HAVE_MMSYSTEM_H AND WINMM_LIBRARY)
874 OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
875 IF(ALSOFT_BACKEND_WINMM)
877 SET(BACKENDS "${BACKENDS} WinMM,")
878 SET(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h)
879 SET(EXTRA_LIBS ${WINMM_LIBRARY} ${EXTRA_LIBS})
883 # Check DSound backend
886 OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
887 IF(ALSOFT_BACKEND_DSOUND)
889 SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
890 SET(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h)
891 ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
892 SET(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIRS})
896 # Check for WASAPI backend
897 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
898 IF(HAVE_MMDEVICEAPI_H)
899 OPTION(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
900 IF(ALSOFT_BACKEND_WASAPI)
902 SET(BACKENDS "${BACKENDS} WASAPI,")
903 SET(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h)
907 SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_REQUIRED_DEFINITIONS})
908 UNSET(OLD_REQUIRED_DEFINITIONS)
910 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
911 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
913 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
914 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
916 IF(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
917 MESSAGE(FATAL_ERROR "Failed to enabled required WASAPI backend")
920 # Check PortAudio backend
921 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
922 FIND_PACKAGE(PortAudio)
924 OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
925 IF(ALSOFT_BACKEND_PORTAUDIO)
926 SET(HAVE_PORTAUDIO 1)
927 SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
928 SET(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.h)
929 ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
930 SET(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS})
933 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
934 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
937 # Check PulseAudio backend
938 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
939 FIND_PACKAGE(PulseAudio)
941 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
942 IF(ALSOFT_BACKEND_PULSEAUDIO)
943 SET(HAVE_PULSEAUDIO 1)
944 SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
945 SET(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h)
946 ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
947 SET(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIRS})
950 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
951 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
955 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
958 OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
959 IF(ALSOFT_BACKEND_JACK)
961 SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
962 SET(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h)
963 ADD_BACKEND_LIBS(${JACK_LIBRARIES})
964 SET(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS})
967 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
968 MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
971 # Check CoreAudio backend
972 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
973 FIND_LIBRARY(COREAUDIO_FRAMEWORK NAMES CoreAudio)
974 FIND_PATH(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h)
975 IF(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR)
976 OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
977 IF(ALSOFT_BACKEND_COREAUDIO)
978 SET(HAVE_COREAUDIO 1)
979 SET(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h)
980 SET(BACKENDS "${BACKENDS} CoreAudio,")
981 SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} /System/Library/Frameworks/AudioUnit.framework
982 /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
984 # Some versions of OSX may need the AudioToolbox framework. Add it if
986 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox)
987 IF(AUDIOTOOLBOX_LIBRARY)
988 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
991 SET(INC_PATHS ${INC_PATHS} ${AUDIOUNIT_INCLUDE_DIR})
994 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
995 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
998 # Check for OpenSL (Android) backend
999 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1000 FIND_PACKAGE(OpenSL)
1002 OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1003 IF(ALSOFT_BACKEND_OPENSL)
1005 SET(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h)
1006 SET(BACKENDS "${BACKENDS} OpenSL,")
1007 SET(EXTRA_LIBS ${OPENSL_LIBRARIES} ${EXTRA_LIBS})
1008 SET(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS})
1011 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1012 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1015 # Check for SDL2 backend
1016 OPTION(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF)
1019 # Off by default, since it adds a runtime dependency
1020 OPTION(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF)
1021 IF(ALSOFT_BACKEND_SDL2)
1023 SET(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h)
1024 SET(BACKENDS "${BACKENDS} SDL2,")
1025 SET(EXTRA_LIBS ${SDL2_LIBRARY} ${EXTRA_LIBS})
1026 SET(INC_PATHS ${INC_PATHS} ${SDL2_INCLUDE_DIR})
1029 IF(ALSOFT_REQUIRE_SDL2 AND NOT SDL2_FOUND)
1030 MESSAGE(FATAL_ERROR "Failed to enabled required SDL2 backend")
1033 # Optionally enable the Wave Writer backend
1034 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1035 IF(ALSOFT_BACKEND_WAVE)
1037 SET(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h)
1038 SET(BACKENDS "${BACKENDS} WaveFile,")
1041 # This is always available
1042 SET(BACKENDS "${BACKENDS} Null")
1046 IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
1047 # Get the current working branch and its latest abbreviated commit hash
1048 ADD_CUSTOM_TARGET(build_version
1049 ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D LIB_VERSION=${LIB_VERSION}
1050 -D LIB_VERSION_NUM=${LIB_VERSION_NUM} -D SRC=${OpenAL_SOURCE_DIR}/version.h.in
1051 -D DST=${OpenAL_BINARY_DIR}/version.h -P ${OpenAL_SOURCE_DIR}/version.cmake
1052 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1056 SET(GIT_BRANCH "UNKNOWN")
1057 SET(GIT_COMMIT_HASH "unknown")
1059 "${OpenAL_SOURCE_DIR}/version.h.in"
1060 "${OpenAL_BINARY_DIR}/version.h")
1064 SET(NATIVE_SRC_DIR "${OpenAL_SOURCE_DIR}/native-tools")
1066 SET(ALSOFT_NATIVE_TOOLS_PATH "" CACHE STRING "Path to prebuilt native tools (leave blank to auto-build)")
1067 IF(ALSOFT_NATIVE_TOOLS_PATH)
1068 find_program(BIN2H_NATIVE_COMMAND NAMES bin2h
1069 PATHS "${ALSOFT_NATIVE_TOOLS_PATH}"
1071 find_program(BSINCGEN_NATIVE_COMMAND NAMES bsincgen
1072 PATHS "${ALSOFT_NATIVE_TOOLS_PATH}"
1074 if(NOT BIN2H_NATIVE_COMMAND OR NOT BSINCGEN_NATIVE_COMMAND)
1075 message(FATAL_ERROR "Failed to find native tools in ${ALSOFT_NATIVE_TOOLS_PATH}.
1076 bin2h: ${BIN2H_NATIVE_COMMAND}
1077 bsincgen: ${BSINCGEN_NATIVE_COMMAND}")
1079 SET(BIN2H_COMMAND ${BIN2H_NATIVE_COMMAND})
1080 SET(BSINCGEN_COMMAND ${BSINCGEN_NATIVE_COMMAND})
1082 SET(NATIVE_BIN_DIR "${OpenAL_BINARY_DIR}/native-tools")
1083 FILE(MAKE_DIRECTORY "${NATIVE_BIN_DIR}")
1085 SET(BIN2H_COMMAND "${NATIVE_BIN_DIR}/bin2h")
1086 SET(BSINCGEN_COMMAND "${NATIVE_BIN_DIR}/bsincgen")
1087 ADD_CUSTOM_COMMAND(OUTPUT "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
1088 COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "${NATIVE_SRC_DIR}"
1089 COMMAND ${CMAKE_COMMAND} -E remove "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
1090 COMMAND ${CMAKE_COMMAND} --build . --config "Release"
1091 WORKING_DIRECTORY "${NATIVE_BIN_DIR}"
1092 DEPENDS "${NATIVE_SRC_DIR}/CMakeLists.txt"
1094 C "${NATIVE_SRC_DIR}/bin2h.c"
1095 C "${NATIVE_SRC_DIR}/bsincgen.c"
1099 ADD_CUSTOM_TARGET(native-tools
1100 DEPENDS "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
1104 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON)
1105 if(ALSOFT_EMBED_HRTF_DATA)
1106 MACRO(make_hrtf_header FILENAME VARNAME)
1107 SET(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}")
1108 SET(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.h")
1110 ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
1111 COMMAND "${BIN2H_COMMAND}" "${infile}" "${outfile}" ${VARNAME}
1112 DEPENDS native-tools "${infile}"
1115 SET(ALC_OBJS ${ALC_OBJS} "${outfile}")
1118 make_hrtf_header("Default HRTF.mhr" "hrtf_default")
1121 ADD_CUSTOM_COMMAND(OUTPUT "${OpenAL_BINARY_DIR}/bsinc_inc.h"
1122 COMMAND "${BSINCGEN_COMMAND}" "${OpenAL_BINARY_DIR}/bsinc_inc.h"
1123 DEPENDS native-tools "${NATIVE_SRC_DIR}/bsincgen.c"
1126 SET(ALC_OBJS ${ALC_OBJS} "${OpenAL_BINARY_DIR}/bsinc_inc.h")
1129 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1130 add_subdirectory(utils/alsoft-config)
1137 FIND_PACKAGE(SDL_sound)
1138 FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1143 SET(LIBNAME "openal")
1145 SET(LIBNAME "OpenAL32")
1148 # Needed for openal.pc.in
1149 SET(prefix ${CMAKE_INSTALL_PREFIX})
1150 SET(exec_prefix "\${prefix}")
1151 SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
1152 SET(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}")
1153 SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
1154 SET(PACKAGE_VERSION "${LIB_VERSION}")
1155 SET(PKG_CONFIG_CFLAGS )
1156 SET(PKG_CONFIG_PRIVATE_LIBS )
1157 IF(LIBTYPE STREQUAL "STATIC")
1158 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC)
1159 FOREACH(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1160 # If this is already a linker flag, or is a full path+file, add it
1161 # as-is. Otherwise, it's a name intended to be dressed as -lname.
1162 IF(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}")
1163 SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}")
1165 SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}")
1172 "${OpenAL_SOURCE_DIR}/config.h.in"
1173 "${OpenAL_BINARY_DIR}/config.h")
1175 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1176 "${OpenAL_BINARY_DIR}/openal.pc"
1180 ADD_LIBRARY(common STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS})
1181 TARGET_INCLUDE_DIRECTORIES(common PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/include)
1182 TARGET_COMPILE_DEFINITIONS(common PRIVATE ${CPP_DEFS})
1183 TARGET_COMPILE_OPTIONS(common PRIVATE ${C_FLAGS})
1184 SET_TARGET_PROPERTIES(common PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
1188 SET(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal.
1191 # Build main library
1192 IF(LIBTYPE STREQUAL "STATIC")
1193 SET(CPP_DEFS ${CPP_DEFS} AL_LIBTYPE_STATIC)
1194 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1195 SET(CPP_DEFS ${CPP_DEFS} AL_NO_UID_DEFS)
1197 ADD_LIBRARY(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1198 TARGET_LINK_LIBRARIES(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1202 SET(SUBSYS_FLAG ${SUBSYS_FLAG} "/SUBSYSTEM:WINDOWS")
1203 ELSEIF(CMAKE_COMPILER_IS_GNUCC)
1204 SET(SUBSYS_FLAG ${SUBSYS_FLAG} "-mwindows")
1208 SET(RC_CONFIG resources/openal32.rc)
1209 IF(WIN32 AND ALSOFT_BUILD_ROUTER)
1210 ADD_LIBRARY(OpenAL SHARED
1217 TARGET_COMPILE_DEFINITIONS(OpenAL
1218 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
1219 TARGET_COMPILE_OPTIONS(OpenAL PRIVATE ${C_FLAGS})
1220 TARGET_LINK_LIBRARIES(OpenAL PRIVATE common ${LINKER_FLAGS})
1221 TARGET_INCLUDE_DIRECTORIES(OpenAL
1223 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1224 $<INSTALL_INTERFACE:include>
1226 ${OpenAL_SOURCE_DIR}/common
1227 ${OpenAL_BINARY_DIR}
1229 SET_TARGET_PROPERTIES(OpenAL PROPERTIES PREFIX "")
1230 SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME ${LIBNAME})
1231 IF(TARGET build_version)
1232 ADD_DEPENDENCIES(OpenAL build_version)
1236 SET(LIBNAME "soft_oal")
1237 SET(IMPL_TARGET soft_oal)
1238 SET(RC_CONFIG resources/soft_oal.rc)
1241 ADD_LIBRARY(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${RC_CONFIG})
1243 SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES PREFIX "")
1245 TARGET_LINK_LIBRARIES(${IMPL_TARGET} PRIVATE common ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1248 TARGET_INCLUDE_DIRECTORIES(${IMPL_TARGET}
1250 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1251 $<INSTALL_INTERFACE:include>
1254 ${OpenAL_BINARY_DIR}
1255 ${OpenAL_SOURCE_DIR}
1256 ${OpenAL_SOURCE_DIR}/alc
1257 ${OpenAL_SOURCE_DIR}/common
1260 SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES OUTPUT_NAME ${LIBNAME}
1261 VERSION ${LIB_VERSION}
1262 SOVERSION ${LIB_MAJOR_VERSION}
1264 TARGET_COMPILE_DEFINITIONS(${IMPL_TARGET}
1265 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
1266 TARGET_COMPILE_OPTIONS(${IMPL_TARGET} PRIVATE ${C_FLAGS})
1268 IF(TARGET build_version)
1269 ADD_DEPENDENCIES(${IMPL_TARGET} build_version)
1272 IF(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
1273 FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1274 FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1275 IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1277 IF(NOT SED_EXECUTABLE)
1278 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1280 IF(NOT DLLTOOL_EXECUTABLE)
1281 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1284 SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY
1285 LINK_FLAGS " -Wl,--output-def,OpenAL32.def")
1286 ADD_CUSTOM_COMMAND(TARGET OpenAL POST_BUILD
1287 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
1288 COMMAND "${DLLTOOL_EXECUTABLE}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
1289 COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
1296 INSTALL(TARGETS OpenAL EXPORT OpenAL
1297 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1298 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1299 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1300 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL)
1301 EXPORT(TARGETS OpenAL
1303 FILE OpenALConfig.cmake)
1304 INSTALL(EXPORT OpenAL
1305 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
1307 FILE OpenALConfig.cmake)
1313 include/AL/efx-creative.h
1314 include/AL/efx-presets.h
1315 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/AL)
1316 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1317 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1319 INSTALL(TARGETS soft_oal
1320 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1327 message(STATUS "Building DLL router")
1331 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1332 MESSAGE(STATUS " ${BACKENDS}")
1334 MESSAGE(STATUS "Building with support for CPU extensions:")
1335 MESSAGE(STATUS " ${CPU_EXTS}")
1338 MESSAGE(STATUS "Building with SSE${FPMATH_SET} codegen")
1342 if(ALSOFT_EMBED_HRTF_DATA)
1343 message(STATUS "Embedding HRTF datasets")
1347 # Install alsoft.conf configuration file
1349 INSTALL(FILES alsoftrc.sample
1350 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1351 MESSAGE(STATUS "Installing sample configuration")
1355 # Install HRTF definitions
1356 IF(ALSOFT_HRTF_DEFS)
1357 INSTALL(FILES "hrtf/Default HRTF.mhr"
1358 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/hrtf)
1359 MESSAGE(STATUS "Installing HRTF definitions")
1363 # Install AmbDec presets
1364 IF(ALSOFT_AMBDEC_PRESETS)
1366 presets/3D7.1.ambdec
1367 presets/hexagon.ambdec
1368 presets/itu5.1.ambdec
1369 presets/itu5.1-nocenter.ambdec
1370 presets/rectangle.ambdec
1371 presets/square.ambdec
1373 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/presets)
1374 MESSAGE(STATUS "Installing AmbDec presets")
1381 ADD_EXECUTABLE(openal-info utils/openal-info.c)
1382 TARGET_INCLUDE_DIRECTORIES(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
1383 TARGET_COMPILE_OPTIONS(openal-info PRIVATE ${C_FLAGS})
1384 TARGET_LINK_LIBRARIES(openal-info PRIVATE ${LINKER_FLAGS} OpenAL)
1385 set(UTIL_TARGETS ${UTIL_TARGETS} openal-info)
1387 find_package(MySOFA)
1389 set(SOFA_SUPPORT_SRCS
1390 utils/sofa-support.cpp
1391 utils/sofa-support.h)
1392 add_library(sofa-support STATIC EXCLUDE_FROM_ALL ${SOFA_SUPPORT_SRCS})
1393 target_compile_definitions(sofa-support PRIVATE ${CPP_DEFS})
1394 target_include_directories(sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/common)
1395 target_compile_options(sofa-support PRIVATE ${C_FLAGS})
1396 target_link_libraries(sofa-support PUBLIC common MySOFA::MySOFA PRIVATE ${LINKER_FLAGS})
1399 utils/makemhr/loaddef.cpp
1400 utils/makemhr/loaddef.h
1401 utils/makemhr/loadsofa.cpp
1402 utils/makemhr/loadsofa.h
1403 utils/makemhr/makemhr.cpp
1404 utils/makemhr/makemhr.h)
1406 set(MAKEMHR_SRCS ${MAKEMHR_SRCS} utils/getopt.c utils/getopt.h)
1408 add_executable(makemhr ${MAKEMHR_SRCS})
1409 target_compile_definitions(makemhr PRIVATE ${CPP_DEFS})
1410 target_include_directories(makemhr
1411 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils)
1412 target_compile_options(makemhr PRIVATE ${C_FLAGS})
1413 target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} sofa-support)
1414 set(UTIL_TARGETS ${UTIL_TARGETS} makemhr)
1416 set(SOFAINFO_SRCS utils/sofa-info.cpp)
1417 add_executable(sofa-info ${SOFAINFO_SRCS})
1418 target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS})
1419 target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/utils)
1420 target_compile_options(sofa-info PRIVATE ${C_FLAGS})
1421 target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} sofa-support)
1425 INSTALL(TARGETS ${UTIL_TARGETS}
1426 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1427 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1428 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
1431 MESSAGE(STATUS "Building utility programs")
1432 IF(TARGET alsoft-config)
1433 MESSAGE(STATUS "Building configuration program")
1439 # Add a static library with common functions used by multiple example targets
1440 ADD_LIBRARY(ex-common STATIC EXCLUDE_FROM_ALL
1441 examples/common/alhelpers.c
1442 examples/common/alhelpers.h)
1443 TARGET_COMPILE_DEFINITIONS(ex-common PUBLIC ${CPP_DEFS})
1444 TARGET_INCLUDE_DIRECTORIES(ex-common PUBLIC ${OpenAL_SOURCE_DIR}/common)
1445 TARGET_COMPILE_OPTIONS(ex-common PUBLIC ${C_FLAGS})
1446 TARGET_LINK_LIBRARIES(ex-common PUBLIC OpenAL PRIVATE ${RT_LIB})
1449 ADD_EXECUTABLE(altonegen examples/altonegen.c)
1450 TARGET_COMPILE_DEFINITIONS(altonegen PRIVATE ${CPP_DEFS})
1451 TARGET_INCLUDE_DIRECTORIES(altonegen PRIVATE ${OpenAL_SOURCE_DIR}/common)
1452 TARGET_COMPILE_OPTIONS(altonegen PRIVATE ${C_FLAGS})
1453 TARGET_LINK_LIBRARIES(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} ex-common)
1456 INSTALL(TARGETS altonegen
1457 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1458 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1459 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
1462 MESSAGE(STATUS "Building test programs")
1467 ADD_EXECUTABLE(alrecord examples/alrecord.c)
1468 TARGET_LINK_LIBRARIES(alrecord PRIVATE ${LINKER_FLAGS} ex-common)
1471 INSTALL(TARGETS alrecord
1472 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1473 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1474 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
1477 MESSAGE(STATUS "Building example programs")
1481 ADD_EXECUTABLE(alplay examples/alplay.c)
1482 TARGET_INCLUDE_DIRECTORIES(alplay
1483 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1484 TARGET_LINK_LIBRARIES(alplay
1485 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1487 ADD_EXECUTABLE(alstream examples/alstream.c)
1488 TARGET_INCLUDE_DIRECTORIES(alstream
1489 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1490 TARGET_LINK_LIBRARIES(alstream
1491 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1493 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1494 TARGET_INCLUDE_DIRECTORIES(alreverb
1495 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1496 TARGET_LINK_LIBRARIES(alreverb
1497 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1499 ADD_EXECUTABLE(almultireverb examples/almultireverb.c)
1500 TARGET_INCLUDE_DIRECTORIES(almultireverb
1501 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1502 TARGET_LINK_LIBRARIES(almultireverb
1503 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common
1506 ADD_EXECUTABLE(allatency examples/allatency.c)
1507 TARGET_INCLUDE_DIRECTORIES(allatency
1508 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1509 TARGET_LINK_LIBRARIES(allatency
1510 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1512 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1513 TARGET_INCLUDE_DIRECTORIES(alloopback
1514 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1515 TARGET_LINK_LIBRARIES(alloopback
1516 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB})
1518 ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1519 TARGET_INCLUDE_DIRECTORIES(alhrtf
1520 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1521 TARGET_LINK_LIBRARIES(alhrtf
1522 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB})
1525 INSTALL(TARGETS alplay alstream alreverb almultireverb allatency alloopback alhrtf
1526 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1527 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1528 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
1531 MESSAGE(STATUS "Building SDL_sound example programs")
1537 IF(AVFORMAT_VERSION VERSION_LESS "57.56.101")
1538 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 57.56.101)")
1541 IF(AVCODEC_VERSION VERSION_LESS "57.64.101")
1542 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 57.64.101)")
1545 IF(AVUTIL_VERSION VERSION_LESS "55.34.101")
1546 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 55.34.101)")
1549 IF(SWSCALE_VERSION VERSION_LESS "4.2.100")
1550 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 4.2.100)")
1553 IF(SWRESAMPLE_VERSION VERSION_LESS "2.3.100")
1554 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 2.3.100)")
1559 ADD_EXECUTABLE(alffplay examples/alffplay.cpp)
1560 TARGET_INCLUDE_DIRECTORIES(alffplay
1561 PRIVATE ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
1562 TARGET_LINK_LIBRARIES(alffplay
1563 PRIVATE ${LINKER_FLAGS} ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} ex-common)
1566 INSTALL(TARGETS alffplay
1567 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1568 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1569 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
1571 MESSAGE(STATUS "Building SDL+FFmpeg example programs")