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 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
26 INCLUDE(CheckFunctionExists)
27 INCLUDE(CheckLibraryExists)
28 INCLUDE(CheckIncludeFile)
29 INCLUDE(CheckIncludeFiles)
30 INCLUDE(CheckSymbolExists)
31 INCLUDE(CheckCCompilerFlag)
32 INCLUDE(CheckCXXCompilerFlag)
33 INCLUDE(CheckCSourceCompiles)
34 INCLUDE(CheckCXXSourceCompiles)
35 INCLUDE(CheckTypeSize)
36 include(CheckStructHasMember)
37 include(CheckFileOffsetBits)
38 include(GNUInstallDirs)
40 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
43 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
45 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
47 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
48 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
50 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
51 OPTION(ALSOFT_TESTS "Build and install test programs" ON)
53 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
54 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
55 OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
56 OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
58 if(DEFINED SHARE_INSTALL_DIR)
59 message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
60 set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
63 if(DEFINED LIB_SUFFIX)
64 message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
68 SET(CPP_DEFS ) # C pre-process, not C++
75 SET(CPP_DEFS ${CPP_DEFS} _WIN32 _WIN32_WINNT=0x0502)
77 OPTION(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
79 # This option is mainly for static linking OpenAL Soft into another project
80 # that already defines the IDs. It is up to that project to ensure all
81 # required IDs are defined.
82 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
85 OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
88 SET(DLLTOOL "${HOST}-dlltool")
90 SET(DLLTOOL "dlltool")
97 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
98 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
99 SET(INC_PATHS ${INC_PATHS} /usr/include)
100 SET(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
107 SET(LIB_MAJOR_VERSION "1")
108 SET(LIB_MINOR_VERSION "19")
109 SET(LIB_REVISION "1")
110 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
111 SET(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0)
116 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
117 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
121 SET(CMAKE_CXX_STANDARD 11)
122 SET(CMAKE_CXX_STANDARD_REQUIRED TRUE)
124 # Prefer C11, but support C99 and C90 too.
125 SET(CMAKE_C_STANDARD 11)
129 # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
130 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
131 IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
132 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
133 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600")
134 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
135 IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
136 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
138 SET(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600)
141 UNSET(OLD_REQUIRED_FLAGS)
144 # Set defines for large file support. Don't set this for Android targets. See:
145 # https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
147 CHECK_FILE_OFFSET_BITS()
148 IF(_FILE_OFFSET_BITS)
149 SET(CPP_DEFS ${CPP_DEFS} "_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
150 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
152 SET(CPP_DEFS ${CPP_DEFS} _LARGEFILE_SOURCE _LARGE_FILES)
153 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
156 # C99 has restrict, but C++ does not, so we can only utilize __restrict.
158 CHECK_C_SOURCE_COMPILES("int *__restrict foo;
159 int main() {return 0;}" HAVE___RESTRICT)
161 SET(RESTRICT_DECL "__restrict")
164 # Some systems may need libatomic for C11 atomic functions to work
165 SET(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
166 SET(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
167 CHECK_C_SOURCE_COMPILES("#include <stdatomic.h>
168 int _Atomic foo = ATOMIC_VAR_INIT(0);
171 return atomic_fetch_add(&foo, 2);
174 IF(NOT HAVE_LIBATOMIC)
175 SET(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
177 SET(EXTRA_LIBS atomic ${EXTRA_LIBS})
179 UNSET(OLD_REQUIRED_LIBRARIES)
181 # Include liblog for Android logging
182 CHECK_LIBRARY_EXISTS(log __android_log_print "" HAVE_LIBLOG)
184 SET(EXTRA_LIBS log ${EXTRA_LIBS})
185 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
188 IF(NOT CMAKE_BUILD_TYPE)
189 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
190 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
193 IF(NOT CMAKE_DEBUG_POSTFIX)
194 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
195 "Library postfix for debug builds. Normally left blank."
200 SET(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS NOMINMAX)
201 SET(C_FLAGS ${C_FLAGS} /wd4065 /wd4200)
204 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
206 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
209 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
212 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
213 IF(FORCE_STATIC_VCRT)
215 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
216 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
217 IF(${flag_var} MATCHES "/MD")
218 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
223 SET(C_FLAGS ${C_FLAGS} -Winline -Wall $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>)
224 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
226 SET(C_FLAGS ${C_FLAGS} -Wextra)
230 SET(C_FLAGS ${C_FLAGS} -Werror)
233 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
235 FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
236 IF(${flag_var} MATCHES "-DNDEBUG")
237 STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
241 CHECK_C_COMPILER_FLAG(-fno-math-errno HAVE_FNO_MATH_ERRNO)
242 IF(HAVE_FNO_MATH_ERRNO)
243 SET(C_FLAGS ${C_FLAGS} -fno-math-errno)
246 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
247 if(ALSOFT_STATIC_LIBGCC)
248 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
249 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
250 check_c_source_compiles(
256 HAVE_STATIC_LIBGCC_SWITCH
258 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
259 unset(OLD_REQUIRED_LIBRARIES)
261 if(NOT HAVE_STATIC_LIBGCC_SWITCH)
262 message(FATAL_ERROR "Cannot static link libgcc")
264 set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
267 option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF)
268 if(ALSOFT_STATIC_STDCXX)
269 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
270 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
271 check_cxx_source_compiles(
277 HAVE_STATIC_LIBSTDCXX_SWITCH
279 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
280 unset(OLD_REQUIRED_LIBRARIES)
282 if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH)
283 message(FATAL_ERROR "Cannot static link libstdc++")
285 set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
289 option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
290 if(ALSOFT_STATIC_WINPTHREAD)
291 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
292 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
293 check_cxx_source_compiles(
299 HAVE_STATIC_LIBWINPTHREAD_SWITCH
301 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
302 unset(OLD_REQUIRED_LIBRARIES)
304 if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
305 message(FATAL_ERROR "Cannot static link libwinpthread")
307 set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
312 # Set visibility/export options if available
314 SET(EXPORT_DECL "__declspec(dllexport)")
316 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
317 # Yes GCC, really don't accept visibility modes you don't support
318 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
320 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
321 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
322 IF(HAVE_GCC_PROTECTED_VISIBILITY)
323 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
325 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
326 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
327 IF(HAVE_GCC_DEFAULT_VISIBILITY)
328 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
332 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
333 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
334 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
335 SET(C_FLAGS ${C_FLAGS} -fvisibility=hidden)
339 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
344 SET(SSE4_1_SWITCH "")
345 SET(FPU_NEON_SWITCH "")
347 CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
348 IF(HAVE_MSSE2_SWITCH)
349 SET(SSE2_SWITCH "-msse2")
351 CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
352 IF(HAVE_MSSE3_SWITCH)
353 SET(SSE3_SWITCH "-msse3")
355 CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
356 IF(HAVE_MSSE4_1_SWITCH)
357 SET(SSE4_1_SWITCH "-msse4.1")
359 CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_MFPU_NEON_SWITCH)
360 IF(HAVE_MFPU_NEON_SWITCH)
361 SET(FPU_NEON_SWITCH "-mfpu=neon")
364 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}")
365 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
366 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
367 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
368 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}")
372 IF(CMAKE_SIZEOF_VOID_P MATCHES "4")
373 IF(SSE2_SWITCH OR MSVC)
374 OPTION(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
377 IF(ALSOFT_ENABLE_SSE2_CODEGEN)
379 CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
380 IF(HAVE_MFPMATH_SSE_2)
381 SET(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
382 SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
386 CHECK_C_COMPILER_FLAG("/arch:SSE2" HAVE_ARCH_SSE2)
388 SET(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
389 SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
397 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
398 FOREACH(flag_var ${SSE_FLAGS})
399 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
402 CHECK_C_SOURCE_COMPILES("#include <emmintrin.h>
403 int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
405 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
409 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
410 int main() {return 0;}" HAVE_GCC_FORMAT)
412 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
413 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
414 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
415 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
416 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
417 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
418 IF(NOT HAVE_GUIDDEF_H)
419 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
422 # Some systems need libm for some math functions to work
424 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
426 SET(MATH_LIB ${MATH_LIB} m)
427 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
430 # Check for the dlopen API (for dynamicly loading backend libs)
432 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
434 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
435 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
438 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
441 # Check for a cpuid intrinsic
443 CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
446 unsigned int eax, ebx, ecx, edx;
447 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
448 }" HAVE_GCC_GET_CPUID)
451 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
457 }" HAVE_CPUID_INTRINSIC)
458 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
461 unsigned long idx = 0;
462 _BitScanForward64(&idx, 1);
464 }" HAVE_BITSCANFORWARD64_INTRINSIC)
465 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
468 unsigned long idx = 0;
469 _BitScanForward(&idx, 1);
471 }" HAVE_BITSCANFORWARD_INTRINSIC)
474 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
475 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
476 CHECK_SYMBOL_EXISTS(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
478 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
479 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
480 IF(NOT HAVE_STRCASECMP)
481 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
482 IF(NOT HAVE__STRICMP)
483 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
486 SET(CPP_DEFS ${CPP_DEFS} strcasecmp=_stricmp)
489 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
490 IF(NOT HAVE_STRNCASECMP)
491 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
492 IF(NOT HAVE__STRNICMP)
493 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
496 SET(CPP_DEFS ${CPP_DEFS} strncasecmp=_strnicmp)
501 # We need pthreads outside of Windows, for semaphores. It's also used to
502 # set the priority and name of threads, when possible.
503 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
504 IF(NOT HAVE_PTHREAD_H)
505 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
508 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
510 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
511 SET(C_FLAGS ${C_FLAGS} -pthread)
512 SET(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
515 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
517 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
520 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
522 # Some systems need pthread_np.h to get pthread_setname_np
523 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
524 IF(HAVE_PTHREAD_NP_H)
525 CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
526 IF(NOT HAVE_PTHREAD_SETNAME_NP)
527 CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
529 CHECK_C_SOURCE_COMPILES("
531 #include <pthread_np.h>
534 pthread_setname_np(\"testname\");
537 PTHREAD_SETNAME_NP_ONE_PARAM
539 CHECK_C_SOURCE_COMPILES("
541 #include <pthread_np.h>
544 pthread_setname_np(pthread_self(), \"%s\", \"testname\");
547 PTHREAD_SETNAME_NP_THREE_PARAMS
551 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
552 IF(NOT HAVE_PTHREAD_SETNAME_NP)
553 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
555 CHECK_C_SOURCE_COMPILES("
559 pthread_setname_np(\"testname\");
562 PTHREAD_SETNAME_NP_ONE_PARAM
564 CHECK_C_SOURCE_COMPILES("
568 pthread_setname_np(pthread_self(), \"%s\", \"testname\");
571 PTHREAD_SETNAME_NP_THREE_PARAMS
577 CHECK_SYMBOL_EXISTS(getopt unistd.h HAVE_GETOPT)
579 # Check for a 64-bit type
580 IF(NOT SIZEOF_LONG MATCHES "8")
581 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
582 MESSAGE(FATAL_ERROR "No 64-bit type found, please report!")
587 # Common sources used by both the OpenAL implementation library and potentially
604 common/intrusive_ptr.h
654 alc/effects/autowah.cpp
655 alc/effects/chorus.cpp
656 alc/effects/compressor.cpp
657 alc/effects/dedicated.cpp
658 alc/effects/distortion.cpp
660 alc/effects/equalizer.cpp
661 alc/effects/fshifter.cpp
662 alc/effects/modulator.cpp
664 alc/effects/pshifter.cpp
665 alc/effects/reverb.cpp
666 alc/effects/vmorpher.cpp
668 alc/filters/biquad.cpp
671 alc/filters/splitter.cpp
672 alc/filters/splitter.h
690 alc/mixer/mixer_c.cpp
694 SET(CPU_EXTS "Default")
701 # Check for SSE+SSE2 support
702 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
703 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
704 IF(HAVE_XMMINTRIN_H AND HAVE_EMMINTRIN_H)
705 OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
706 OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
707 IF(ALSOFT_CPUEXT_SSE AND ALSOFT_CPUEXT_SSE2)
710 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp)
712 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp
713 PROPERTIES COMPILE_FLAGS "${SSE2_SWITCH}")
715 SET(CPU_EXTS "${CPU_EXTS}, SSE, SSE2")
718 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
719 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
721 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
722 MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
725 OPTION(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF)
727 OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
728 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
730 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse3.cpp)
732 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse3.cpp PROPERTIES
733 COMPILE_FLAGS "${SSE3_SWITCH}")
735 SET(CPU_EXTS "${CPU_EXTS}, SSE3")
738 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
739 MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
742 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
744 OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
745 IF(HAVE_SSE3 AND ALSOFT_CPUEXT_SSE4_1)
747 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse41.cpp)
749 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse41.cpp PROPERTIES
750 COMPILE_FLAGS "${SSE4_1_SWITCH}")
752 SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
755 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
756 MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
759 # Check for ARM Neon support
760 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
762 OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
763 IF(ALSOFT_CPUEXT_NEON)
765 SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_neon.cpp)
767 SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_neon.cpp PROPERTIES
768 COMPILE_FLAGS "${FPU_NEON_SWITCH}")
770 SET(CPU_EXTS "${CPU_EXTS}, Neon")
773 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
774 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
786 SET(HAVE_PORTAUDIO 0)
787 SET(HAVE_PULSEAUDIO 0)
788 SET(HAVE_COREAUDIO 0)
793 IF(WIN32 OR HAVE_DLFCN_H)
795 MACRO(ADD_BACKEND_LIBS _LIBS)
798 SET(IS_LINKED " (linked)")
799 MACRO(ADD_BACKEND_LIBS _LIBS)
800 SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
805 SET(ALC_OBJS ${ALC_OBJS}
806 alc/backends/base.cpp
808 # Default backends, always available
809 alc/backends/loopback.cpp
810 alc/backends/loopback.h
811 alc/backends/null.cpp
816 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
819 OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
820 IF(ALSOFT_BACKEND_ALSA)
822 SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
823 SET(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h)
824 ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
825 SET(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
828 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
829 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
833 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
836 OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
837 IF(ALSOFT_BACKEND_OSS)
839 SET(BACKENDS "${BACKENDS} OSS,")
840 SET(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h)
842 SET(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
844 SET(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
847 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
848 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
851 # Check Solaris backend
852 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
853 FIND_PACKAGE(AudioIO)
855 OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
856 IF(ALSOFT_BACKEND_SOLARIS)
858 SET(BACKENDS "${BACKENDS} Solaris,")
859 SET(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h)
860 SET(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
863 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
864 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
867 # Check SndIO backend
868 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
869 FIND_PACKAGE(SoundIO)
871 OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
872 IF(ALSOFT_BACKEND_SNDIO)
874 SET(BACKENDS "${BACKENDS} SndIO (linked),")
875 SET(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h)
876 SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
877 SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
880 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
881 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
885 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
888 OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
889 IF(ALSOFT_BACKEND_QSA)
891 SET(BACKENDS "${BACKENDS} QSA (linked),")
892 SET(ALC_OBJS ${ALC_OBJS} alc/backends/qsa.cpp alc/backends/qsa.h)
893 SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
894 SET(INC_PATHS ${INC_PATHS} ${QSA_INCLUDE_DIRS})
897 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
898 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
901 # Check Windows-only backends
902 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
903 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
904 OPTION(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
906 SET(WINSDK_LIB_DIRS )
907 SET(WINSDK_INCLUDE_DIRS )
908 FIND_PACKAGE(WindowsSDK)
910 get_windowssdk_library_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_LIB_DIRS)
911 get_windowssdk_include_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_INCLUDE_DIRS)
914 SET(OLD_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
915 SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0502)
917 # Check MMSystem backend
918 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
919 FIND_LIBRARY(WINMM_LIBRARY NAMES winmm
920 PATHS ${WINSDK_LIB_DIRS}
921 PATH_SUFFIXES lib lib/x86 lib/x64)
922 IF(HAVE_MMSYSTEM_H AND WINMM_LIBRARY)
923 OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
924 IF(ALSOFT_BACKEND_WINMM)
926 SET(BACKENDS "${BACKENDS} WinMM,")
927 SET(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h)
928 SET(EXTRA_LIBS ${WINMM_LIBRARY} ${EXTRA_LIBS})
932 # Check DSound backend
935 OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
936 IF(ALSOFT_BACKEND_DSOUND)
938 SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
939 SET(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h)
940 ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
941 SET(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIRS})
945 # Check for WASAPI backend
946 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
947 IF(HAVE_MMDEVICEAPI_H)
948 OPTION(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
949 IF(ALSOFT_BACKEND_WASAPI)
951 SET(BACKENDS "${BACKENDS} WASAPI,")
952 SET(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h)
956 SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_REQUIRED_DEFINITIONS})
957 UNSET(OLD_REQUIRED_DEFINITIONS)
959 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
960 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
962 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
963 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
965 IF(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
966 MESSAGE(FATAL_ERROR "Failed to enabled required WASAPI backend")
969 # Check PortAudio backend
970 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
971 FIND_PACKAGE(PortAudio)
973 OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
974 IF(ALSOFT_BACKEND_PORTAUDIO)
975 SET(HAVE_PORTAUDIO 1)
976 SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
977 SET(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.h)
978 ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
979 SET(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS})
982 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
983 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
986 # Check PulseAudio backend
987 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
988 FIND_PACKAGE(PulseAudio)
990 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
991 IF(ALSOFT_BACKEND_PULSEAUDIO)
992 SET(HAVE_PULSEAUDIO 1)
993 SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
994 SET(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h)
995 ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
996 SET(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIRS})
999 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
1000 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
1003 # Check JACK backend
1004 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
1007 OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
1008 IF(ALSOFT_BACKEND_JACK)
1010 SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
1011 SET(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h)
1012 ADD_BACKEND_LIBS(${JACK_LIBRARIES})
1013 SET(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS})
1016 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1017 MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
1020 # Check CoreAudio backend
1021 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1022 FIND_LIBRARY(COREAUDIO_FRAMEWORK
1024 PATHS /System/Library/Frameworks
1026 IF(COREAUDIO_FRAMEWORK)
1027 OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1028 IF(ALSOFT_BACKEND_COREAUDIO)
1029 SET(HAVE_COREAUDIO 1)
1030 SET(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h)
1031 SET(BACKENDS "${BACKENDS} CoreAudio,")
1032 SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1033 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1034 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1036 # Some versions of OSX may need the AudioToolbox framework. Add it if
1038 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1040 PATHS ~/Library/Frameworks
1042 /System/Library/Frameworks
1044 IF(AUDIOTOOLBOX_LIBRARY)
1045 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1049 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1050 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1053 # Check for OpenSL (Android) backend
1054 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1055 FIND_PACKAGE(OpenSL)
1057 OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1058 IF(ALSOFT_BACKEND_OPENSL)
1060 SET(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h)
1061 SET(BACKENDS "${BACKENDS} OpenSL,")
1062 SET(EXTRA_LIBS ${OPENSL_LIBRARIES} ${EXTRA_LIBS})
1063 SET(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS})
1066 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1067 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1070 # Check for SDL2 backend
1071 OPTION(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF)
1074 # Off by default, since it adds a runtime dependency
1075 OPTION(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF)
1076 IF(ALSOFT_BACKEND_SDL2)
1078 SET(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h)
1079 SET(BACKENDS "${BACKENDS} SDL2,")
1080 SET(EXTRA_LIBS ${SDL2_LIBRARY} ${EXTRA_LIBS})
1081 SET(INC_PATHS ${INC_PATHS} ${SDL2_INCLUDE_DIR})
1084 IF(ALSOFT_REQUIRE_SDL2 AND NOT SDL2_FOUND)
1085 MESSAGE(FATAL_ERROR "Failed to enabled required SDL2 backend")
1088 # Optionally enable the Wave Writer backend
1089 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1090 IF(ALSOFT_BACKEND_WAVE)
1092 SET(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h)
1093 SET(BACKENDS "${BACKENDS} WaveFile,")
1096 # This is always available
1097 SET(BACKENDS "${BACKENDS} Null")
1101 IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
1102 # Get the current working branch and its latest abbreviated commit hash
1103 ADD_CUSTOM_TARGET(build_version
1104 ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
1105 -D LIB_VERSION=${LIB_VERSION}
1106 -D LIB_VERSION_NUM=${LIB_VERSION_NUM}
1107 -D SRC=${OpenAL_SOURCE_DIR}/version.h.in
1108 -D DST=${OpenAL_BINARY_DIR}/version.h
1109 -P ${OpenAL_SOURCE_DIR}/version.cmake
1110 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1114 SET(GIT_BRANCH "UNKNOWN")
1115 SET(GIT_COMMIT_HASH "unknown")
1117 "${OpenAL_SOURCE_DIR}/version.h.in"
1118 "${OpenAL_BINARY_DIR}/version.h")
1122 SET(NATIVE_SRC_DIR "${OpenAL_SOURCE_DIR}/native-tools")
1124 SET(ALSOFT_NATIVE_TOOLS_PATH "" CACHE STRING "Path to prebuilt native tools (leave blank to auto-build)")
1125 IF(ALSOFT_NATIVE_TOOLS_PATH)
1126 find_program(BIN2H_NATIVE_COMMAND NAMES bin2h
1127 PATHS "${ALSOFT_NATIVE_TOOLS_PATH}"
1129 find_program(BSINCGEN_NATIVE_COMMAND NAMES bsincgen
1130 PATHS "${ALSOFT_NATIVE_TOOLS_PATH}"
1132 if(NOT BIN2H_NATIVE_COMMAND OR NOT BSINCGEN_NATIVE_COMMAND)
1133 message(FATAL_ERROR "Failed to find native tools in ${ALSOFT_NATIVE_TOOLS_PATH}.
1134 bin2h: ${BIN2H_NATIVE_COMMAND}
1135 bsincgen: ${BSINCGEN_NATIVE_COMMAND}")
1137 SET(BIN2H_COMMAND ${BIN2H_NATIVE_COMMAND})
1138 SET(BSINCGEN_COMMAND ${BSINCGEN_NATIVE_COMMAND})
1140 SET(NATIVE_BIN_DIR "${OpenAL_BINARY_DIR}/native-tools")
1141 FILE(MAKE_DIRECTORY "${NATIVE_BIN_DIR}")
1143 SET(BIN2H_COMMAND "${NATIVE_BIN_DIR}/bin2h")
1144 SET(BSINCGEN_COMMAND "${NATIVE_BIN_DIR}/bsincgen")
1145 ADD_CUSTOM_COMMAND(OUTPUT "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
1146 COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "${NATIVE_SRC_DIR}"
1147 COMMAND ${CMAKE_COMMAND} -E remove "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
1148 COMMAND ${CMAKE_COMMAND} --build . --config "Release"
1149 WORKING_DIRECTORY "${NATIVE_BIN_DIR}"
1150 DEPENDS "${NATIVE_SRC_DIR}/CMakeLists.txt"
1151 IMPLICIT_DEPENDS C "${NATIVE_SRC_DIR}/bin2h.c"
1152 C "${NATIVE_SRC_DIR}/bsincgen.c"
1156 ADD_CUSTOM_TARGET(native-tools
1157 DEPENDS "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
1161 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON)
1162 if(ALSOFT_EMBED_HRTF_DATA)
1163 MACRO(make_hrtf_header FILENAME VARNAME)
1164 SET(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}")
1165 SET(outfile "${OpenAL_BINARY_DIR}/${FILENAME}.h")
1167 ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
1168 COMMAND "${BIN2H_COMMAND}" "${infile}" "${outfile}" ${VARNAME}
1169 DEPENDS native-tools "${infile}"
1172 SET(ALC_OBJS ${ALC_OBJS} "${outfile}")
1175 make_hrtf_header(default-44100.mhr "hrtf_default_44100")
1176 make_hrtf_header(default-48000.mhr "hrtf_default_48000")
1179 ADD_CUSTOM_COMMAND(OUTPUT "${OpenAL_BINARY_DIR}/bsinc_inc.h"
1180 COMMAND "${BSINCGEN_COMMAND}" "${OpenAL_BINARY_DIR}/bsinc_inc.h"
1181 DEPENDS native-tools "${NATIVE_SRC_DIR}/bsincgen.c"
1184 SET(ALC_OBJS ${ALC_OBJS} "${OpenAL_BINARY_DIR}/bsinc_inc.h")
1187 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1188 add_subdirectory(utils/alsoft-config)
1195 FIND_PACKAGE(SDL_sound)
1196 FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1201 SET(LIBNAME "openal")
1203 SET(LIBNAME "OpenAL32")
1206 # Needed for openal.pc.in
1207 SET(prefix ${CMAKE_INSTALL_PREFIX})
1208 SET(exec_prefix "\${prefix}")
1209 SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
1210 SET(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}")
1211 SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
1212 SET(PACKAGE_VERSION "${LIB_VERSION}")
1213 SET(PKG_CONFIG_CFLAGS )
1214 SET(PKG_CONFIG_PRIVATE_LIBS )
1215 IF(LIBTYPE STREQUAL "STATIC")
1216 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC)
1217 FOREACH(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1218 # If this is already a linker flag, or is a full path+file, add it
1219 # as-is. Otherwise, it's a name intended to be dressed as -lname.
1220 IF(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}")
1221 SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}")
1223 SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}")
1230 "${OpenAL_SOURCE_DIR}/config.h.in"
1231 "${OpenAL_BINARY_DIR}/config.h")
1233 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1234 "${OpenAL_BINARY_DIR}/openal.pc"
1239 SET(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal.
1242 # Build main library
1243 IF(LIBTYPE STREQUAL "STATIC")
1244 SET(CPP_DEFS ${CPP_DEFS} AL_LIBTYPE_STATIC)
1245 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1246 SET(CPP_DEFS ${CPP_DEFS} AL_NO_UID_DEFS)
1248 ADD_LIBRARY(OpenAL STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1253 SET(SUBSYS_FLAG ${SUBSYS_FLAG} "/SUBSYSTEM:WINDOWS")
1254 ELSEIF(CMAKE_COMPILER_IS_GNUCC)
1255 SET(SUBSYS_FLAG ${SUBSYS_FLAG} "-mwindows")
1259 SET(RC_CONFIG resources/openal32.rc)
1260 IF(WIN32 AND ALSOFT_BUILD_ROUTER)
1261 ADD_LIBRARY(OpenAL SHARED
1269 TARGET_COMPILE_DEFINITIONS(OpenAL
1270 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
1271 TARGET_COMPILE_OPTIONS(OpenAL PRIVATE ${C_FLAGS})
1272 TARGET_LINK_LIBRARIES(OpenAL PRIVATE ${LINKER_FLAGS})
1273 TARGET_INCLUDE_DIRECTORIES(OpenAL
1275 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1276 $<INSTALL_INTERFACE:include>
1278 ${OpenAL_SOURCE_DIR}/common
1279 ${OpenAL_BINARY_DIR}
1281 SET_TARGET_PROPERTIES(OpenAL PROPERTIES PREFIX "")
1282 SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME ${LIBNAME})
1283 IF(TARGET build_version)
1284 ADD_DEPENDENCIES(OpenAL build_version)
1288 SET(LIBNAME "soft_oal")
1289 SET(IMPL_TARGET soft_oal)
1290 SET(RC_CONFIG resources/soft_oal.rc)
1293 ADD_LIBRARY(${IMPL_TARGET} SHARED ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${RC_CONFIG})
1295 SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES PREFIX "")
1299 TARGET_LINK_LIBRARIES(${IMPL_TARGET}
1300 PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1302 TARGET_INCLUDE_DIRECTORIES(${IMPL_TARGET}
1304 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1305 $<INSTALL_INTERFACE:include>
1308 ${OpenAL_BINARY_DIR}
1309 ${OpenAL_SOURCE_DIR}
1310 ${OpenAL_SOURCE_DIR}/alc
1311 ${OpenAL_SOURCE_DIR}/common
1314 SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES OUTPUT_NAME ${LIBNAME}
1315 VERSION ${LIB_VERSION}
1316 SOVERSION ${LIB_MAJOR_VERSION}
1318 TARGET_COMPILE_DEFINITIONS(${IMPL_TARGET}
1319 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
1320 TARGET_COMPILE_OPTIONS(${IMPL_TARGET} PRIVATE ${C_FLAGS})
1322 IF(TARGET build_version)
1323 ADD_DEPENDENCIES(${IMPL_TARGET} build_version)
1326 IF(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
1327 FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1328 FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1329 IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1331 IF(NOT SED_EXECUTABLE)
1332 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1334 IF(NOT DLLTOOL_EXECUTABLE)
1335 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1338 SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS
1339 " -Wl,--output-def,OpenAL32.def")
1340 ADD_CUSTOM_COMMAND(TARGET OpenAL POST_BUILD
1341 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
1342 COMMAND "${DLLTOOL_EXECUTABLE}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
1343 COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
1350 INSTALL(TARGETS OpenAL EXPORT OpenAL
1351 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1352 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1353 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1354 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL
1356 EXPORT(TARGETS OpenAL
1358 FILE OpenALConfig.cmake)
1359 INSTALL(EXPORT OpenAL
1360 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
1362 FILE OpenALConfig.cmake)
1363 INSTALL(FILES include/AL/al.h
1367 include/AL/efx-creative.h
1368 include/AL/efx-presets.h
1369 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/AL
1371 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1372 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1374 INSTALL(TARGETS soft_oal
1375 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1383 message(STATUS "Building DLL router")
1387 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1388 MESSAGE(STATUS " ${BACKENDS}")
1390 MESSAGE(STATUS "Building with support for CPU extensions:")
1391 MESSAGE(STATUS " ${CPU_EXTS}")
1394 MESSAGE(STATUS "Building with SSE${FPMATH_SET} codegen")
1400 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1401 MESSAGE(STATUS " This is probably NOT what you want!")
1406 if(ALSOFT_EMBED_HRTF_DATA)
1407 message(STATUS "Embedding HRTF datasets")
1411 # Install alsoft.conf configuration file
1413 INSTALL(FILES alsoftrc.sample
1414 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal
1416 MESSAGE(STATUS "Installing sample configuration")
1420 # Install HRTF definitions
1421 IF(ALSOFT_HRTF_DEFS)
1422 INSTALL(FILES hrtf/default-44100.mhr
1423 hrtf/default-48000.mhr
1424 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/hrtf
1426 MESSAGE(STATUS "Installing HRTF definitions")
1430 # Install AmbDec presets
1431 IF(ALSOFT_AMBDEC_PRESETS)
1432 INSTALL(FILES presets/3D7.1.ambdec
1433 presets/hexagon.ambdec
1434 presets/itu5.1.ambdec
1435 presets/itu5.1-nocenter.ambdec
1436 presets/rectangle.ambdec
1437 presets/square.ambdec
1439 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/presets
1441 MESSAGE(STATUS "Installing AmbDec presets")
1448 ADD_EXECUTABLE(openal-info utils/openal-info.c)
1449 TARGET_INCLUDE_DIRECTORIES(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
1450 TARGET_COMPILE_OPTIONS(openal-info PRIVATE ${C_FLAGS})
1451 TARGET_LINK_LIBRARIES(openal-info PRIVATE ${LINKER_FLAGS} OpenAL)
1452 set(UTIL_TARGETS ${UTIL_TARGETS} openal-info)
1454 find_package(MySOFA)
1457 utils/makemhr/loaddef.cpp
1458 utils/makemhr/loaddef.h
1459 utils/makemhr/loadsofa.cpp
1460 utils/makemhr/loadsofa.h
1461 utils/makemhr/makemhr.cpp
1462 utils/makemhr/makemhr.h)
1464 set(MAKEMHR_SRCS ${MAKEMHR_SRCS} utils/getopt.c utils/getopt.h)
1466 add_executable(makemhr ${MAKEMHR_SRCS})
1467 target_compile_definitions(makemhr PRIVATE ${CPP_DEFS})
1468 target_include_directories(makemhr
1469 PRIVATE ${OpenAL_SOURCE_DIR}/common ${OpenAL_BINARY_DIR})
1470 target_compile_options(makemhr PRIVATE ${C_FLAGS})
1471 target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} MySOFA::MySOFA)
1472 set(UTIL_TARGETS ${UTIL_TARGETS} makemhr)
1474 set(SOFAINFO_SRCS utils/sofa-info.cpp)
1475 add_executable(sofa-info ${SOFAINFO_SRCS})
1476 target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS})
1477 target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
1478 target_compile_options(sofa-info PRIVATE ${C_FLAGS})
1479 target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} MySOFA::MySOFA)
1483 INSTALL(TARGETS ${UTIL_TARGETS}
1484 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1485 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1486 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1490 MESSAGE(STATUS "Building utility programs")
1491 IF(TARGET alsoft-config)
1492 MESSAGE(STATUS "Building configuration program")
1497 IF(ALSOFT_EXAMPLES OR ALSOFT_TESTS)
1498 # Add a static library with common functions used by multiple targets
1499 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c)
1500 TARGET_COMPILE_DEFINITIONS(ex-common PUBLIC ${CPP_DEFS})
1501 TARGET_INCLUDE_DIRECTORIES(ex-common PUBLIC ${OpenAL_SOURCE_DIR}/common)
1502 TARGET_COMPILE_OPTIONS(ex-common PUBLIC ${C_FLAGS})
1503 TARGET_LINK_LIBRARIES(ex-common PUBLIC OpenAL)
1507 ADD_EXECUTABLE(altonegen examples/altonegen.c)
1508 TARGET_COMPILE_DEFINITIONS(altonegen PRIVATE ${CPP_DEFS})
1509 TARGET_INCLUDE_DIRECTORIES(altonegen PRIVATE ${OpenAL_SOURCE_DIR}/common)
1510 TARGET_COMPILE_OPTIONS(altonegen PRIVATE ${C_FLAGS})
1511 TARGET_LINK_LIBRARIES(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} ex-common)
1514 INSTALL(TARGETS altonegen
1515 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1516 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1517 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1521 MESSAGE(STATUS "Building test programs")
1526 ADD_EXECUTABLE(alrecord examples/alrecord.c)
1527 TARGET_LINK_LIBRARIES(alrecord PRIVATE ${LINKER_FLAGS} ex-common)
1530 INSTALL(TARGETS alrecord
1531 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1532 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1533 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1537 MESSAGE(STATUS "Building example programs")
1541 ADD_EXECUTABLE(alplay examples/alplay.c)
1542 TARGET_INCLUDE_DIRECTORIES(alplay
1543 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1544 TARGET_LINK_LIBRARIES(alplay
1545 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1547 ADD_EXECUTABLE(alstream examples/alstream.c)
1548 TARGET_INCLUDE_DIRECTORIES(alstream
1549 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1550 TARGET_LINK_LIBRARIES(alstream
1551 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1553 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1554 TARGET_INCLUDE_DIRECTORIES(alreverb
1555 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1556 TARGET_LINK_LIBRARIES(alreverb
1557 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1559 ADD_EXECUTABLE(almultireverb examples/almultireverb.c)
1560 TARGET_INCLUDE_DIRECTORIES(almultireverb
1561 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1562 TARGET_LINK_LIBRARIES(almultireverb
1563 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common
1566 ADD_EXECUTABLE(allatency examples/allatency.c)
1567 TARGET_INCLUDE_DIRECTORIES(allatency
1568 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1569 TARGET_LINK_LIBRARIES(allatency
1570 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
1572 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1573 TARGET_INCLUDE_DIRECTORIES(alloopback
1574 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1575 TARGET_LINK_LIBRARIES(alloopback
1576 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB})
1578 ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1579 TARGET_INCLUDE_DIRECTORIES(alhrtf
1580 PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1581 TARGET_LINK_LIBRARIES(alhrtf
1582 PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB})
1585 INSTALL(TARGETS alplay alstream alreverb almultireverb allatency alloopback alhrtf
1586 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1587 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1588 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1592 MESSAGE(STATUS "Building SDL_sound example programs")
1598 IF(AVFORMAT_VERSION VERSION_LESS "57.56.101")
1599 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 57.56.101)")
1602 IF(AVCODEC_VERSION VERSION_LESS "57.64.101")
1603 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 57.64.101)")
1606 IF(AVUTIL_VERSION VERSION_LESS "55.34.101")
1607 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 55.34.101)")
1610 IF(SWSCALE_VERSION VERSION_LESS "4.2.100")
1611 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 4.2.100)")
1614 IF(SWRESAMPLE_VERSION VERSION_LESS "2.3.100")
1615 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 2.3.100)")
1620 ADD_EXECUTABLE(alffplay examples/alffplay.cpp)
1621 TARGET_INCLUDE_DIRECTORIES(alffplay
1622 PRIVATE ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
1623 TARGET_LINK_LIBRARIES(alffplay
1624 PRIVATE ${LINKER_FLAGS} ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} ex-common)
1627 INSTALL(TARGETS alffplay
1628 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1629 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1630 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1633 MESSAGE(STATUS "Building SDL+FFmpeg example programs")