1 # CMake build file list for OpenAL
3 cmake_minimum_required(VERSION 3.13)
7 # The workaround for try_compile failing with code signing
8 # since cmake-3.18.2, not required
9 set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
10 ${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}
11 "CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED"
12 "CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED")
13 set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO)
14 set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
17 if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
18 # Fix compile failure with armv7 deployment target >= 11.0, xcode clang
20 # error: invalid iOS deployment version '--target=armv7-apple-ios13.6',
21 # iOS 10 is the maximum deployment target for 32-bit targets
22 # If CMAKE_OSX_DEPLOYMENT_TARGET is not defined, cmake will choose latest
24 if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*armv7.*")
25 if(NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET
26 OR NOT CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "11.0")
27 message(STATUS "Forcing iOS deployment target to 10.0 for armv7")
28 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.0" CACHE STRING "Minimum OS X deployment version"
32 elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
36 if(COMMAND CMAKE_POLICY)
37 cmake_policy(SET CMP0003 NEW)
38 cmake_policy(SET CMP0005 NEW)
40 cmake_policy(SET CMP0020 NEW)
43 cmake_policy(SET CMP0042 NEW)
46 cmake_policy(SET CMP0054 NEW)
49 cmake_policy(SET CMP0058 NEW)
52 cmake_policy(SET CMP0063 NEW)
55 cmake_policy(SET CMP0075 NEW)
58 cmake_policy(SET CMP0092 NEW)
61 cmake_policy(SET CMP0117 NEW)
63 endif(COMMAND CMAKE_POLICY)
67 if(NOT CMAKE_BUILD_TYPE)
68 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
69 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
72 if(NOT CMAKE_DEBUG_POSTFIX)
73 set(CMAKE_DEBUG_POSTFIX "" CACHE STRING
74 "Library postfix for debug builds. Normally left blank."
78 set(DEFAULT_TARGET_PROPS
81 CXX_STANDARD_REQUIRED TRUE
82 # Prefer C11, but support C99 and earlier when possible.
85 set(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
87 include(CheckFunctionExists)
88 include(CheckLibraryExists)
89 include(CheckIncludeFile)
90 include(CheckIncludeFiles)
91 include(CheckSymbolExists)
92 include(CheckCCompilerFlag)
93 include(CheckCXXCompilerFlag)
94 include(CheckCSourceCompiles)
95 include(CheckCXXSourceCompiles)
96 include(CheckStructHasMember)
97 include(CMakePackageConfigHelpers)
98 include(GNUInstallDirs)
100 find_package(PkgConfig)
101 find_package(SDL2 QUIET)
104 option(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
106 option(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
108 option(ALSOFT_UTILS "Build utility programs" ON)
109 option(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
111 option(ALSOFT_EXAMPLES "Build example programs" ON)
112 option(ALSOFT_TESTS "Build test programs" OFF)
114 option(ALSOFT_INSTALL "Install main library" ON)
115 option(ALSOFT_INSTALL_CONFIG "Install alsoft.conf sample configuration file" ON)
116 option(ALSOFT_INSTALL_HRTF_DATA "Install HRTF data files" ON)
117 option(ALSOFT_INSTALL_AMBDEC_PRESETS "Install AmbDec preset files" ON)
118 option(ALSOFT_INSTALL_EXAMPLES "Install example programs (alplay, alstream, ...)" ON)
119 option(ALSOFT_INSTALL_UTILS "Install utility programs (openal-info, alsoft-config, ...)" ON)
120 option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON)
122 option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32})
124 option(ALSOFT_SEARCH_INSTALL_DATADIR "Search the installation data directory" OFF)
125 if(ALSOFT_SEARCH_INSTALL_DATADIR)
126 set(ALSOFT_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
129 if(DEFINED SHARE_INSTALL_DIR)
130 message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
131 set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
134 if(DEFINED LIB_SUFFIX)
135 message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
137 if(DEFINED ALSOFT_CONFIG)
138 message(WARNING "ALSOFT_CONFIG is deprecated. Use ALSOFT_INSTALL_CONFIG instead")
140 if(DEFINED ALSOFT_HRTF_DEFS)
141 message(WARNING "ALSOFT_HRTF_DEFS is deprecated. Use ALSOFT_INSTALL_HRTF_DATA instead")
143 if(DEFINED ALSOFT_AMBDEC_PRESETS)
144 message(WARNING "ALSOFT_AMBDEC_PRESETS is deprecated. Use ALSOFT_INSTALL_AMBDEC_PRESETS instead")
148 set(CPP_DEFS ) # C pre-processor, not C++
152 set(LINKER_FLAGS_DEBUG )
153 set(LINKER_FLAGS_RELEASE )
157 set(CPP_DEFS ${CPP_DEFS} _WIN32 NOMINMAX)
159 set(CPP_DEFS ${CPP_DEFS} __USE_MINGW_ANSI_STDIO)
162 option(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
164 option(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
167 option(ALSOFT_OSX_FRAMEWORK "Build as macOS framework" OFF)
171 # QNX's gcc do not uses /usr/include and /usr/lib paths by default
172 if("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
173 set(INC_PATHS ${INC_PATHS} /usr/include)
174 set(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
177 # When the library is built for static linking, apps should define
178 # AL_LIBTYPE_STATIC when including the AL headers.
183 set(LIB_MAJOR_VERSION "1")
184 set(LIB_MINOR_VERSION "23")
185 set(LIB_REVISION "1")
186 set(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
187 set(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0)
192 # Some systems erroneously require the __STDC_FORMAT_MACROS macro to be defined
193 # to get the fixed-width integer type formatter macros.
194 check_cxx_source_compiles("#include <cinttypes>
199 std::printf(\"%\" PRId64, i64);
201 HAVE_STDC_FORMAT_MACROS)
202 if(NOT HAVE_STDC_FORMAT_MACROS)
203 set(CPP_DEFS ${CPP_DEFS} __STDC_FORMAT_MACROS)
206 # Some systems may need libatomic for atomic functions to work
207 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
208 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
209 check_cxx_source_compiles("#include <atomic>
210 std::atomic<int> foo{0};
211 int main() { return foo.fetch_add(2); }"
213 if(NOT HAVE_LIBATOMIC)
214 set(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
216 set(EXTRA_LIBS atomic ${EXTRA_LIBS})
218 unset(OLD_REQUIRED_LIBRARIES)
221 # Include liblog for Android logging
222 check_library_exists(log __android_log_print "" HAVE_LIBLOG)
224 set(EXTRA_LIBS log ${EXTRA_LIBS})
225 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
230 set(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS)
231 check_cxx_compiler_flag(/permissive- HAVE_PERMISSIVE_SWITCH)
232 if(HAVE_PERMISSIVE_SWITCH)
233 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:/permissive->)
235 set(C_FLAGS ${C_FLAGS} /W4 /w14640 /wd4065 /wd4127 /wd4268 /wd4324 /wd5030 /wd5051)
238 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
240 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
243 message(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
246 option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
247 if(FORCE_STATIC_VCRT)
249 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
250 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
251 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
252 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
253 if(${flag_var} MATCHES "/MD")
254 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
259 set(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align
261 $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>)
263 check_cxx_compiler_flag(-Wno-c++20-attribute-extensions HAVE_WNO_CXX20_ATTR_EXT)
264 if(HAVE_WNO_CXX20_ATTR_EXT)
265 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-attribute-extensions>)
267 check_cxx_compiler_flag(-Wno-c++20-extensions HAVE_WNO_CXX20_EXT)
268 if(HAVE_WNO_CXX20_EXT)
269 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-extensions>)
273 check_cxx_compiler_flag(-Wno-interference-size HAVE_WNO_INTERFERENCE_SIZE)
274 if(HAVE_WNO_INTERFERENCE_SIZE)
275 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>)
279 set(C_FLAGS ${C_FLAGS} -Werror)
282 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
284 foreach(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
285 if(${flag_var} MATCHES "-DNDEBUG")
286 string(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
290 check_c_compiler_flag(-fno-math-errno HAVE_FNO_MATH_ERRNO)
291 if(HAVE_FNO_MATH_ERRNO)
292 set(C_FLAGS ${C_FLAGS} -fno-math-errno)
295 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
296 if(ALSOFT_STATIC_LIBGCC)
297 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
298 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
299 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBGCC_SWITCH)
300 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
301 unset(OLD_REQUIRED_LIBRARIES)
303 if(NOT HAVE_STATIC_LIBGCC_SWITCH)
304 message(FATAL_ERROR "Cannot static link libgcc")
306 set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
309 option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF)
310 if(ALSOFT_STATIC_STDCXX)
311 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
312 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-static-libstdc++")
313 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBSTDCXX_SWITCH)
314 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
315 unset(OLD_REQUIRED_LIBRARIES)
317 if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH)
318 message(FATAL_ERROR "Cannot static link libstdc++")
320 set(LINKER_FLAGS ${LINKER_FLAGS} "-static-libstdc++")
324 option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
325 if(ALSOFT_STATIC_WINPTHREAD)
326 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
327 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
328 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBWINPTHREAD_SWITCH)
329 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
330 unset(OLD_REQUIRED_LIBRARIES)
332 if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
333 message(FATAL_ERROR "Cannot static link libwinpthread")
335 set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
340 # Set visibility/export options if available
341 if(NOT LIBTYPE STREQUAL "STATIC")
343 set(EXPORT_DECL "__declspec(dllexport)")
345 set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
346 # Yes GCC, really don't accept visibility modes you don't support
347 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
349 check_c_source_compiles("int foo() __attribute__((visibility(\"protected\")));
350 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
351 if(HAVE_GCC_PROTECTED_VISIBILITY)
352 set(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
354 check_c_source_compiles("int foo() __attribute__((visibility(\"default\")));
355 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
356 if(HAVE_GCC_DEFAULT_VISIBILITY)
357 set(EXPORT_DECL "__attribute__((visibility(\"default\")))")
360 if(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
361 set(CMAKE_C_VISIBILITY_PRESET hidden)
362 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
365 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
373 set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
374 # Yes GCC, really don't accept command line options you don't support
375 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
376 check_c_compiler_flag(-msse2 HAVE_MSSE2_SWITCH)
377 if(HAVE_MSSE2_SWITCH)
378 set(SSE2_SWITCH "-msse2")
380 set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
381 unset(OLD_REQUIRED_FLAGS)
384 check_include_file(xmmintrin.h HAVE_XMMINTRIN_H)
385 check_include_file(emmintrin.h HAVE_EMMINTRIN_H)
386 check_include_file(pmmintrin.h HAVE_PMMINTRIN_H)
387 check_include_file(smmintrin.h HAVE_SMMINTRIN_H)
388 check_include_file(arm_neon.h HAVE_ARM_NEON_H)
396 # Check for SSE support
397 option(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
398 option(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
399 if(ALSOFT_CPUEXT_SSE AND HAVE_XMMINTRIN_H)
402 if(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
403 message(FATAL_ERROR "Failed to enable required SSE CPU extensions")
406 option(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
407 option(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
408 if(ALSOFT_CPUEXT_SSE2 AND HAVE_SSE AND HAVE_EMMINTRIN_H)
411 if(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
412 message(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
415 option(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
416 option(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF)
417 if(ALSOFT_CPUEXT_SSE3 AND HAVE_SSE2 AND HAVE_PMMINTRIN_H)
420 if(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
421 message(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
424 option(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
425 option(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
426 if(ALSOFT_CPUEXT_SSE4_1 AND HAVE_SSE3 AND HAVE_SMMINTRIN_H)
429 if(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
430 message(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
433 # Check for ARM Neon support
434 option(ALSOFT_CPUEXT_NEON "Enable ARM NEON support" ON)
435 option(ALSOFT_REQUIRE_NEON "Require ARM NEON support" OFF)
436 if(ALSOFT_CPUEXT_NEON AND HAVE_ARM_NEON_H)
437 check_c_source_compiles("#include <arm_neon.h>
440 int32x4_t ret4 = vdupq_n_s32(0);
441 return vgetq_lane_s32(ret4, 0);
442 }" HAVE_NEON_INTRINSICS)
443 if(HAVE_NEON_INTRINSICS)
447 if(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
448 message(FATAL_ERROR "Failed to enable required ARM NEON CPU extensions")
452 set(ALSOFT_FORCE_ALIGN )
455 if(CMAKE_SIZEOF_VOID_P MATCHES "4" AND HAVE_SSE2)
456 option(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
457 if(ALSOFT_ENABLE_SSE2_CODEGEN)
459 check_c_compiler_flag("/arch:SSE2" HAVE_ARCH_SSE2)
461 set(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
462 set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
466 check_c_compiler_flag("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
467 if(HAVE_MFPMATH_SSE_2)
468 set(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
469 set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
472 # SSE depends on a 16-byte aligned stack, and by default, GCC
473 # assumes the stack is suitably aligned. Older Linux code or other
474 # OSs don't guarantee this on 32-bit, so externally-callable
475 # functions need to ensure an aligned stack.
476 set(EXPORT_DECL "${EXPORT_DECL}__attribute__((force_align_arg_pointer))")
477 set(ALSOFT_FORCE_ALIGN "__attribute__((force_align_arg_pointer))")
483 set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
484 foreach(flag_var ${SSE_FLAGS})
485 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
488 check_c_source_compiles("#include <emmintrin.h>
489 int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
491 set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
495 check_include_file(cpuid.h HAVE_CPUID_H)
496 check_include_file(intrin.h HAVE_INTRIN_H)
497 check_include_file(guiddef.h HAVE_GUIDDEF_H)
499 # Some systems need libm for some math functions to work
501 check_library_exists(m pow "" HAVE_LIBM)
503 set(MATH_LIB ${MATH_LIB} m)
504 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
507 # Some systems need to link with -lrt for clock_gettime as used by the common
510 check_library_exists(rt clock_gettime "" HAVE_LIBRT)
515 # Check for the dlopen API (for dynamically loading backend libs)
517 check_include_file(dlfcn.h HAVE_DLFCN_H)
518 check_library_exists(dl dlopen "" HAVE_LIBDL)
520 set(EXTRA_LIBS dl ${EXTRA_LIBS})
521 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
525 # Check for a cpuid intrinsic
527 check_c_source_compiles("#include <cpuid.h>
530 unsigned int eax, ebx, ecx, edx;
531 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
532 }" HAVE_GCC_GET_CPUID)
535 check_c_source_compiles("#include <intrin.h>
541 }" HAVE_CPUID_INTRINSIC)
544 check_symbol_exists(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
547 # We need pthreads outside of Windows, for semaphores. It's also used to
548 # set the priority and name of threads, when possible.
549 check_include_file(pthread.h HAVE_PTHREAD_H)
550 if(NOT HAVE_PTHREAD_H)
551 message(FATAL_ERROR "PThreads is required for non-Windows builds!")
554 check_c_compiler_flag(-pthread HAVE_PTHREAD)
556 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
557 set(C_FLAGS ${C_FLAGS} -pthread)
558 set(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
561 check_symbol_exists(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
563 # Some systems need pthread_np.h to get pthread_setname_np
564 check_include_files("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
565 if(HAVE_PTHREAD_NP_H)
566 check_symbol_exists(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
567 if(NOT HAVE_PTHREAD_SETNAME_NP)
568 check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
571 check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
572 if(NOT HAVE_PTHREAD_SETNAME_NP)
573 check_symbol_exists(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
579 # Common sources used by both the OpenAL implementation library, the OpenAL
580 # router, and certain tools and examples.
595 common/althrd_setname.cpp
596 common/althrd_setname.h
604 common/intrusive_ptr.h
608 common/phase_shifter.h
609 common/polyphase_resampler.cpp
610 common/polyphase_resampler.h
612 common/ringbuffer.cpp
619 # Core library routines
631 core/bsinc_tables.cpp
634 core/buffer_storage.cpp
635 core/buffer_storage.h
643 core/cubic_tables.cpp
654 core/filters/biquad.h
655 core/filters/biquad.cpp
658 core/filters/splitter.cpp
659 core/filters/splitter.h
664 core/front_stablizer.h
675 core/resampler_limits.h
676 core/storage_formats.cpp
677 core/storage_formats.h
687 option(ALSOFT_RTKIT "Enable RTKit support" ON)
688 option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE)
690 find_package(DBus1 QUIET)
691 if(NOT DBus1_FOUND AND PkgConfig_FOUND)
692 pkg_check_modules(DBUS dbus-1)
694 if(DBus1_FOUND OR DBUS_FOUND)
696 set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h
697 core/rtkit.cpp core/rtkit.h)
699 set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS})
700 set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER})
702 set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES})
705 set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS})
706 set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS})
708 set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES})
713 if(NOT DBus1_INCLUDE_DIRS)
714 set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS")
716 if(NOT DBus1_LIBRARIES)
717 set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES")
719 message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})")
723 if(ALSOFT_REQUIRE_RTKIT AND NOT HAVE_RTKIT)
724 message(FATAL_ERROR "Failed to enable required RTKit support")
727 # Default mixers, always available
728 set(CORE_OBJS ${CORE_OBJS}
730 core/mixer/hrtfbase.h
731 core/mixer/hrtfdefs.h
732 core/mixer/mixer_c.cpp)
734 # AL and related routines
745 al/effects/autowah.cpp
746 al/effects/chorus.cpp
747 al/effects/compressor.cpp
748 al/effects/convolution.cpp
749 al/effects/dedicated.cpp
750 al/effects/distortion.cpp
752 al/effects/effects.cpp
754 al/effects/equalizer.cpp
755 al/effects/fshifter.cpp
756 al/effects/modulator.cpp
758 al/effects/pshifter.cpp
759 al/effects/reverb.cpp
760 al/effects/vmorpher.cpp
774 # ALC and related routines
786 alc/effects/autowah.cpp
787 alc/effects/chorus.cpp
788 alc/effects/compressor.cpp
789 alc/effects/convolution.cpp
790 alc/effects/dedicated.cpp
791 alc/effects/distortion.cpp
793 alc/effects/equalizer.cpp
794 alc/effects/fshifter.cpp
795 alc/effects/modulator.cpp
797 alc/effects/pshifter.cpp
798 alc/effects/reverb.cpp
799 alc/effects/vmorpher.cpp
816 al/eax/fx_slot_index.cpp
817 al/eax/fx_slot_index.h
827 # Include SIMD mixers
828 set(CPU_EXTS "Default")
830 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse.cpp)
831 set(CPU_EXTS "${CPU_EXTS}, SSE")
834 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse2.cpp)
835 set(CPU_EXTS "${CPU_EXTS}, SSE2")
838 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse3.cpp)
839 set(CPU_EXTS "${CPU_EXTS}, SSE3")
842 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse41.cpp)
843 set(CPU_EXTS "${CPU_EXTS}, SSE4.1")
846 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_neon.cpp)
847 set(CPU_EXTS "${CPU_EXTS}, Neon")
859 set(HAVE_PORTAUDIO 0)
860 set(HAVE_PULSEAUDIO 0)
861 set(HAVE_COREAUDIO 0)
867 if(WIN32 OR HAVE_DLFCN_H)
869 macro(ADD_BACKEND_LIBS _LIBS)
872 set(IS_LINKED " (linked)")
873 macro(ADD_BACKEND_LIBS _LIBS)
874 set(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
879 set(ALC_OBJS ${ALC_OBJS}
880 alc/backends/base.cpp
882 # Default backends, always available
883 alc/backends/loopback.cpp
884 alc/backends/loopback.h
885 alc/backends/null.cpp
889 # Check PipeWire backend
890 option(ALSOFT_BACKEND_PIPEWIRE "Enable PipeWire backend" ON)
891 option(ALSOFT_REQUIRE_PIPEWIRE "Require PipeWire backend" OFF)
892 if(ALSOFT_BACKEND_PIPEWIRE AND PkgConfig_FOUND)
893 pkg_check_modules(PIPEWIRE libpipewire-0.3>=0.3.23)
896 set(BACKENDS "${BACKENDS} PipeWire${IS_LINKED},")
897 set(ALC_OBJS ${ALC_OBJS} alc/backends/pipewire.cpp alc/backends/pipewire.h)
898 add_backend_libs(${PIPEWIRE_LIBRARIES})
899 set(INC_PATHS ${INC_PATHS} ${PIPEWIRE_INCLUDE_DIRS})
902 if(ALSOFT_REQUIRE_PIPEWIRE AND NOT HAVE_PIPEWIRE)
903 message(FATAL_ERROR "Failed to enable required PipeWire backend")
906 # Check PulseAudio backend
907 option(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
908 option(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
909 if(ALSOFT_BACKEND_PULSEAUDIO)
910 find_package(PulseAudio)
912 set(HAVE_PULSEAUDIO 1)
913 set(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
914 set(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h)
915 add_backend_libs(${PULSEAUDIO_LIBRARY})
916 set(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIR})
919 if(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
920 message(FATAL_ERROR "Failed to enable required PulseAudio backend")
925 option(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
926 option(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
927 if(ALSOFT_BACKEND_ALSA)
931 set(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
932 set(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h)
933 add_backend_libs(${ALSA_LIBRARIES})
934 set(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
939 option(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
940 option(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
941 if(ALSOFT_BACKEND_OSS)
945 set(BACKENDS "${BACKENDS} OSS,")
946 set(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h)
948 set(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
950 set(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
954 # Check Solaris backend
955 option(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
956 option(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
957 if(ALSOFT_BACKEND_SOLARIS)
958 find_package(AudioIO)
961 set(BACKENDS "${BACKENDS} Solaris,")
962 set(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h)
963 set(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
967 # Check SndIO backend (disabled by default on non-BSDs)
969 option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
971 option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" OFF)
973 option(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
974 if(ALSOFT_BACKEND_SNDIO)
978 set(BACKENDS "${BACKENDS} SndIO (linked),")
979 set(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h)
980 set(EXTRA_LIBS ${SNDIO_LIBRARIES} ${EXTRA_LIBS})
981 set(INC_PATHS ${INC_PATHS} ${SNDIO_INCLUDE_DIRS})
985 if(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
986 message(FATAL_ERROR "Failed to enable required ALSA backend")
988 if(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
989 message(FATAL_ERROR "Failed to enable required OSS backend")
991 if(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
992 message(FATAL_ERROR "Failed to enable required Solaris backend")
994 if(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
995 message(FATAL_ERROR "Failed to enable required SndIO backend")
998 # Check Windows-only backends
1001 # Check MMSystem backend
1002 option(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
1003 option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
1004 if(ALSOFT_BACKEND_WINMM)
1006 set(BACKENDS "${BACKENDS} WinMM,")
1007 set(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h)
1008 # There doesn't seem to be good way to search for winmm.lib for MSVC.
1009 # find_library doesn't find it without being told to look in a specific
1010 # place in the WindowsSDK, but it links anyway. If there ends up being
1011 # Windows targets without this, another means to detect it is needed.
1012 set(EXTRA_LIBS winmm ${EXTRA_LIBS})
1015 # Check DSound backend
1016 option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
1017 option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
1018 if(ALSOFT_BACKEND_DSOUND)
1019 check_include_file(dsound.h HAVE_DSOUND_H)
1021 find_path(DSOUND_INCLUDE_DIR NAMES "dsound.h"
1022 PATHS "${DXSDK_DIR}" PATH_SUFFIXES include
1023 DOC "The DirectSound include directory")
1025 if(HAVE_DSOUND_H OR DSOUND_INCLUDE_DIR)
1027 set(BACKENDS "${BACKENDS} DirectSound,")
1028 set(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h)
1030 if(NOT HAVE_DSOUND_H)
1031 set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR})
1037 # Check for WASAPI backend
1038 option(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
1039 option(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
1040 if(ALSOFT_BACKEND_WASAPI)
1041 check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
1042 if(HAVE_MMDEVICEAPI_H)
1044 set(BACKENDS "${BACKENDS} WASAPI,")
1045 set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h)
1049 if(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
1050 message(FATAL_ERROR "Failed to enable required WinMM backend")
1052 if(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
1053 message(FATAL_ERROR "Failed to enable required DSound backend")
1055 if(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
1056 message(FATAL_ERROR "Failed to enable required WASAPI backend")
1059 # Check JACK backend
1060 option(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
1061 option(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
1062 if(ALSOFT_BACKEND_JACK)
1066 set(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
1067 set(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h)
1068 add_backend_libs(${JACK_LIBRARIES})
1069 set(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS})
1072 if(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1073 message(FATAL_ERROR "Failed to enable required JACK backend")
1076 # Check CoreAudio backend
1077 option(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1078 option(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1079 if(ALSOFT_BACKEND_COREAUDIO)
1080 find_library(COREAUDIO_FRAMEWORK NAMES CoreAudio)
1081 find_path(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h)
1082 if(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR)
1083 set(HAVE_COREAUDIO 1)
1084 set(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h)
1085 set(BACKENDS "${BACKENDS} CoreAudio,")
1087 set(EXTRA_LIBS -Wl,-framework,CoreAudio ${EXTRA_LIBS})
1088 if(CMAKE_SYSTEM_NAME MATCHES "^(iOS|tvOS)$")
1089 find_library(COREFOUNDATION_FRAMEWORK NAMES CoreFoundation)
1090 if(COREFOUNDATION_FRAMEWORK)
1091 set(EXTRA_LIBS -Wl,-framework,CoreFoundation ${EXTRA_LIBS})
1094 set(EXTRA_LIBS -Wl,-framework,AudioUnit,-framework,ApplicationServices ${EXTRA_LIBS})
1097 # Some versions of OSX may need the AudioToolbox framework. Add it if
1099 find_library(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox)
1100 if(AUDIOTOOLBOX_LIBRARY)
1101 set(EXTRA_LIBS -Wl,-framework,AudioToolbox ${EXTRA_LIBS})
1104 set(INC_PATHS ${INC_PATHS} ${AUDIOUNIT_INCLUDE_DIR})
1107 if(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1108 message(FATAL_ERROR "Failed to enable required CoreAudio backend")
1111 # Check for Oboe (Android) backend
1112 option(ALSOFT_BACKEND_OBOE "Enable Oboe backend" ON)
1113 option(ALSOFT_REQUIRE_OBOE "Require Oboe backend" OFF)
1114 if(ALSOFT_BACKEND_OBOE)
1117 set(OBOE_SOURCE "" CACHE STRING "Source directory for Oboe.")
1119 add_subdirectory(${OBOE_SOURCE} ./oboe)
1120 set(OBOE_TARGET oboe)
1122 find_package(oboe CONFIG)
1123 if(NOT TARGET oboe::oboe)
1126 if(TARGET oboe::oboe)
1127 set(OBOE_TARGET "oboe::oboe")
1134 set(ALC_OBJS ${ALC_OBJS} alc/backends/oboe.cpp alc/backends/oboe.h)
1135 set(BACKENDS "${BACKENDS} Oboe,")
1136 set(EXTRA_LIBS ${OBOE_TARGET} ${EXTRA_LIBS})
1139 if(ALSOFT_REQUIRE_OBOE AND NOT HAVE_OBOE)
1140 message(FATAL_ERROR "Failed to enable required Oboe backend")
1143 # Check for OpenSL (Android) backend
1144 option(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1145 option(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1146 if(ALSOFT_BACKEND_OPENSL)
1147 find_package(OpenSL)
1150 set(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h)
1151 set(BACKENDS "${BACKENDS} OpenSL,")
1152 set(EXTRA_LIBS ${OPENSL_LIBRARIES} ${EXTRA_LIBS})
1153 set(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS})
1156 if(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1157 message(FATAL_ERROR "Failed to enable required OpenSL backend")
1160 # Check PortAudio backend
1161 option(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
1162 option(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
1163 if(ALSOFT_BACKEND_PORTAUDIO)
1164 find_package(PortAudio)
1166 set(HAVE_PORTAUDIO 1)
1167 set(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
1168 set(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.h)
1169 add_backend_libs(${PORTAUDIO_LIBRARIES})
1170 set(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS})
1173 if(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
1174 message(FATAL_ERROR "Failed to enable required PortAudio backend")
1177 # Check for SDL2 backend
1178 # Off by default, since it adds a runtime dependency
1179 option(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF)
1180 option(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF)
1181 if(ALSOFT_BACKEND_SDL2)
1184 set(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h)
1185 set(BACKENDS "${BACKENDS} SDL2,")
1186 set(EXTRA_LIBS ${EXTRA_LIBS} SDL2::SDL2)
1188 message(STATUS "Could NOT find SDL2")
1191 if(ALSOFT_REQUIRE_SDL2 AND NOT SDL2_FOUND)
1192 message(FATAL_ERROR "Failed to enable required SDL2 backend")
1195 # Optionally enable the Wave Writer backend
1196 option(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1197 if(ALSOFT_BACKEND_WAVE)
1199 set(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h)
1200 set(BACKENDS "${BACKENDS} WaveFile,")
1203 # This is always available
1204 set(BACKENDS "${BACKENDS} Null")
1208 if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
1209 set(GIT_DIR "${OpenAL_SOURCE_DIR}/.git")
1211 # Check if this is a submodule, if it is then find the .git directory
1212 if(NOT IS_DIRECTORY "${OpenAL_SOURCE_DIR}/.git")
1213 file(READ ${GIT_DIR} submodule)
1214 string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule})
1215 string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
1216 get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
1217 get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
1220 # Get the current working branch and its latest abbreviated commit hash
1221 add_custom_command(OUTPUT "${OpenAL_BINARY_DIR}/version_witness.txt"
1222 BYPRODUCTS "${OpenAL_BINARY_DIR}/version.h"
1223 COMMAND ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D LIB_VERSION=${LIB_VERSION}
1224 -D LIB_VERSION_NUM=${LIB_VERSION_NUM} -D SRC=${OpenAL_SOURCE_DIR}/version.h.in
1225 -D DST=${OpenAL_BINARY_DIR}/version.h -P ${OpenAL_SOURCE_DIR}/version.cmake
1226 COMMAND ${CMAKE_COMMAND} -E touch "${OpenAL_BINARY_DIR}/version_witness.txt"
1227 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1228 MAIN_DEPENDENCY "${OpenAL_SOURCE_DIR}/version.h.in"
1229 DEPENDS "${GIT_DIR}/index" "${OpenAL_SOURCE_DIR}/version.cmake"
1233 add_custom_target(build_version DEPENDS "${OpenAL_BINARY_DIR}/version_witness.txt")
1235 set(GIT_BRANCH "UNKNOWN")
1236 set(GIT_COMMIT_HASH "unknown")
1238 "${OpenAL_SOURCE_DIR}/version.h.in"
1239 "${OpenAL_BINARY_DIR}/version.h")
1243 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON)
1244 if(ALSOFT_EMBED_HRTF_DATA)
1245 macro(make_hrtf_header FILENAME VARNAME)
1246 set(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}")
1247 set(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.txt")
1249 add_custom_command(OUTPUT "${outfile}"
1250 COMMAND ${CMAKE_COMMAND} -D "INPUT_FILE=${infile}" -D "OUTPUT_FILE=${outfile}"
1251 -P "${CMAKE_MODULE_PATH}/bin2h.script.cmake"
1252 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1253 DEPENDS "${infile}" "${CMAKE_MODULE_PATH}/bin2h.script.cmake"
1256 set(ALC_OBJS ${ALC_OBJS} "${outfile}")
1259 make_hrtf_header("Default HRTF.mhr" "default_hrtf")
1264 find_package(MySOFA)
1265 if(NOT ALSOFT_NO_CONFIG_UTIL)
1266 find_package(Qt5Widgets QUIET)
1267 if(NOT Qt5Widgets_FOUND)
1268 message(STATUS "Could NOT find Qt5Widgets")
1272 if(ALSOFT_UTILS OR ALSOFT_EXAMPLES)
1273 find_package(SndFile)
1275 find_package(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1280 set(LIBNAME "openal")
1282 set(LIBNAME "OpenAL32")
1285 # Needed for openal.pc.in
1286 set(prefix ${CMAKE_INSTALL_PREFIX})
1287 set(exec_prefix "\${prefix}")
1288 set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
1289 set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
1290 set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
1291 set(PACKAGE_VERSION "${LIB_VERSION}")
1292 set(PKG_CONFIG_CFLAGS )
1293 set(PKG_CONFIG_PRIVATE_LIBS )
1294 if(LIBTYPE STREQUAL "STATIC")
1295 set(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC)
1296 foreach(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1297 # If this is already a linker flag, or is a full path+file, add it
1298 # as-is. If it's an SDL2 target, add the link flag for it. Otherwise,
1299 # it's a name intended to be dressed as -lname.
1300 if(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}")
1301 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}")
1302 elseif(FLAG MATCHES "^SDL2::SDL2")
1303 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -lSDL2")
1305 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}")
1312 "${OpenAL_SOURCE_DIR}/config.h.in"
1313 "${OpenAL_BINARY_DIR}/config.h")
1315 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1316 "${OpenAL_BINARY_DIR}/openal.pc"
1320 add_library(alcommon STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS})
1321 target_include_directories(alcommon PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/include
1322 PUBLIC ${OpenAL_SOURCE_DIR}/common)
1323 target_compile_definitions(alcommon PRIVATE ${CPP_DEFS})
1324 target_compile_options(alcommon PRIVATE ${C_FLAGS})
1325 set_target_properties(alcommon PROPERTIES ${DEFAULT_TARGET_PROPS} POSITION_INDEPENDENT_CODE TRUE)
1329 set(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal.
1331 # Build main library
1332 if(LIBTYPE STREQUAL "STATIC")
1333 add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS})
1334 target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC)
1335 target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1338 # This option is for static linking OpenAL Soft into another project
1339 # that already defines the IDs. It is up to that project to ensure all
1340 # required IDs are defined.
1341 option(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
1342 if(ALSOFT_NO_UID_DEFS)
1343 target_compile_definitions(${IMPL_TARGET} PRIVATE AL_NO_UID_DEFS)
1347 set(RC_CONFIG resources/openal32.rc)
1348 if(WIN32 AND ALSOFT_BUILD_ROUTER)
1349 add_library(OpenAL SHARED
1356 target_compile_definitions(OpenAL
1357 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}"
1358 "AL_API=${EXPORT_DECL}" ${CPP_DEFS})
1359 target_compile_options(OpenAL PRIVATE ${C_FLAGS})
1360 target_link_libraries(OpenAL PRIVATE alcommon ${LINKER_FLAGS})
1361 target_include_directories(OpenAL
1363 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1364 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1366 ${OpenAL_SOURCE_DIR}/common
1367 ${OpenAL_BINARY_DIR}
1369 set_target_properties(OpenAL PROPERTIES ${DEFAULT_TARGET_PROPS} PREFIX ""
1370 OUTPUT_NAME ${LIBNAME})
1371 if(TARGET build_version)
1372 add_dependencies(OpenAL build_version)
1376 set(LIBNAME "soft_oal")
1377 set(IMPL_TARGET soft_oal)
1378 set(RC_CONFIG resources/soft_oal.rc)
1381 # !important: for osx framework public header works, the headers must be in
1383 set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h
1384 include/AL/efx-presets.h)
1386 add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS} ${RC_CONFIG}
1387 ${TARGET_PUBLIC_HEADERS})
1389 set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "")
1391 target_link_libraries(${IMPL_TARGET} PRIVATE alcommon ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1394 set(ALSOFT_CPPWINRT_VERSION "2.0.230706.1" CACHE STRING "The soft-oal default cppwinrt version")
1396 find_program(NUGET_EXE NAMES nuget)
1398 message("NUGET.EXE not found.")
1399 message(FATAL_ERROR "Please install this executable, and run CMake again.")
1402 exec_program(${NUGET_EXE}
1403 ARGS install "Microsoft.Windows.CppWinRT" -Version ${ALSOFT_CPPWINRT_VERSION} -ExcludeVersion -OutputDirectory "\"${CMAKE_BINARY_DIR}/packages\"")
1405 set_target_properties(${IMPL_TARGET} PROPERTIES
1406 VS_PROJECT_IMPORT ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.props
1408 target_link_libraries(${IMPL_TARGET} PRIVATE ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets)
1411 if(NOT WIN32 AND NOT APPLE)
1412 # FIXME: This doesn't put a dependency on the version script. Changing
1413 # the version script will not cause a relink as it should.
1414 target_link_options(${IMPL_TARGET} PRIVATE
1415 "-Wl,--version-script=${OpenAL_SOURCE_DIR}/libopenal.version")
1418 if(APPLE AND ALSOFT_OSX_FRAMEWORK)
1419 # Sets framework name to soft_oal to avoid ambiguity with the system OpenAL.framework
1420 set(LIBNAME "soft_oal")
1422 execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
1424 OUTPUT_VARIABLE BUNDLE_VERSION
1425 OUTPUT_STRIP_TRAILING_WHITESPACE)
1427 set(BUNDLE_VERSION 1)
1430 # Build: Fix rpath in iOS shared libraries
1431 # If this flag is not set, the final dylib binary ld path will be
1432 # /User/xxx/*/soft_oal.framework/soft_oal, which can't be loaded by iOS devices.
1433 # See also: https://github.com/libjpeg-turbo/libjpeg-turbo/commit/c80ddef7a4ce21ace9e3ca0fd190d320cc8cdaeb
1434 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
1435 set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
1438 set_target_properties(${IMPL_TARGET} PROPERTIES
1441 MACOSX_FRAMEWORK_NAME "${IMPL_TARGET}"
1442 MACOSX_FRAMEWORK_IDENTIFIER "org.openal-soft.openal"
1443 MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${LIB_VERSION}"
1444 MACOSX_FRAMEWORK_BUNDLE_VERSION "${BUNDLE_VERSION}"
1445 XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
1446 XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
1447 XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
1448 PUBLIC_HEADER "${TARGET_PUBLIC_HEADERS}"
1453 target_include_directories(${IMPL_TARGET}
1455 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1457 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include/AL>
1458 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1459 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/AL>
1462 ${OpenAL_BINARY_DIR}
1463 ${OpenAL_SOURCE_DIR}
1464 ${OpenAL_SOURCE_DIR}/common
1467 set_target_properties(${IMPL_TARGET} PROPERTIES ${DEFAULT_TARGET_PROPS}
1468 OUTPUT_NAME ${LIBNAME}
1469 VERSION ${LIB_VERSION}
1470 SOVERSION ${LIB_MAJOR_VERSION}
1472 target_compile_definitions(${IMPL_TARGET}
1473 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}"
1475 target_compile_options(${IMPL_TARGET} PRIVATE ${C_FLAGS})
1477 if(TARGET build_version)
1478 add_dependencies(${IMPL_TARGET} build_version)
1481 if(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
1482 find_program(SED_EXECUTABLE NAMES sed DOC "sed executable")
1483 if(NOT SED_EXECUTABLE OR NOT CMAKE_DLLTOOL)
1485 if(NOT SED_EXECUTABLE)
1486 message(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1488 if(NOT CMAKE_DLLTOOL)
1489 message(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1492 target_link_options(OpenAL PRIVATE "-Wl,--output-def,${PROJECT_BINARY_DIR}/OpenAL32.def")
1493 add_custom_command(TARGET OpenAL POST_BUILD
1494 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
1495 COMMAND "${CMAKE_DLLTOOL}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
1496 # Technically OpenAL32.def was created by the build, but cmake
1497 # doesn't recognize it due to -Wl,--output-def,OpenAL32.def being
1498 # manually specified. But declaring the file here allows it to be
1499 # properly cleaned, e.g. during make clean.
1500 BYPRODUCTS OpenAL32.def OpenAL32.lib
1501 COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
1509 message(STATUS "Building DLL router")
1513 message(STATUS "Building OpenAL with support for the following backends:")
1514 message(STATUS " ${BACKENDS}")
1516 message(STATUS "Building with support for CPU extensions:")
1517 message(STATUS " ${CPU_EXTS}")
1520 message(STATUS "Building with SSE${FPMATH_SET} codegen")
1524 message(STATUS "Building with UWP support")
1528 message(STATUS "Building with legacy EAX extension support")
1532 if(ALSOFT_EMBED_HRTF_DATA)
1533 message(STATUS "Embedding HRTF datasets")
1537 # An alias for sub-project builds
1538 add_library(OpenAL::OpenAL ALIAS OpenAL)
1540 # Install main library
1542 configure_package_config_file(OpenALConfig.cmake.in OpenALConfig.cmake
1543 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL)
1544 install(TARGETS OpenAL EXPORT OpenAL
1545 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1546 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1547 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1548 FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
1549 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL)
1550 export(TARGETS OpenAL
1552 FILE OpenALTargets.cmake)
1553 install(EXPORT OpenAL
1554 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
1556 FILE OpenALTargets.cmake)
1557 install(DIRECTORY include/AL
1558 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
1559 install(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1560 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1561 install(FILES "${OpenAL_BINARY_DIR}/OpenALConfig.cmake"
1562 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL")
1564 install(TARGETS soft_oal
1565 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1567 message(STATUS "Installing library and headers")
1569 message(STATUS "NOT installing library and headers")
1572 if(ALSOFT_INSTALL_CONFIG)
1573 install(FILES alsoftrc.sample
1574 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1575 message(STATUS "Installing sample configuration")
1578 if(ALSOFT_INSTALL_HRTF_DATA)
1579 install(DIRECTORY hrtf
1580 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1581 message(STATUS "Installing HRTF data files")
1584 if(ALSOFT_INSTALL_AMBDEC_PRESETS)
1585 install(DIRECTORY presets
1586 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1587 message(STATUS "Installing AmbDec presets")
1593 set(UNICODE_FLAG ${UNICODE_FLAG} -municode)
1595 set(EXTRA_INSTALLS )
1597 add_executable(openal-info utils/openal-info.c)
1598 target_include_directories(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
1599 target_compile_options(openal-info PRIVATE ${C_FLAGS})
1600 target_link_libraries(openal-info PRIVATE ${LINKER_FLAGS} OpenAL ${UNICODE_FLAG})
1601 set_target_properties(openal-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1602 if(ALSOFT_INSTALL_EXAMPLES)
1603 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} openal-info)
1607 add_executable(uhjdecoder utils/uhjdecoder.cpp)
1608 target_compile_definitions(uhjdecoder PRIVATE ${CPP_DEFS})
1609 target_include_directories(uhjdecoder
1610 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1611 target_compile_options(uhjdecoder PRIVATE ${C_FLAGS})
1612 target_link_libraries(uhjdecoder PUBLIC alcommon
1613 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1614 set_target_properties(uhjdecoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1616 add_executable(uhjencoder utils/uhjencoder.cpp)
1617 target_compile_definitions(uhjencoder PRIVATE ${CPP_DEFS})
1618 target_include_directories(uhjencoder
1619 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1620 target_compile_options(uhjencoder PRIVATE ${C_FLAGS})
1621 target_link_libraries(uhjencoder PUBLIC alcommon
1622 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1623 set_target_properties(uhjencoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1627 set(SOFA_SUPPORT_SRCS
1628 utils/sofa-support.cpp
1629 utils/sofa-support.h)
1630 add_library(sofa-support STATIC EXCLUDE_FROM_ALL ${SOFA_SUPPORT_SRCS})
1631 target_compile_definitions(sofa-support PRIVATE ${CPP_DEFS})
1632 target_include_directories(sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/common)
1633 target_compile_options(sofa-support PRIVATE ${C_FLAGS})
1634 target_link_libraries(sofa-support PUBLIC alcommon MySOFA::MySOFA PRIVATE ${LINKER_FLAGS})
1635 set_target_properties(sofa-support PROPERTIES ${DEFAULT_TARGET_PROPS})
1638 utils/makemhr/loaddef.cpp
1639 utils/makemhr/loaddef.h
1640 utils/makemhr/loadsofa.cpp
1641 utils/makemhr/loadsofa.h
1642 utils/makemhr/makemhr.cpp
1643 utils/makemhr/makemhr.h)
1644 add_executable(makemhr ${MAKEMHR_SRCS})
1645 target_compile_definitions(makemhr PRIVATE ${CPP_DEFS})
1646 target_include_directories(makemhr
1647 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils)
1648 target_compile_options(makemhr PRIVATE ${C_FLAGS})
1649 target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} sofa-support ${UNICODE_FLAG})
1650 set_target_properties(makemhr PROPERTIES ${DEFAULT_TARGET_PROPS})
1651 if(ALSOFT_INSTALL_EXAMPLES)
1652 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} makemhr)
1655 set(SOFAINFO_SRCS utils/sofa-info.cpp)
1656 add_executable(sofa-info ${SOFAINFO_SRCS})
1657 target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS})
1658 target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/utils)
1659 target_compile_options(sofa-info PRIVATE ${C_FLAGS})
1660 target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} sofa-support ${UNICODE_FLAG})
1661 set_target_properties(sofa-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1663 message(STATUS "Building utility programs")
1665 if(NOT ALSOFT_NO_CONFIG_UTIL)
1666 add_subdirectory(utils/alsoft-config)
1672 # Add a static library with common functions used by multiple example targets
1673 add_library(al-excommon STATIC EXCLUDE_FROM_ALL
1674 examples/common/alhelpers.c
1675 examples/common/alhelpers.h)
1676 target_compile_definitions(al-excommon PUBLIC ${CPP_DEFS})
1677 target_include_directories(al-excommon PUBLIC ${OpenAL_SOURCE_DIR}/common)
1678 target_compile_options(al-excommon PUBLIC ${C_FLAGS})
1679 target_link_libraries(al-excommon PUBLIC OpenAL PRIVATE ${RT_LIB})
1680 set_target_properties(al-excommon PROPERTIES ${DEFAULT_TARGET_PROPS})
1683 add_executable(altonegen examples/altonegen.c)
1684 target_link_libraries(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} al-excommon ${UNICODE_FLAG})
1685 set_target_properties(altonegen PROPERTIES ${DEFAULT_TARGET_PROPS})
1687 add_executable(alrecord examples/alrecord.c)
1688 target_link_libraries(alrecord PRIVATE ${LINKER_FLAGS} al-excommon ${UNICODE_FLAG})
1689 set_target_properties(alrecord PROPERTIES ${DEFAULT_TARGET_PROPS})
1691 if(ALSOFT_INSTALL_EXAMPLES)
1692 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} altonegen alrecord)
1695 message(STATUS "Building example programs")
1698 add_executable(alplay examples/alplay.c)
1699 target_link_libraries(alplay PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1701 set_target_properties(alplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1703 add_executable(alstream examples/alstream.c)
1704 target_link_libraries(alstream PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1706 set_target_properties(alstream PROPERTIES ${DEFAULT_TARGET_PROPS})
1708 add_executable(alreverb examples/alreverb.c)
1709 target_link_libraries(alreverb PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1711 set_target_properties(alreverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1713 add_executable(almultireverb examples/almultireverb.c)
1714 target_link_libraries(almultireverb
1715 PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon ${MATH_LIB} ${UNICODE_FLAG})
1716 set_target_properties(almultireverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1718 add_executable(allatency examples/allatency.c)
1719 target_link_libraries(allatency PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1721 set_target_properties(allatency PROPERTIES ${DEFAULT_TARGET_PROPS})
1723 add_executable(alhrtf examples/alhrtf.c)
1724 target_link_libraries(alhrtf
1725 PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon ${MATH_LIB} ${UNICODE_FLAG})
1726 set_target_properties(alhrtf PROPERTIES ${DEFAULT_TARGET_PROPS})
1728 add_executable(alstreamcb examples/alstreamcb.cpp)
1729 target_link_libraries(alstreamcb PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1731 set_target_properties(alstreamcb PROPERTIES ${DEFAULT_TARGET_PROPS})
1733 add_executable(aldirect examples/aldirect.cpp)
1734 target_link_libraries(aldirect PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1736 set_target_properties(aldirect PROPERTIES ${DEFAULT_TARGET_PROPS})
1738 add_executable(alconvolve examples/alconvolve.c)
1739 target_link_libraries(alconvolve PRIVATE ${LINKER_FLAGS} alcommon SndFile::SndFile
1740 al-excommon ${UNICODE_FLAG})
1741 set_target_properties(alconvolve PROPERTIES ${DEFAULT_TARGET_PROPS})
1743 if(ALSOFT_INSTALL_EXAMPLES)
1744 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alplay alstream alreverb almultireverb allatency
1748 message(STATUS "Building SndFile example programs")
1752 add_executable(alloopback examples/alloopback.c)
1753 target_link_libraries(alloopback
1754 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 al-excommon ${MATH_LIB})
1755 set_target_properties(alloopback PROPERTIES ${DEFAULT_TARGET_PROPS})
1757 if(ALSOFT_INSTALL_EXAMPLES)
1758 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alloopback)
1761 message(STATUS "Building SDL example programs")
1766 if(AVFORMAT_VERSION VERSION_LESS "59.27.100")
1767 message(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 59.27.100)")
1770 if(AVCODEC_VERSION VERSION_LESS "59.37.100")
1771 message(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 59.37.100)")
1774 if(AVUTIL_VERSION VERSION_LESS "57.28.100")
1775 message(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 57.28.100)")
1778 if(SWSCALE_VERSION VERSION_LESS "6.7.100")
1779 message(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 6.7.100)")
1782 if(SWRESAMPLE_VERSION VERSION_LESS "4.7.100")
1783 message(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 4.7.100)")
1788 add_executable(alffplay examples/alffplay.cpp)
1789 target_include_directories(alffplay PRIVATE ${FFMPEG_INCLUDE_DIRS})
1790 target_link_libraries(alffplay
1791 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 ${FFMPEG_LIBRARIES} al-excommon)
1792 set_target_properties(alffplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1794 if(ALSOFT_INSTALL_EXAMPLES)
1795 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alffplay)
1797 message(STATUS "Building SDL+FFmpeg example programs")
1804 add_subdirectory(tests)
1808 install(TARGETS ${EXTRA_INSTALLS}
1809 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1810 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
1811 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1812 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})