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 "24")
185 set(LIB_REVISION "0")
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 # NOTE: _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR is temporary. When building on
231 # VS 2022 17.10 or newer, but using an older runtime, mutexes can crash
232 # when locked. Ideally the runtime should be updated on the system, but
233 # until the update becomes more widespread, this helps avoid some pain
235 set(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
236 check_cxx_compiler_flag(/permissive- HAVE_PERMISSIVE_SWITCH)
237 if(HAVE_PERMISSIVE_SWITCH)
238 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:/permissive->)
240 set(C_FLAGS ${C_FLAGS} /W4 /w14640 /wd4065 /wd4127 /wd4268 /wd4324 /wd5030 /wd5051
241 $<$<COMPILE_LANGUAGE:CXX>:/EHsc>)
244 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
246 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
249 message(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
252 option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
253 if(FORCE_STATIC_VCRT)
255 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
256 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
257 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
258 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
259 if(${flag_var} MATCHES "/MD")
260 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
265 set(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align
267 $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>)
269 check_cxx_compiler_flag(-Wno-c++20-attribute-extensions HAVE_WNO_CXX20_ATTR_EXT)
270 if(HAVE_WNO_CXX20_ATTR_EXT)
271 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-attribute-extensions>)
273 check_cxx_compiler_flag(-Wno-c++20-extensions HAVE_WNO_CXX20_EXT)
274 if(HAVE_WNO_CXX20_EXT)
275 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-extensions>)
279 check_cxx_compiler_flag(-Wno-interference-size HAVE_WNO_INTERFERENCE_SIZE)
280 if(HAVE_WNO_INTERFERENCE_SIZE)
281 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>)
285 set(C_FLAGS ${C_FLAGS} -Werror)
287 set(C_FLAGS ${C_FLAGS} -Werror=undef)
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)
868 if(WIN32 OR HAVE_DLFCN_H)
870 macro(ADD_BACKEND_LIBS _LIBS)
873 set(IS_LINKED " (linked)")
874 macro(ADD_BACKEND_LIBS _LIBS)
875 set(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
880 set(ALC_OBJS ${ALC_OBJS}
881 alc/backends/base.cpp
883 # Default backends, always available
884 alc/backends/loopback.cpp
885 alc/backends/loopback.h
886 alc/backends/null.cpp
890 # Check PipeWire backend
891 option(ALSOFT_BACKEND_PIPEWIRE "Enable PipeWire backend" ON)
892 option(ALSOFT_REQUIRE_PIPEWIRE "Require PipeWire backend" OFF)
893 if(ALSOFT_BACKEND_PIPEWIRE AND PkgConfig_FOUND)
894 pkg_check_modules(PIPEWIRE libpipewire-0.3>=0.3.23)
897 set(BACKENDS "${BACKENDS} PipeWire${IS_LINKED},")
898 set(ALC_OBJS ${ALC_OBJS} alc/backends/pipewire.cpp alc/backends/pipewire.h)
899 add_backend_libs(${PIPEWIRE_LIBRARIES})
900 set(INC_PATHS ${INC_PATHS} ${PIPEWIRE_INCLUDE_DIRS})
903 if(ALSOFT_REQUIRE_PIPEWIRE AND NOT HAVE_PIPEWIRE)
904 message(FATAL_ERROR "Failed to enable required PipeWire backend")
907 # Check PulseAudio backend
908 option(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
909 option(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
910 if(ALSOFT_BACKEND_PULSEAUDIO)
911 find_package(PulseAudio)
913 set(HAVE_PULSEAUDIO 1)
914 set(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
915 set(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h)
916 add_backend_libs(${PULSEAUDIO_LIBRARY})
917 set(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIR})
920 if(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
921 message(FATAL_ERROR "Failed to enable required PulseAudio backend")
926 option(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
927 option(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
928 if(ALSOFT_BACKEND_ALSA)
932 set(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
933 set(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h)
934 add_backend_libs(${ALSA_LIBRARIES})
935 set(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
940 option(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
941 option(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
942 if(ALSOFT_BACKEND_OSS)
946 set(BACKENDS "${BACKENDS} OSS,")
947 set(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h)
949 set(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
951 set(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
955 # Check Solaris backend
956 option(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
957 option(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
958 if(ALSOFT_BACKEND_SOLARIS)
959 find_package(AudioIO)
962 set(BACKENDS "${BACKENDS} Solaris,")
963 set(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h)
964 set(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
968 # Check SndIO backend (disabled by default on non-BSDs)
970 option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
972 option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" OFF)
974 option(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
975 if(ALSOFT_BACKEND_SNDIO)
979 set(BACKENDS "${BACKENDS} SndIO (linked),")
980 set(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h)
981 set(EXTRA_LIBS ${SNDIO_LIBRARIES} ${EXTRA_LIBS})
982 set(INC_PATHS ${INC_PATHS} ${SNDIO_INCLUDE_DIRS})
986 if(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
987 message(FATAL_ERROR "Failed to enable required ALSA backend")
989 if(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
990 message(FATAL_ERROR "Failed to enable required OSS backend")
992 if(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
993 message(FATAL_ERROR "Failed to enable required Solaris backend")
995 if(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
996 message(FATAL_ERROR "Failed to enable required SndIO backend")
999 # Check Windows-only backends
1002 # Check MMSystem backend
1003 option(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
1004 option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
1005 if(ALSOFT_BACKEND_WINMM)
1007 set(BACKENDS "${BACKENDS} WinMM,")
1008 set(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h)
1009 # There doesn't seem to be good way to search for winmm.lib for MSVC.
1010 # find_library doesn't find it without being told to look in a specific
1011 # place in the WindowsSDK, but it links anyway. If there ends up being
1012 # Windows targets without this, another means to detect it is needed.
1013 set(EXTRA_LIBS winmm ${EXTRA_LIBS})
1016 # Check DSound backend
1017 option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
1018 option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
1019 if(ALSOFT_BACKEND_DSOUND)
1020 check_include_file(dsound.h HAVE_DSOUND_H)
1022 find_path(DSOUND_INCLUDE_DIR NAMES "dsound.h"
1023 PATHS "${DXSDK_DIR}" PATH_SUFFIXES include
1024 DOC "The DirectSound include directory")
1026 if(HAVE_DSOUND_H OR DSOUND_INCLUDE_DIR)
1028 set(BACKENDS "${BACKENDS} DirectSound,")
1029 set(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h)
1031 if(NOT HAVE_DSOUND_H)
1032 set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR})
1038 # Check for WASAPI backend
1039 option(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
1040 option(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
1041 if(ALSOFT_BACKEND_WASAPI)
1042 check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
1043 if(HAVE_MMDEVICEAPI_H)
1045 set(BACKENDS "${BACKENDS} WASAPI,")
1046 set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h)
1049 set(EXTRA_LIBS avrt ${EXTRA_LIBS})
1054 option(ALSOFT_BACKEND_OTHERIO "Enable OtherIO backend" OFF)
1055 option(ALSOFT_REQUIRE_OTHERIO "Require OtherIO backend" OFF)
1056 if(ALSOFT_BACKEND_OTHERIO)
1058 set(BACKENDS "${BACKENDS} OtherIO,")
1059 set(ALC_OBJS ${ALC_OBJS} alc/backends/otherio.cpp alc/backends/otherio.h)
1062 if(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
1063 message(FATAL_ERROR "Failed to enable required WinMM backend")
1065 if(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
1066 message(FATAL_ERROR "Failed to enable required DSound backend")
1068 if(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
1069 message(FATAL_ERROR "Failed to enable required WASAPI backend")
1071 if(ALSOFT_REQUIRE_OTHERIO AND NOT HAVE_OTHERIO)
1072 message(FATAL_ERROR "Failed to enable required OtherIO backend")
1075 # Check JACK backend
1076 option(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
1077 option(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
1078 if(ALSOFT_BACKEND_JACK)
1082 set(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
1083 set(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h)
1084 add_backend_libs(${JACK_LIBRARIES})
1085 set(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS})
1088 if(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1089 message(FATAL_ERROR "Failed to enable required JACK backend")
1092 # Check CoreAudio backend
1093 option(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1094 option(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1095 if(ALSOFT_BACKEND_COREAUDIO)
1096 find_library(COREAUDIO_FRAMEWORK NAMES CoreAudio)
1097 find_path(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h)
1098 if(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR)
1099 set(HAVE_COREAUDIO 1)
1100 set(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h)
1101 set(BACKENDS "${BACKENDS} CoreAudio,")
1103 set(EXTRA_LIBS -Wl,-framework,CoreAudio ${EXTRA_LIBS})
1104 if(CMAKE_SYSTEM_NAME MATCHES "^(iOS|tvOS)$")
1105 find_library(COREFOUNDATION_FRAMEWORK NAMES CoreFoundation)
1106 if(COREFOUNDATION_FRAMEWORK)
1107 set(EXTRA_LIBS -Wl,-framework,CoreFoundation ${EXTRA_LIBS})
1110 set(EXTRA_LIBS -Wl,-framework,AudioUnit,-framework,ApplicationServices ${EXTRA_LIBS})
1113 # Some versions of OSX may need the AudioToolbox framework. Add it if
1115 find_library(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox)
1116 if(AUDIOTOOLBOX_LIBRARY)
1117 set(EXTRA_LIBS -Wl,-framework,AudioToolbox ${EXTRA_LIBS})
1120 set(INC_PATHS ${INC_PATHS} ${AUDIOUNIT_INCLUDE_DIR})
1123 if(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1124 message(FATAL_ERROR "Failed to enable required CoreAudio backend")
1127 # Check for Oboe (Android) backend
1128 option(ALSOFT_BACKEND_OBOE "Enable Oboe backend" ON)
1129 option(ALSOFT_REQUIRE_OBOE "Require Oboe backend" OFF)
1130 if(ALSOFT_BACKEND_OBOE)
1133 set(OBOE_SOURCE "" CACHE STRING "Source directory for Oboe.")
1135 add_subdirectory(${OBOE_SOURCE} ./oboe EXCLUDE_FROM_ALL)
1136 set(OBOE_TARGET oboe)
1138 find_package(oboe CONFIG)
1139 if(NOT TARGET oboe::oboe)
1142 if(TARGET oboe::oboe)
1143 set(OBOE_TARGET "oboe::oboe")
1150 set(ALC_OBJS ${ALC_OBJS} alc/backends/oboe.cpp alc/backends/oboe.h)
1151 set(BACKENDS "${BACKENDS} Oboe,")
1152 set(EXTRA_LIBS ${OBOE_TARGET} ${EXTRA_LIBS})
1155 if(ALSOFT_REQUIRE_OBOE AND NOT HAVE_OBOE)
1156 message(FATAL_ERROR "Failed to enable required Oboe backend")
1159 # Check for OpenSL (Android) backend
1160 option(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1161 option(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1162 if(ALSOFT_BACKEND_OPENSL)
1163 find_package(OpenSL)
1166 set(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h)
1167 set(BACKENDS "${BACKENDS} OpenSL,")
1168 set(EXTRA_LIBS ${OPENSL_LIBRARIES} ${EXTRA_LIBS})
1169 set(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS})
1172 if(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1173 message(FATAL_ERROR "Failed to enable required OpenSL backend")
1176 # Check PortAudio backend
1177 option(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
1178 option(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
1179 if(ALSOFT_BACKEND_PORTAUDIO)
1180 find_package(PortAudio)
1182 set(HAVE_PORTAUDIO 1)
1183 set(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
1184 set(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.h)
1185 add_backend_libs(${PORTAUDIO_LIBRARIES})
1186 set(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS})
1189 if(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
1190 message(FATAL_ERROR "Failed to enable required PortAudio backend")
1193 # Check for SDL2 backend
1194 # Off by default, since it adds a runtime dependency
1195 option(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF)
1196 option(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF)
1197 if(ALSOFT_BACKEND_SDL2)
1200 set(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h)
1201 set(BACKENDS "${BACKENDS} SDL2,")
1202 set(EXTRA_LIBS ${EXTRA_LIBS} SDL2::SDL2)
1204 message(STATUS "Could NOT find SDL2")
1207 if(ALSOFT_REQUIRE_SDL2 AND NOT HAVE_SDL2)
1208 message(FATAL_ERROR "Failed to enable required SDL2 backend")
1211 # Optionally enable the Wave Writer backend
1212 option(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1213 if(ALSOFT_BACKEND_WAVE)
1215 set(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h)
1216 set(BACKENDS "${BACKENDS} WaveFile,")
1219 # This is always available
1220 set(BACKENDS "${BACKENDS} Null")
1224 if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
1225 set(GIT_DIR "${OpenAL_SOURCE_DIR}/.git")
1227 # Check if this is a submodule, if it is then find the .git directory
1228 if(NOT IS_DIRECTORY "${OpenAL_SOURCE_DIR}/.git")
1229 file(READ ${GIT_DIR} submodule)
1230 string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule})
1231 string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
1232 get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
1233 get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
1236 # Get the current working branch and its latest abbreviated commit hash
1237 add_custom_command(OUTPUT "${OpenAL_BINARY_DIR}/version_witness.txt"
1238 BYPRODUCTS "${OpenAL_BINARY_DIR}/version.h"
1239 COMMAND ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D LIB_VERSION=${LIB_VERSION}
1240 -D LIB_VERSION_NUM=${LIB_VERSION_NUM} -D SRC=${OpenAL_SOURCE_DIR}/version.h.in
1241 -D DST=${OpenAL_BINARY_DIR}/version.h -P ${OpenAL_SOURCE_DIR}/version.cmake
1242 COMMAND ${CMAKE_COMMAND} -E touch "${OpenAL_BINARY_DIR}/version_witness.txt"
1243 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1244 MAIN_DEPENDENCY "${OpenAL_SOURCE_DIR}/version.h.in"
1245 DEPENDS "${GIT_DIR}/index" "${OpenAL_SOURCE_DIR}/version.cmake"
1249 add_custom_target(alsoft.build_version DEPENDS "${OpenAL_BINARY_DIR}/version_witness.txt")
1251 set(GIT_BRANCH "UNKNOWN")
1252 set(GIT_COMMIT_HASH "unknown")
1254 "${OpenAL_SOURCE_DIR}/version.h.in"
1255 "${OpenAL_BINARY_DIR}/version.h")
1259 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON)
1260 if(ALSOFT_EMBED_HRTF_DATA)
1261 macro(make_hrtf_header FILENAME VARNAME)
1262 set(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}")
1263 set(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.txt")
1265 add_custom_command(OUTPUT "${outfile}"
1266 COMMAND ${CMAKE_COMMAND} -D "INPUT_FILE=${infile}" -D "OUTPUT_FILE=${outfile}"
1267 -P "${CMAKE_MODULE_PATH}/bin2h.script.cmake"
1268 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1269 DEPENDS "${infile}" "${CMAKE_MODULE_PATH}/bin2h.script.cmake"
1272 set(ALC_OBJS ${ALC_OBJS} "${outfile}")
1275 make_hrtf_header("Default HRTF.mhr" "default_hrtf")
1280 find_package(MySOFA)
1281 if(NOT ALSOFT_NO_CONFIG_UTIL)
1282 find_package(Qt5Widgets QUIET)
1283 if(NOT Qt5Widgets_FOUND)
1284 message(STATUS "Could NOT find Qt5Widgets")
1288 if(ALSOFT_UTILS OR ALSOFT_EXAMPLES)
1289 find_package(SndFile)
1291 find_package(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1296 set(LIBNAME "openal")
1298 set(LIBNAME "OpenAL32")
1301 # Needed for openal.pc.in
1302 set(prefix ${CMAKE_INSTALL_PREFIX})
1303 set(exec_prefix "\${prefix}")
1304 set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
1305 set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
1306 set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
1307 set(PACKAGE_VERSION "${LIB_VERSION}")
1308 set(PKG_CONFIG_CFLAGS )
1309 set(PKG_CONFIG_PRIVATE_LIBS )
1310 if(LIBTYPE STREQUAL "STATIC")
1311 set(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC)
1312 foreach(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1313 # If this is already a linker flag, or is a full path+file, add it
1314 # as-is. If it's an SDL2 target, add the link flag for it. Otherwise,
1315 # it's a name intended to be dressed as -lname.
1316 if(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}")
1317 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}")
1318 elseif(FLAG MATCHES "^SDL2::SDL2")
1319 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -lSDL2")
1321 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}")
1328 "${OpenAL_SOURCE_DIR}/config.h.in"
1329 "${OpenAL_BINARY_DIR}/config.h")
1331 "${OpenAL_SOURCE_DIR}/config_backends.h.in"
1332 "${OpenAL_BINARY_DIR}/config_backends.h")
1334 "${OpenAL_SOURCE_DIR}/config_simd.h.in"
1335 "${OpenAL_BINARY_DIR}/config_simd.h")
1337 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1338 "${OpenAL_BINARY_DIR}/openal.pc"
1342 add_library(alsoft.common STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS})
1343 target_include_directories(alsoft.common PRIVATE ${OpenAL_SOURCE_DIR}/include
1344 PUBLIC ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1345 target_compile_definitions(alsoft.common PRIVATE ${CPP_DEFS})
1346 target_compile_options(alsoft.common PRIVATE ${C_FLAGS})
1347 set_target_properties(alsoft.common PROPERTIES ${DEFAULT_TARGET_PROPS} POSITION_INDEPENDENT_CODE TRUE)
1351 set(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal.
1353 # Build main library
1354 if(LIBTYPE STREQUAL "STATIC")
1355 add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS})
1356 target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC)
1357 target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1360 # This option is for static linking OpenAL Soft into another project
1361 # that already defines the IDs. It is up to that project to ensure all
1362 # required IDs are defined.
1363 option(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
1364 if(ALSOFT_NO_UID_DEFS)
1365 target_compile_definitions(${IMPL_TARGET} PRIVATE AL_NO_UID_DEFS)
1369 set(RC_CONFIG resources/openal32.rc)
1370 if(WIN32 AND ALSOFT_BUILD_ROUTER)
1371 add_library(OpenAL SHARED
1378 target_compile_definitions(OpenAL
1379 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}"
1380 "AL_API=${EXPORT_DECL}" ${CPP_DEFS})
1381 target_compile_options(OpenAL PRIVATE ${C_FLAGS})
1382 target_link_libraries(OpenAL PRIVATE alsoft.common ${LINKER_FLAGS})
1383 target_include_directories(OpenAL
1385 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1386 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1388 ${OpenAL_SOURCE_DIR}/common
1389 ${OpenAL_BINARY_DIR}
1391 set_target_properties(OpenAL PROPERTIES ${DEFAULT_TARGET_PROPS} PREFIX ""
1392 OUTPUT_NAME ${LIBNAME})
1393 if(TARGET alsoft.build_version)
1394 add_dependencies(OpenAL alsoft.build_version)
1398 set(LIBNAME "soft_oal")
1399 set(IMPL_TARGET soft_oal)
1400 set(RC_CONFIG resources/soft_oal.rc)
1403 # !important: for osx framework public header works, the headers must be in
1405 set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h
1406 include/AL/efx-presets.h)
1408 add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS} ${RC_CONFIG}
1409 ${TARGET_PUBLIC_HEADERS})
1411 set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "")
1413 target_link_libraries(${IMPL_TARGET} PRIVATE alsoft.common ${LINKER_FLAGS} ${EXTRA_LIBS}
1417 set(ALSOFT_CPPWINRT_VERSION "2.0.230706.1" CACHE STRING "The soft-oal default cppwinrt version")
1419 find_program(NUGET_EXE NAMES nuget)
1421 message("NUGET.EXE not found.")
1422 message(FATAL_ERROR "Please install this executable, and run CMake again.")
1425 exec_program(${NUGET_EXE}
1426 ARGS install "Microsoft.Windows.CppWinRT" -Version ${ALSOFT_CPPWINRT_VERSION} -ExcludeVersion -OutputDirectory "\"${CMAKE_BINARY_DIR}/packages\"")
1428 set_target_properties(${IMPL_TARGET} PROPERTIES
1429 VS_PROJECT_IMPORT ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.props
1431 target_link_libraries(${IMPL_TARGET} PRIVATE ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets)
1434 if(NOT WIN32 AND NOT APPLE)
1435 # FIXME: This doesn't put a dependency on the version script. Changing
1436 # the version script will not cause a relink as it should.
1437 target_link_options(${IMPL_TARGET} PRIVATE
1438 "-Wl,--version-script=${OpenAL_SOURCE_DIR}/libopenal.version")
1441 if(APPLE AND ALSOFT_OSX_FRAMEWORK)
1442 # Sets framework name to soft_oal to avoid ambiguity with the system OpenAL.framework
1443 set(LIBNAME "soft_oal")
1445 execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
1447 OUTPUT_VARIABLE BUNDLE_VERSION
1448 OUTPUT_STRIP_TRAILING_WHITESPACE)
1450 set(BUNDLE_VERSION 1)
1453 # Build: Fix rpath in iOS shared libraries
1454 # If this flag is not set, the final dylib binary ld path will be
1455 # /User/xxx/*/soft_oal.framework/soft_oal, which can't be loaded by iOS devices.
1456 # See also: https://github.com/libjpeg-turbo/libjpeg-turbo/commit/c80ddef7a4ce21ace9e3ca0fd190d320cc8cdaeb
1457 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
1458 set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
1461 set_target_properties(${IMPL_TARGET} PROPERTIES
1464 MACOSX_FRAMEWORK_NAME "${IMPL_TARGET}"
1465 MACOSX_FRAMEWORK_IDENTIFIER "org.openal-soft.openal"
1466 MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${LIB_VERSION}"
1467 MACOSX_FRAMEWORK_BUNDLE_VERSION "${BUNDLE_VERSION}"
1468 XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
1469 XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
1470 XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
1471 PUBLIC_HEADER "${TARGET_PUBLIC_HEADERS}"
1476 target_include_directories(${IMPL_TARGET}
1478 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1480 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include/AL>
1481 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1482 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/AL>
1485 ${OpenAL_BINARY_DIR}
1486 ${OpenAL_SOURCE_DIR}
1487 ${OpenAL_SOURCE_DIR}/common
1490 set_target_properties(${IMPL_TARGET} PROPERTIES ${DEFAULT_TARGET_PROPS}
1491 OUTPUT_NAME ${LIBNAME}
1492 VERSION ${LIB_VERSION}
1493 SOVERSION ${LIB_MAJOR_VERSION}
1495 target_compile_definitions(${IMPL_TARGET}
1496 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}"
1498 target_compile_options(${IMPL_TARGET} PRIVATE ${C_FLAGS})
1500 if(TARGET alsoft.build_version)
1501 add_dependencies(${IMPL_TARGET} alsoft.build_version)
1504 if(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
1505 find_program(SED_EXECUTABLE NAMES sed DOC "sed executable")
1506 if(NOT SED_EXECUTABLE OR NOT CMAKE_DLLTOOL)
1508 if(NOT SED_EXECUTABLE)
1509 message(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1511 if(NOT CMAKE_DLLTOOL)
1512 message(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1515 target_link_options(OpenAL PRIVATE "-Wl,--output-def,${PROJECT_BINARY_DIR}/OpenAL32.def")
1516 add_custom_command(TARGET OpenAL POST_BUILD
1517 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
1518 COMMAND "${CMAKE_DLLTOOL}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
1519 # Technically OpenAL32.def was created by the build, but cmake
1520 # doesn't recognize it due to -Wl,--output-def,OpenAL32.def being
1521 # manually specified. But declaring the file here allows it to be
1522 # properly cleaned, e.g. during make clean.
1523 BYPRODUCTS OpenAL32.def OpenAL32.lib
1524 COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
1532 message(STATUS "Building DLL router")
1536 message(STATUS "Building OpenAL with support for the following backends:")
1537 message(STATUS " ${BACKENDS}")
1539 message(STATUS "Building with support for CPU extensions:")
1540 message(STATUS " ${CPU_EXTS}")
1543 message(STATUS "Building with SSE${FPMATH_SET} codegen")
1547 message(STATUS "Building with UWP support")
1551 message(STATUS "Building with legacy EAX extension support")
1555 if(ALSOFT_EMBED_HRTF_DATA)
1556 message(STATUS "Embedding HRTF datasets")
1560 # An alias for sub-project builds
1561 add_library(OpenAL::OpenAL ALIAS OpenAL)
1563 # Install main library
1565 configure_package_config_file(OpenALConfig.cmake.in OpenALConfig.cmake
1566 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL)
1567 install(TARGETS OpenAL EXPORT OpenAL
1568 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1569 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1570 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1571 FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
1572 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL)
1573 export(TARGETS OpenAL
1575 FILE OpenALTargets.cmake)
1576 install(EXPORT OpenAL
1577 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
1579 FILE OpenALTargets.cmake)
1580 install(DIRECTORY include/AL
1581 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
1582 install(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1583 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1584 install(FILES "${OpenAL_BINARY_DIR}/OpenALConfig.cmake"
1585 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL")
1587 install(TARGETS soft_oal
1588 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1590 message(STATUS "Installing library and headers")
1592 message(STATUS "NOT installing library and headers")
1595 if(ALSOFT_INSTALL_CONFIG)
1596 install(FILES alsoftrc.sample
1597 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1598 message(STATUS "Installing sample configuration")
1601 if(ALSOFT_INSTALL_HRTF_DATA)
1602 install(DIRECTORY hrtf
1603 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1604 message(STATUS "Installing HRTF data files")
1607 if(ALSOFT_INSTALL_AMBDEC_PRESETS)
1608 install(DIRECTORY presets
1609 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1610 message(STATUS "Installing AmbDec presets")
1616 set(UNICODE_FLAG ${UNICODE_FLAG} -municode)
1618 set(EXTRA_INSTALLS )
1620 add_executable(openal-info utils/openal-info.c)
1621 target_include_directories(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
1622 target_compile_options(openal-info PRIVATE ${C_FLAGS})
1623 target_link_libraries(openal-info PRIVATE ${LINKER_FLAGS} OpenAL ${UNICODE_FLAG})
1624 set_target_properties(openal-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1625 if(ALSOFT_INSTALL_EXAMPLES)
1626 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} openal-info)
1630 add_executable(uhjdecoder utils/uhjdecoder.cpp)
1631 target_compile_definitions(uhjdecoder PRIVATE ${CPP_DEFS})
1632 target_include_directories(uhjdecoder
1633 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1634 target_compile_options(uhjdecoder PRIVATE ${C_FLAGS})
1635 target_link_libraries(uhjdecoder PUBLIC alsoft.common
1636 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1637 set_target_properties(uhjdecoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1639 add_executable(uhjencoder utils/uhjencoder.cpp)
1640 target_compile_definitions(uhjencoder PRIVATE ${CPP_DEFS})
1641 target_include_directories(uhjencoder
1642 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1643 target_compile_options(uhjencoder PRIVATE ${C_FLAGS})
1644 target_link_libraries(uhjencoder PUBLIC alsoft.common
1645 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1646 set_target_properties(uhjencoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1650 set(SOFA_SUPPORT_SRCS
1651 utils/sofa-support.cpp
1652 utils/sofa-support.h)
1653 add_library(alsoft.sofa-support STATIC EXCLUDE_FROM_ALL ${SOFA_SUPPORT_SRCS})
1654 target_compile_definitions(alsoft.sofa-support PRIVATE ${CPP_DEFS})
1655 target_include_directories(alsoft.sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/common)
1656 target_compile_options(alsoft.sofa-support PRIVATE ${C_FLAGS})
1657 target_link_libraries(alsoft.sofa-support PUBLIC alsoft.common MySOFA::MySOFA
1658 PRIVATE ${LINKER_FLAGS})
1659 set_target_properties(alsoft.sofa-support PROPERTIES ${DEFAULT_TARGET_PROPS})
1662 utils/makemhr/loaddef.cpp
1663 utils/makemhr/loaddef.h
1664 utils/makemhr/loadsofa.cpp
1665 utils/makemhr/loadsofa.h
1666 utils/makemhr/makemhr.cpp
1667 utils/makemhr/makemhr.h)
1668 add_executable(makemhr ${MAKEMHR_SRCS})
1669 target_compile_definitions(makemhr PRIVATE ${CPP_DEFS})
1670 target_include_directories(makemhr
1671 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils)
1672 target_compile_options(makemhr PRIVATE ${C_FLAGS})
1673 target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} alsoft.sofa-support ${UNICODE_FLAG})
1674 set_target_properties(makemhr PROPERTIES ${DEFAULT_TARGET_PROPS})
1675 if(ALSOFT_INSTALL_EXAMPLES)
1676 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} makemhr)
1679 set(SOFAINFO_SRCS utils/sofa-info.cpp)
1680 add_executable(sofa-info ${SOFAINFO_SRCS})
1681 target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS})
1682 target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/utils)
1683 target_compile_options(sofa-info PRIVATE ${C_FLAGS})
1684 target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} alsoft.sofa-support
1686 set_target_properties(sofa-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1688 message(STATUS "Building utility programs")
1690 if(NOT ALSOFT_NO_CONFIG_UTIL)
1691 add_subdirectory(utils/alsoft-config)
1697 # Add a static library with common functions used by multiple example targets
1698 add_library(alsoft.excommon STATIC EXCLUDE_FROM_ALL
1699 examples/common/alhelpers.c
1700 examples/common/alhelpers.h)
1701 target_compile_definitions(alsoft.excommon PUBLIC ${CPP_DEFS})
1702 target_include_directories(alsoft.excommon PUBLIC ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1703 target_compile_options(alsoft.excommon PUBLIC ${C_FLAGS})
1704 target_link_libraries(alsoft.excommon PUBLIC OpenAL PRIVATE ${RT_LIB})
1705 set_target_properties(alsoft.excommon PROPERTIES ${DEFAULT_TARGET_PROPS})
1708 add_executable(altonegen examples/altonegen.c)
1709 target_link_libraries(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} alsoft.excommon
1711 set_target_properties(altonegen PROPERTIES ${DEFAULT_TARGET_PROPS})
1713 add_executable(alrecord examples/alrecord.c)
1714 target_link_libraries(alrecord PRIVATE ${LINKER_FLAGS} alsoft.excommon ${UNICODE_FLAG})
1715 set_target_properties(alrecord PROPERTIES ${DEFAULT_TARGET_PROPS})
1717 add_executable(aldebug examples/aldebug.cpp)
1718 target_link_libraries(aldebug PRIVATE ${LINKER_FLAGS} alsoft.excommon ${UNICODE_FLAG})
1719 set_target_properties(aldebug PROPERTIES ${DEFAULT_TARGET_PROPS})
1721 add_executable(allafplay examples/allafplay.cpp)
1722 target_link_libraries(allafplay PRIVATE ${LINKER_FLAGS} alsoft.common alsoft.excommon
1724 set_target_properties(allafplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1726 if(ALSOFT_INSTALL_EXAMPLES)
1727 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} altonegen alrecord aldebug allafplay)
1730 message(STATUS "Building example programs")
1733 add_executable(alplay examples/alplay.c)
1734 target_link_libraries(alplay PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1736 set_target_properties(alplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1738 add_executable(alstream examples/alstream.c)
1739 target_link_libraries(alstream PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1741 set_target_properties(alstream PROPERTIES ${DEFAULT_TARGET_PROPS})
1743 add_executable(alreverb examples/alreverb.c)
1744 target_link_libraries(alreverb PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1746 set_target_properties(alreverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1748 add_executable(almultireverb examples/almultireverb.c)
1749 target_link_libraries(almultireverb
1750 PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${MATH_LIB} ${UNICODE_FLAG})
1751 set_target_properties(almultireverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1753 add_executable(allatency examples/allatency.c)
1754 target_link_libraries(allatency PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1756 set_target_properties(allatency PROPERTIES ${DEFAULT_TARGET_PROPS})
1758 add_executable(alhrtf examples/alhrtf.c)
1759 target_link_libraries(alhrtf
1760 PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${MATH_LIB} ${UNICODE_FLAG})
1761 set_target_properties(alhrtf PROPERTIES ${DEFAULT_TARGET_PROPS})
1763 add_executable(alstreamcb examples/alstreamcb.cpp)
1764 target_link_libraries(alstreamcb PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1766 set_target_properties(alstreamcb PROPERTIES ${DEFAULT_TARGET_PROPS})
1768 add_executable(aldirect examples/aldirect.cpp)
1769 target_link_libraries(aldirect PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1771 set_target_properties(aldirect PROPERTIES ${DEFAULT_TARGET_PROPS})
1773 add_executable(alconvolve examples/alconvolve.c)
1774 target_link_libraries(alconvolve PRIVATE ${LINKER_FLAGS} alsoft.common SndFile::SndFile
1775 alsoft.excommon ${UNICODE_FLAG})
1776 set_target_properties(alconvolve PROPERTIES ${DEFAULT_TARGET_PROPS})
1778 if(ALSOFT_INSTALL_EXAMPLES)
1779 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alplay alstream alreverb almultireverb allatency
1783 message(STATUS "Building SndFile example programs")
1787 add_executable(alloopback examples/alloopback.c)
1788 target_link_libraries(alloopback
1789 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 alsoft.excommon ${MATH_LIB})
1790 set_target_properties(alloopback PROPERTIES ${DEFAULT_TARGET_PROPS})
1792 if(ALSOFT_INSTALL_EXAMPLES)
1793 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alloopback)
1796 message(STATUS "Building SDL example programs")
1801 if(AVFORMAT_VERSION VERSION_LESS "59.27.100")
1802 message(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 59.27.100)")
1805 if(AVCODEC_VERSION VERSION_LESS "59.37.100")
1806 message(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 59.37.100)")
1809 if(AVUTIL_VERSION VERSION_LESS "57.28.100")
1810 message(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 57.28.100)")
1813 if(SWSCALE_VERSION VERSION_LESS "6.7.100")
1814 message(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 6.7.100)")
1817 if(SWRESAMPLE_VERSION VERSION_LESS "4.7.100")
1818 message(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 4.7.100)")
1823 add_executable(alffplay examples/alffplay.cpp)
1824 target_include_directories(alffplay PRIVATE ${FFMPEG_INCLUDE_DIRS})
1825 target_link_libraries(alffplay
1826 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 ${FFMPEG_LIBRARIES} alsoft.excommon)
1827 set_target_properties(alffplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1829 if(ALSOFT_INSTALL_EXAMPLES)
1830 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alffplay)
1832 message(STATUS "Building SDL+FFmpeg example programs")
1839 add_subdirectory(tests)
1843 install(TARGETS ${EXTRA_INSTALLS}
1844 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1845 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
1846 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1847 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})