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)
103 add_subdirectory(fmt-11.0.2)
105 option(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
107 option(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
109 option(ALSOFT_UTILS "Build utility programs" ON)
110 option(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
112 option(ALSOFT_EXAMPLES "Build example programs" ON)
113 option(ALSOFT_TESTS "Build test programs" OFF)
115 option(ALSOFT_INSTALL "Install main library" ON)
116 option(ALSOFT_INSTALL_CONFIG "Install alsoft.conf sample configuration file" ON)
117 option(ALSOFT_INSTALL_HRTF_DATA "Install HRTF data files" ON)
118 option(ALSOFT_INSTALL_AMBDEC_PRESETS "Install AmbDec preset files" ON)
119 option(ALSOFT_INSTALL_EXAMPLES "Install example programs (alplay, alstream, ...)" ON)
120 option(ALSOFT_INSTALL_UTILS "Install utility programs (openal-info, alsoft-config, ...)" ON)
121 option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON)
123 option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32})
125 option(ALSOFT_SEARCH_INSTALL_DATADIR "Search the installation data directory" OFF)
126 if(ALSOFT_SEARCH_INSTALL_DATADIR)
127 set(ALSOFT_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
130 if(DEFINED SHARE_INSTALL_DIR)
131 message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
132 set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
135 if(DEFINED LIB_SUFFIX)
136 message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
138 if(DEFINED ALSOFT_CONFIG)
139 message(WARNING "ALSOFT_CONFIG is deprecated. Use ALSOFT_INSTALL_CONFIG instead")
141 if(DEFINED ALSOFT_HRTF_DEFS)
142 message(WARNING "ALSOFT_HRTF_DEFS is deprecated. Use ALSOFT_INSTALL_HRTF_DATA instead")
144 if(DEFINED ALSOFT_AMBDEC_PRESETS)
145 message(WARNING "ALSOFT_AMBDEC_PRESETS is deprecated. Use ALSOFT_INSTALL_AMBDEC_PRESETS instead")
149 set(CPP_DEFS ) # C pre-processor, not C++
153 set(LINKER_FLAGS_DEBUG )
154 set(LINKER_FLAGS_RELEASE )
158 set(CPP_DEFS ${CPP_DEFS} _WIN32 NOMINMAX)
160 set(CPP_DEFS ${CPP_DEFS} __USE_MINGW_ANSI_STDIO)
163 option(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
165 option(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
168 option(ALSOFT_OSX_FRAMEWORK "Build as macOS framework" OFF)
172 # QNX's gcc do not uses /usr/include and /usr/lib paths by default
173 if("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
174 set(INC_PATHS ${INC_PATHS} /usr/include)
175 set(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
178 # When the library is built for static linking, apps should define
179 # AL_LIBTYPE_STATIC when including the AL headers.
184 set(LIB_MAJOR_VERSION "1")
185 set(LIB_MINOR_VERSION "24")
186 set(LIB_REVISION "0")
187 set(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
188 set(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0)
193 # Some systems erroneously require the __STDC_FORMAT_MACROS macro to be defined
194 # to get the fixed-width integer type formatter macros.
195 check_cxx_source_compiles("#include <cinttypes>
200 std::printf(\"%\" PRId64, i64);
202 HAVE_STDC_FORMAT_MACROS)
203 if(NOT HAVE_STDC_FORMAT_MACROS)
204 set(CPP_DEFS ${CPP_DEFS} __STDC_FORMAT_MACROS)
207 # Some systems may need libatomic for atomic functions to work
208 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
209 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
210 check_cxx_source_compiles("#include <atomic>
211 std::atomic<int> foo{0};
212 int main() { return foo.fetch_add(2); }"
214 if(NOT HAVE_LIBATOMIC)
215 set(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
217 set(EXTRA_LIBS atomic ${EXTRA_LIBS})
219 unset(OLD_REQUIRED_LIBRARIES)
222 # Include liblog for Android logging
223 check_library_exists(log __android_log_print "" HAVE_LIBLOG)
225 set(EXTRA_LIBS log ${EXTRA_LIBS})
226 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
231 # NOTE: _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR is temporary. When building on
232 # VS 2022 17.10 or newer, but using an older runtime, mutexes can crash
233 # when locked. Ideally the runtime should be updated on the system, but
234 # until the update becomes more widespread, this helps avoid some pain
236 set(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
237 check_cxx_compiler_flag(/permissive- HAVE_PERMISSIVE_SWITCH)
238 if(HAVE_PERMISSIVE_SWITCH)
239 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:/permissive->)
241 set(C_FLAGS ${C_FLAGS} /W4 /w14640 /wd4065 /wd4127 /wd4268 /wd4324 /wd5030 /wd5051
242 $<$<COMPILE_LANGUAGE:CXX>:/EHsc>)
245 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
247 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
250 message(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
253 option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
254 if(FORCE_STATIC_VCRT)
256 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
257 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
258 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
259 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
260 if(${flag_var} MATCHES "/MD")
261 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
266 set(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align
268 $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>)
270 check_cxx_compiler_flag(-Wno-c++20-attribute-extensions HAVE_WNO_CXX20_ATTR_EXT)
271 if(HAVE_WNO_CXX20_ATTR_EXT)
272 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-attribute-extensions>)
274 check_cxx_compiler_flag(-Wno-c++20-extensions HAVE_WNO_CXX20_EXT)
275 if(HAVE_WNO_CXX20_EXT)
276 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-extensions>)
280 check_cxx_compiler_flag(-Wno-interference-size HAVE_WNO_INTERFERENCE_SIZE)
281 if(HAVE_WNO_INTERFERENCE_SIZE)
282 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>)
286 set(C_FLAGS ${C_FLAGS} -Werror)
288 set(C_FLAGS ${C_FLAGS} -Werror=undef)
291 check_c_compiler_flag(-fno-math-errno HAVE_FNO_MATH_ERRNO)
292 if(HAVE_FNO_MATH_ERRNO)
293 set(C_FLAGS ${C_FLAGS} -fno-math-errno)
296 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
297 if(ALSOFT_STATIC_LIBGCC)
298 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
299 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
300 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBGCC_SWITCH)
301 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
302 unset(OLD_REQUIRED_LIBRARIES)
304 if(NOT HAVE_STATIC_LIBGCC_SWITCH)
305 message(FATAL_ERROR "Cannot static link libgcc")
307 set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
310 option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF)
311 if(ALSOFT_STATIC_STDCXX)
312 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
313 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-static-libstdc++")
314 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBSTDCXX_SWITCH)
315 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
316 unset(OLD_REQUIRED_LIBRARIES)
318 if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH)
319 message(FATAL_ERROR "Cannot static link libstdc++")
321 set(LINKER_FLAGS ${LINKER_FLAGS} "-static-libstdc++")
325 option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
326 if(ALSOFT_STATIC_WINPTHREAD)
327 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
328 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
329 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBWINPTHREAD_SWITCH)
330 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
331 unset(OLD_REQUIRED_LIBRARIES)
333 if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
334 message(FATAL_ERROR "Cannot static link libwinpthread")
336 set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
341 # Set visibility/export options if available
342 if(NOT LIBTYPE STREQUAL "STATIC")
344 set(EXPORT_DECL "__declspec(dllexport)")
346 set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
347 # Yes GCC, really don't accept visibility modes you don't support
348 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
350 check_c_source_compiles("int foo() __attribute__((visibility(\"protected\")));
351 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
352 if(HAVE_GCC_PROTECTED_VISIBILITY)
353 set(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
355 check_c_source_compiles("int foo() __attribute__((visibility(\"default\")));
356 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
357 if(HAVE_GCC_DEFAULT_VISIBILITY)
358 set(EXPORT_DECL "__attribute__((visibility(\"default\")))")
361 if(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
362 set(CMAKE_C_VISIBILITY_PRESET hidden)
363 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
366 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
374 set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
375 # Yes GCC, really don't accept command line options you don't support
376 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
377 check_c_compiler_flag(-msse2 HAVE_MSSE2_SWITCH)
378 if(HAVE_MSSE2_SWITCH)
379 set(SSE2_SWITCH "-msse2")
381 set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
382 unset(OLD_REQUIRED_FLAGS)
385 check_include_file(xmmintrin.h HAVE_XMMINTRIN_H)
386 check_include_file(emmintrin.h HAVE_EMMINTRIN_H)
387 check_include_file(pmmintrin.h HAVE_PMMINTRIN_H)
388 check_include_file(smmintrin.h HAVE_SMMINTRIN_H)
389 check_include_file(arm_neon.h HAVE_ARM_NEON_H)
397 # Check for SSE support
398 option(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
399 option(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
400 if(ALSOFT_CPUEXT_SSE AND HAVE_XMMINTRIN_H)
403 if(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
404 message(FATAL_ERROR "Failed to enable required SSE CPU extensions")
407 option(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
408 option(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
409 if(ALSOFT_CPUEXT_SSE2 AND HAVE_SSE AND HAVE_EMMINTRIN_H)
412 if(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
413 message(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
416 option(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
417 option(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF)
418 if(ALSOFT_CPUEXT_SSE3 AND HAVE_SSE2 AND HAVE_PMMINTRIN_H)
421 if(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
422 message(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
425 option(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
426 option(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
427 if(ALSOFT_CPUEXT_SSE4_1 AND HAVE_SSE3 AND HAVE_SMMINTRIN_H)
430 if(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
431 message(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
434 # Check for ARM Neon support
435 option(ALSOFT_CPUEXT_NEON "Enable ARM NEON support" ON)
436 option(ALSOFT_REQUIRE_NEON "Require ARM NEON support" OFF)
437 if(ALSOFT_CPUEXT_NEON AND HAVE_ARM_NEON_H)
438 check_c_source_compiles("#include <arm_neon.h>
441 int32x4_t ret4 = vdupq_n_s32(0);
442 return vgetq_lane_s32(ret4, 0);
443 }" HAVE_NEON_INTRINSICS)
444 if(HAVE_NEON_INTRINSICS)
448 if(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
449 message(FATAL_ERROR "Failed to enable required ARM NEON CPU extensions")
453 set(ALSOFT_FORCE_ALIGN )
456 if(CMAKE_SIZEOF_VOID_P MATCHES "4" AND HAVE_SSE2)
457 option(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
458 if(ALSOFT_ENABLE_SSE2_CODEGEN)
460 check_c_compiler_flag("/arch:SSE2" HAVE_ARCH_SSE2)
462 set(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
463 set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
467 check_c_compiler_flag("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
468 if(HAVE_MFPMATH_SSE_2)
469 set(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
470 set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
473 # SSE depends on a 16-byte aligned stack, and by default, GCC
474 # assumes the stack is suitably aligned. Older Linux code or other
475 # OSs don't guarantee this on 32-bit, so externally-callable
476 # functions need to ensure an aligned stack.
477 set(EXPORT_DECL "${EXPORT_DECL}__attribute__((force_align_arg_pointer))")
478 set(ALSOFT_FORCE_ALIGN "__attribute__((force_align_arg_pointer))")
484 set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
485 foreach(flag_var ${SSE_FLAGS})
486 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
489 check_c_source_compiles("#include <emmintrin.h>
490 int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
492 set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
496 check_include_file(cpuid.h HAVE_CPUID_H)
497 check_include_file(intrin.h HAVE_INTRIN_H)
498 check_include_file(guiddef.h HAVE_GUIDDEF_H)
500 # Some systems need libm for some math functions to work
502 check_library_exists(m pow "" HAVE_LIBM)
504 set(MATH_LIB ${MATH_LIB} m)
505 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
508 # Some systems need to link with -lrt for clock_gettime as used by the common
511 check_library_exists(rt clock_gettime "" HAVE_LIBRT)
516 # Check for the dlopen API (for dynamically loading backend libs)
518 check_include_file(dlfcn.h HAVE_DLFCN_H)
519 check_library_exists(dl dlopen "" HAVE_LIBDL)
521 set(EXTRA_LIBS dl ${EXTRA_LIBS})
522 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
526 # Check for a cpuid intrinsic
528 check_c_source_compiles("#include <cpuid.h>
531 unsigned int eax, ebx, ecx, edx;
532 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
533 }" HAVE_GCC_GET_CPUID)
536 check_c_source_compiles("#include <intrin.h>
542 }" HAVE_CPUID_INTRINSIC)
545 check_symbol_exists(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
548 # We need pthreads outside of Windows, for semaphores. It's also used to
549 # set the priority and name of threads, when possible.
550 check_include_file(pthread.h HAVE_PTHREAD_H)
551 if(NOT HAVE_PTHREAD_H)
552 message(FATAL_ERROR "PThreads is required for non-Windows builds!")
555 check_c_compiler_flag(-pthread HAVE_PTHREAD)
557 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
558 set(C_FLAGS ${C_FLAGS} -pthread)
559 set(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
562 check_symbol_exists(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
564 # Some systems need pthread_np.h to get pthread_setname_np
565 check_include_files("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
566 if(HAVE_PTHREAD_NP_H)
567 check_symbol_exists(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
568 if(NOT HAVE_PTHREAD_SETNAME_NP)
569 check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
572 check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
573 if(NOT HAVE_PTHREAD_SETNAME_NP)
574 check_symbol_exists(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
580 # Common sources used by both the OpenAL implementation library, the OpenAL
581 # router, and certain tools and examples.
596 common/althrd_setname.cpp
597 common/althrd_setname.h
605 common/intrusive_ptr.h
609 common/phase_shifter.h
610 common/polyphase_resampler.cpp
611 common/polyphase_resampler.h
613 common/ringbuffer.cpp
620 # Core library routines
632 core/bsinc_tables.cpp
635 core/buffer_storage.cpp
636 core/buffer_storage.h
644 core/cubic_tables.cpp
655 core/filters/biquad.h
656 core/filters/biquad.cpp
659 core/filters/splitter.cpp
660 core/filters/splitter.h
665 core/front_stablizer.h
676 core/resampler_limits.h
677 core/storage_formats.cpp
678 core/storage_formats.h
688 option(ALSOFT_RTKIT "Enable RTKit support" ON)
689 option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE)
691 find_package(DBus1 QUIET)
692 if(NOT DBus1_FOUND AND PkgConfig_FOUND)
693 pkg_check_modules(DBUS dbus-1)
695 if(DBus1_FOUND OR DBUS_FOUND)
697 set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h
698 core/rtkit.cpp core/rtkit.h)
700 set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS})
701 set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER})
703 set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES})
706 set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS})
707 set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS})
709 set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES})
714 if(NOT DBus1_INCLUDE_DIRS)
715 set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS")
717 if(NOT DBus1_LIBRARIES)
718 set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES")
720 message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})")
724 if(ALSOFT_REQUIRE_RTKIT AND NOT HAVE_RTKIT)
725 message(FATAL_ERROR "Failed to enable required RTKit support")
728 # Default mixers, always available
729 set(CORE_OBJS ${CORE_OBJS}
731 core/mixer/hrtfbase.h
732 core/mixer/hrtfdefs.h
733 core/mixer/mixer_c.cpp)
735 # AL and related routines
746 al/effects/autowah.cpp
747 al/effects/chorus.cpp
748 al/effects/compressor.cpp
749 al/effects/convolution.cpp
750 al/effects/dedicated.cpp
751 al/effects/distortion.cpp
753 al/effects/effects.cpp
755 al/effects/equalizer.cpp
756 al/effects/fshifter.cpp
757 al/effects/modulator.cpp
759 al/effects/pshifter.cpp
760 al/effects/reverb.cpp
761 al/effects/vmorpher.cpp
775 # ALC and related routines
787 alc/effects/autowah.cpp
788 alc/effects/chorus.cpp
789 alc/effects/compressor.cpp
790 alc/effects/convolution.cpp
791 alc/effects/dedicated.cpp
792 alc/effects/distortion.cpp
794 alc/effects/equalizer.cpp
795 alc/effects/fshifter.cpp
796 alc/effects/modulator.cpp
798 alc/effects/pshifter.cpp
799 alc/effects/reverb.cpp
800 alc/effects/vmorpher.cpp
817 al/eax/fx_slot_index.cpp
818 al/eax/fx_slot_index.h
828 # Include SIMD mixers
829 set(CPU_EXTS "Default")
831 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse.cpp)
832 set(CPU_EXTS "${CPU_EXTS}, SSE")
835 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse2.cpp)
836 set(CPU_EXTS "${CPU_EXTS}, SSE2")
839 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse3.cpp)
840 set(CPU_EXTS "${CPU_EXTS}, SSE3")
843 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse41.cpp)
844 set(CPU_EXTS "${CPU_EXTS}, SSE4.1")
847 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_neon.cpp)
848 set(CPU_EXTS "${CPU_EXTS}, Neon")
860 set(HAVE_PORTAUDIO 0)
861 set(HAVE_PULSEAUDIO 0)
862 set(HAVE_COREAUDIO 0)
869 if(WIN32 OR HAVE_DLFCN_H)
871 macro(ADD_BACKEND_LIBS _LIBS)
874 set(IS_LINKED " (linked)")
875 macro(ADD_BACKEND_LIBS _LIBS)
876 set(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
881 set(ALC_OBJS ${ALC_OBJS}
882 alc/backends/base.cpp
884 # Default backends, always available
885 alc/backends/loopback.cpp
886 alc/backends/loopback.h
887 alc/backends/null.cpp
891 # Check PipeWire backend
892 option(ALSOFT_BACKEND_PIPEWIRE "Enable PipeWire backend" ON)
893 option(ALSOFT_REQUIRE_PIPEWIRE "Require PipeWire backend" OFF)
894 if(ALSOFT_BACKEND_PIPEWIRE AND PkgConfig_FOUND)
895 pkg_check_modules(PIPEWIRE libpipewire-0.3>=0.3.23)
898 set(BACKENDS "${BACKENDS} PipeWire${IS_LINKED},")
899 set(ALC_OBJS ${ALC_OBJS} alc/backends/pipewire.cpp alc/backends/pipewire.h)
900 add_backend_libs(${PIPEWIRE_LIBRARIES})
901 set(INC_PATHS ${INC_PATHS} ${PIPEWIRE_INCLUDE_DIRS})
904 if(ALSOFT_REQUIRE_PIPEWIRE AND NOT HAVE_PIPEWIRE)
905 message(FATAL_ERROR "Failed to enable required PipeWire backend")
908 # Check PulseAudio backend
909 option(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
910 option(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
911 if(ALSOFT_BACKEND_PULSEAUDIO)
912 find_package(PulseAudio)
914 set(HAVE_PULSEAUDIO 1)
915 set(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
916 set(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h)
917 add_backend_libs(${PULSEAUDIO_LIBRARY})
918 set(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIR})
921 if(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
922 message(FATAL_ERROR "Failed to enable required PulseAudio backend")
927 option(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
928 option(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
929 if(ALSOFT_BACKEND_ALSA)
933 set(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
934 set(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h)
935 add_backend_libs(${ALSA_LIBRARIES})
936 set(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
941 option(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
942 option(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
943 if(ALSOFT_BACKEND_OSS)
947 set(BACKENDS "${BACKENDS} OSS,")
948 set(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h)
950 set(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
952 set(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
956 # Check Solaris backend
957 option(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
958 option(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
959 if(ALSOFT_BACKEND_SOLARIS)
960 find_package(AudioIO)
963 set(BACKENDS "${BACKENDS} Solaris,")
964 set(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h)
965 set(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
969 # Check SndIO backend (disabled by default on non-BSDs)
971 option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
973 option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" OFF)
975 option(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
976 if(ALSOFT_BACKEND_SNDIO)
980 set(BACKENDS "${BACKENDS} SndIO (linked),")
981 set(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h)
982 set(EXTRA_LIBS ${SNDIO_LIBRARIES} ${EXTRA_LIBS})
983 set(INC_PATHS ${INC_PATHS} ${SNDIO_INCLUDE_DIRS})
987 if(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
988 message(FATAL_ERROR "Failed to enable required ALSA backend")
990 if(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
991 message(FATAL_ERROR "Failed to enable required OSS backend")
993 if(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
994 message(FATAL_ERROR "Failed to enable required Solaris backend")
996 if(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
997 message(FATAL_ERROR "Failed to enable required SndIO backend")
1000 # Check Windows-only backends
1003 # Check MMSystem backend
1004 option(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
1005 option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
1006 if(ALSOFT_BACKEND_WINMM)
1008 set(BACKENDS "${BACKENDS} WinMM,")
1009 set(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h)
1010 # There doesn't seem to be good way to search for winmm.lib for MSVC.
1011 # find_library doesn't find it without being told to look in a specific
1012 # place in the WindowsSDK, but it links anyway. If there ends up being
1013 # Windows targets without this, another means to detect it is needed.
1014 set(EXTRA_LIBS winmm ${EXTRA_LIBS})
1017 # Check DSound backend
1018 option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
1019 option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
1020 if(ALSOFT_BACKEND_DSOUND)
1021 check_include_file(dsound.h HAVE_DSOUND_H)
1023 find_path(DSOUND_INCLUDE_DIR NAMES "dsound.h"
1024 PATHS "${DXSDK_DIR}" PATH_SUFFIXES include
1025 DOC "The DirectSound include directory")
1027 if(HAVE_DSOUND_H OR DSOUND_INCLUDE_DIR)
1029 set(BACKENDS "${BACKENDS} DirectSound,")
1030 set(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h)
1032 if(NOT HAVE_DSOUND_H)
1033 set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR})
1039 # Check for WASAPI backend
1040 option(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
1041 option(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
1042 if(ALSOFT_BACKEND_WASAPI)
1043 check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
1044 if(HAVE_MMDEVICEAPI_H)
1046 set(BACKENDS "${BACKENDS} WASAPI,")
1047 set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h)
1050 set(EXTRA_LIBS avrt ${EXTRA_LIBS})
1055 option(ALSOFT_BACKEND_OTHERIO "Enable OtherIO backend" OFF)
1056 option(ALSOFT_REQUIRE_OTHERIO "Require OtherIO backend" OFF)
1057 if(ALSOFT_BACKEND_OTHERIO)
1059 set(BACKENDS "${BACKENDS} OtherIO,")
1060 set(ALC_OBJS ${ALC_OBJS} alc/backends/otherio.cpp alc/backends/otherio.h)
1063 if(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
1064 message(FATAL_ERROR "Failed to enable required WinMM backend")
1066 if(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
1067 message(FATAL_ERROR "Failed to enable required DSound backend")
1069 if(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
1070 message(FATAL_ERROR "Failed to enable required WASAPI backend")
1072 if(ALSOFT_REQUIRE_OTHERIO AND NOT HAVE_OTHERIO)
1073 message(FATAL_ERROR "Failed to enable required OtherIO backend")
1076 # Check JACK backend
1077 option(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
1078 option(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
1079 if(ALSOFT_BACKEND_JACK)
1083 set(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
1084 set(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h)
1085 add_backend_libs(${JACK_LIBRARIES})
1086 set(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS})
1089 if(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1090 message(FATAL_ERROR "Failed to enable required JACK backend")
1093 # Check CoreAudio backend
1094 option(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1095 option(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1096 if(ALSOFT_BACKEND_COREAUDIO)
1097 find_library(COREAUDIO_FRAMEWORK NAMES CoreAudio)
1098 find_path(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h)
1099 if(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR)
1100 set(HAVE_COREAUDIO 1)
1101 set(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h)
1102 set(BACKENDS "${BACKENDS} CoreAudio,")
1104 set(EXTRA_LIBS -Wl,-framework,CoreAudio ${EXTRA_LIBS})
1105 if(CMAKE_SYSTEM_NAME MATCHES "^(iOS|tvOS)$")
1106 find_library(COREFOUNDATION_FRAMEWORK NAMES CoreFoundation)
1107 if(COREFOUNDATION_FRAMEWORK)
1108 set(EXTRA_LIBS -Wl,-framework,CoreFoundation ${EXTRA_LIBS})
1111 set(EXTRA_LIBS -Wl,-framework,AudioUnit,-framework,ApplicationServices ${EXTRA_LIBS})
1114 # Some versions of OSX may need the AudioToolbox framework. Add it if
1116 find_library(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox)
1117 if(AUDIOTOOLBOX_LIBRARY)
1118 set(EXTRA_LIBS -Wl,-framework,AudioToolbox ${EXTRA_LIBS})
1121 set(INC_PATHS ${INC_PATHS} ${AUDIOUNIT_INCLUDE_DIR})
1124 if(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1125 message(FATAL_ERROR "Failed to enable required CoreAudio backend")
1128 # Check for Oboe (Android) backend
1129 option(ALSOFT_BACKEND_OBOE "Enable Oboe backend" ON)
1130 option(ALSOFT_REQUIRE_OBOE "Require Oboe backend" OFF)
1131 if(ALSOFT_BACKEND_OBOE)
1134 set(OBOE_SOURCE "" CACHE STRING "Source directory for Oboe.")
1136 add_subdirectory(${OBOE_SOURCE} ./oboe EXCLUDE_FROM_ALL)
1137 set(OBOE_TARGET oboe)
1139 find_package(oboe CONFIG)
1140 if(NOT TARGET oboe::oboe)
1143 if(TARGET oboe::oboe)
1144 set(OBOE_TARGET "oboe::oboe")
1151 set(ALC_OBJS ${ALC_OBJS} alc/backends/oboe.cpp alc/backends/oboe.h)
1152 set(BACKENDS "${BACKENDS} Oboe,")
1153 set(EXTRA_LIBS ${OBOE_TARGET} ${EXTRA_LIBS})
1156 if(ALSOFT_REQUIRE_OBOE AND NOT HAVE_OBOE)
1157 message(FATAL_ERROR "Failed to enable required Oboe backend")
1160 # Check for OpenSL (Android) backend
1161 option(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1162 option(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1163 if(ALSOFT_BACKEND_OPENSL)
1164 find_package(OpenSL)
1167 set(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h)
1168 set(BACKENDS "${BACKENDS} OpenSL,")
1169 set(EXTRA_LIBS ${OPENSL_LIBRARIES} ${EXTRA_LIBS})
1170 set(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS})
1173 if(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1174 message(FATAL_ERROR "Failed to enable required OpenSL backend")
1177 # Check PortAudio backend
1178 option(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
1179 option(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
1180 if(ALSOFT_BACKEND_PORTAUDIO)
1181 find_package(PortAudio)
1183 set(HAVE_PORTAUDIO 1)
1184 set(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
1185 set(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.h)
1186 add_backend_libs(${PORTAUDIO_LIBRARIES})
1187 set(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS})
1190 if(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
1191 message(FATAL_ERROR "Failed to enable required PortAudio backend")
1194 # Check for SDL2 backend
1195 # Off by default, since it adds a runtime dependency
1196 option(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF)
1197 option(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF)
1198 if(ALSOFT_BACKEND_SDL2)
1201 set(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h)
1202 set(BACKENDS "${BACKENDS} SDL2,")
1203 set(EXTRA_LIBS ${EXTRA_LIBS} SDL2::SDL2)
1205 message(STATUS "Could NOT find SDL2")
1208 if(ALSOFT_REQUIRE_SDL2 AND NOT HAVE_SDL2)
1209 message(FATAL_ERROR "Failed to enable required SDL2 backend")
1212 # Optionally enable the Wave Writer backend
1213 option(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1214 if(ALSOFT_BACKEND_WAVE)
1216 set(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h)
1217 set(BACKENDS "${BACKENDS} WaveFile,")
1220 # This is always available
1221 set(BACKENDS "${BACKENDS} Null")
1225 if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
1226 set(GIT_DIR "${OpenAL_SOURCE_DIR}/.git")
1228 # Check if this is a submodule, if it is then find the .git directory
1229 if(NOT IS_DIRECTORY "${OpenAL_SOURCE_DIR}/.git")
1230 file(READ ${GIT_DIR} submodule)
1231 string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule})
1232 string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
1233 get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
1234 get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
1237 # Get the current working branch and its latest abbreviated commit hash
1238 add_custom_command(OUTPUT "${OpenAL_BINARY_DIR}/version_witness.txt"
1239 BYPRODUCTS "${OpenAL_BINARY_DIR}/version.h"
1240 COMMAND ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D LIB_VERSION=${LIB_VERSION}
1241 -D LIB_VERSION_NUM=${LIB_VERSION_NUM} -D SRC=${OpenAL_SOURCE_DIR}/version.h.in
1242 -D DST=${OpenAL_BINARY_DIR}/version.h -P ${OpenAL_SOURCE_DIR}/version.cmake
1243 COMMAND ${CMAKE_COMMAND} -E touch "${OpenAL_BINARY_DIR}/version_witness.txt"
1244 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1245 MAIN_DEPENDENCY "${OpenAL_SOURCE_DIR}/version.h.in"
1246 DEPENDS "${GIT_DIR}/index" "${OpenAL_SOURCE_DIR}/version.cmake"
1250 add_custom_target(alsoft.build_version DEPENDS "${OpenAL_BINARY_DIR}/version_witness.txt")
1252 set(GIT_BRANCH "UNKNOWN")
1253 set(GIT_COMMIT_HASH "unknown")
1255 "${OpenAL_SOURCE_DIR}/version.h.in"
1256 "${OpenAL_BINARY_DIR}/version.h")
1260 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON)
1261 if(ALSOFT_EMBED_HRTF_DATA)
1262 macro(make_hrtf_header FILENAME VARNAME)
1263 set(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}")
1264 set(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.txt")
1266 add_custom_command(OUTPUT "${outfile}"
1267 COMMAND ${CMAKE_COMMAND} -D "INPUT_FILE=${infile}" -D "OUTPUT_FILE=${outfile}"
1268 -P "${CMAKE_MODULE_PATH}/bin2h.script.cmake"
1269 WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1270 DEPENDS "${infile}" "${CMAKE_MODULE_PATH}/bin2h.script.cmake"
1273 set(ALC_OBJS ${ALC_OBJS} "${outfile}")
1276 make_hrtf_header("Default HRTF.mhr" "default_hrtf")
1281 find_package(MySOFA)
1282 if(NOT ALSOFT_NO_CONFIG_UTIL)
1283 find_package(Qt5Widgets QUIET)
1284 if(NOT Qt5Widgets_FOUND)
1285 message(STATUS "Could NOT find Qt5Widgets")
1289 if(ALSOFT_UTILS OR ALSOFT_EXAMPLES)
1290 find_package(SndFile)
1292 find_package(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1297 set(LIBNAME "openal")
1299 set(LIBNAME "OpenAL32")
1302 # Needed for openal.pc.in
1303 set(prefix ${CMAKE_INSTALL_PREFIX})
1304 set(exec_prefix "\${prefix}")
1305 set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
1306 set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
1307 set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
1308 set(PACKAGE_VERSION "${LIB_VERSION}")
1309 set(PKG_CONFIG_CFLAGS )
1310 set(PKG_CONFIG_PRIVATE_LIBS )
1311 if(LIBTYPE STREQUAL "STATIC")
1312 set(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC)
1313 foreach(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1314 # If this is already a linker flag, or is a full path+file, add it
1315 # as-is. If it's an SDL2 target, add the link flag for it. Otherwise,
1316 # it's a name intended to be dressed as -lname.
1317 if(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}")
1318 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}")
1319 elseif(FLAG MATCHES "^SDL2::SDL2")
1320 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -lSDL2")
1322 set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}")
1329 "${OpenAL_SOURCE_DIR}/config.h.in"
1330 "${OpenAL_BINARY_DIR}/config.h")
1332 "${OpenAL_SOURCE_DIR}/config_backends.h.in"
1333 "${OpenAL_BINARY_DIR}/config_backends.h")
1335 "${OpenAL_SOURCE_DIR}/config_simd.h.in"
1336 "${OpenAL_BINARY_DIR}/config_simd.h")
1338 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1339 "${OpenAL_BINARY_DIR}/openal.pc"
1343 add_library(alsoft.common STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS})
1344 target_include_directories(alsoft.common PRIVATE ${OpenAL_SOURCE_DIR}/include
1345 PUBLIC ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1346 target_compile_definitions(alsoft.common PRIVATE ${CPP_DEFS})
1347 target_compile_options(alsoft.common PRIVATE ${C_FLAGS})
1348 set_target_properties(alsoft.common PROPERTIES ${DEFAULT_TARGET_PROPS} POSITION_INDEPENDENT_CODE TRUE)
1352 set(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal.
1354 # Build main library
1355 if(LIBTYPE STREQUAL "STATIC")
1356 add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS})
1357 target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC)
1358 target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1361 # This option is for static linking OpenAL Soft into another project
1362 # that already defines the IDs. It is up to that project to ensure all
1363 # required IDs are defined.
1364 option(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
1365 if(ALSOFT_NO_UID_DEFS)
1366 target_compile_definitions(${IMPL_TARGET} PRIVATE AL_NO_UID_DEFS)
1370 set(RC_CONFIG resources/openal32.rc)
1371 if(WIN32 AND ALSOFT_BUILD_ROUTER)
1372 add_library(OpenAL SHARED
1379 target_compile_definitions(OpenAL
1380 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}"
1381 "AL_API=${EXPORT_DECL}" ${CPP_DEFS})
1382 target_compile_options(OpenAL PRIVATE ${C_FLAGS})
1383 target_link_libraries(OpenAL PRIVATE alsoft.common ${LINKER_FLAGS})
1384 target_include_directories(OpenAL
1386 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1387 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1389 ${OpenAL_SOURCE_DIR}/common
1390 ${OpenAL_BINARY_DIR}
1392 set_target_properties(OpenAL PROPERTIES ${DEFAULT_TARGET_PROPS} PREFIX ""
1393 OUTPUT_NAME ${LIBNAME})
1394 if(TARGET alsoft.build_version)
1395 add_dependencies(OpenAL alsoft.build_version)
1399 set(LIBNAME "soft_oal")
1400 set(IMPL_TARGET soft_oal)
1401 set(RC_CONFIG resources/soft_oal.rc)
1404 # !important: for osx framework public header works, the headers must be in
1406 set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h
1407 include/AL/efx-presets.h)
1409 add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS} ${RC_CONFIG}
1410 ${TARGET_PUBLIC_HEADERS})
1412 set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "")
1414 target_link_libraries(${IMPL_TARGET} PRIVATE alsoft.common ${LINKER_FLAGS} ${EXTRA_LIBS}
1418 set(ALSOFT_CPPWINRT_VERSION "2.0.230706.1" CACHE STRING "The soft-oal default cppwinrt version")
1420 find_program(NUGET_EXE NAMES nuget)
1422 message("NUGET.EXE not found.")
1423 message(FATAL_ERROR "Please install this executable, and run CMake again.")
1426 exec_program(${NUGET_EXE}
1427 ARGS install "Microsoft.Windows.CppWinRT" -Version ${ALSOFT_CPPWINRT_VERSION} -ExcludeVersion -OutputDirectory "\"${CMAKE_BINARY_DIR}/packages\"")
1429 set_target_properties(${IMPL_TARGET} PROPERTIES
1430 VS_PROJECT_IMPORT ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.props
1432 target_link_libraries(${IMPL_TARGET} PRIVATE ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets)
1435 if(NOT WIN32 AND NOT APPLE)
1436 # FIXME: This doesn't put a dependency on the version script. Changing
1437 # the version script will not cause a relink as it should.
1438 target_link_options(${IMPL_TARGET} PRIVATE
1439 "-Wl,--version-script=${OpenAL_SOURCE_DIR}/libopenal.version")
1442 if(APPLE AND ALSOFT_OSX_FRAMEWORK)
1443 # Sets framework name to soft_oal to avoid ambiguity with the system OpenAL.framework
1444 set(LIBNAME "soft_oal")
1446 execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
1448 OUTPUT_VARIABLE BUNDLE_VERSION
1449 OUTPUT_STRIP_TRAILING_WHITESPACE)
1451 set(BUNDLE_VERSION 1)
1454 # Build: Fix rpath in iOS shared libraries
1455 # If this flag is not set, the final dylib binary ld path will be
1456 # /User/xxx/*/soft_oal.framework/soft_oal, which can't be loaded by iOS devices.
1457 # See also: https://github.com/libjpeg-turbo/libjpeg-turbo/commit/c80ddef7a4ce21ace9e3ca0fd190d320cc8cdaeb
1458 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
1459 set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
1462 set_target_properties(${IMPL_TARGET} PROPERTIES
1465 MACOSX_FRAMEWORK_NAME "${IMPL_TARGET}"
1466 MACOSX_FRAMEWORK_IDENTIFIER "org.openal-soft.openal"
1467 MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${LIB_VERSION}"
1468 MACOSX_FRAMEWORK_BUNDLE_VERSION "${BUNDLE_VERSION}"
1469 XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
1470 XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
1471 XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
1472 PUBLIC_HEADER "${TARGET_PUBLIC_HEADERS}"
1477 target_include_directories(${IMPL_TARGET}
1479 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1481 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include/AL>
1482 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1483 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/AL>
1486 ${OpenAL_BINARY_DIR}
1487 ${OpenAL_SOURCE_DIR}
1488 ${OpenAL_SOURCE_DIR}/common
1491 set_target_properties(${IMPL_TARGET} PROPERTIES ${DEFAULT_TARGET_PROPS}
1492 OUTPUT_NAME ${LIBNAME}
1493 VERSION ${LIB_VERSION}
1494 SOVERSION ${LIB_MAJOR_VERSION}
1496 target_compile_definitions(${IMPL_TARGET}
1497 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}"
1499 target_compile_options(${IMPL_TARGET} PRIVATE ${C_FLAGS})
1501 if(TARGET alsoft.build_version)
1502 add_dependencies(${IMPL_TARGET} alsoft.build_version)
1505 if(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
1506 find_program(SED_EXECUTABLE NAMES sed DOC "sed executable")
1507 if(NOT SED_EXECUTABLE OR NOT CMAKE_DLLTOOL)
1509 if(NOT SED_EXECUTABLE)
1510 message(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1512 if(NOT CMAKE_DLLTOOL)
1513 message(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1516 target_link_options(OpenAL PRIVATE "-Wl,--output-def,${PROJECT_BINARY_DIR}/OpenAL32.def")
1517 add_custom_command(TARGET OpenAL POST_BUILD
1518 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
1519 COMMAND "${CMAKE_DLLTOOL}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
1520 # Technically OpenAL32.def was created by the build, but cmake
1521 # doesn't recognize it due to -Wl,--output-def,OpenAL32.def being
1522 # manually specified. But declaring the file here allows it to be
1523 # properly cleaned, e.g. during make clean.
1524 BYPRODUCTS OpenAL32.def OpenAL32.lib
1525 COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
1533 message(STATUS "Building DLL router")
1537 message(STATUS "Building OpenAL with support for the following backends:")
1538 message(STATUS " ${BACKENDS}")
1540 message(STATUS "Building with support for CPU extensions:")
1541 message(STATUS " ${CPU_EXTS}")
1544 message(STATUS "Building with SSE${FPMATH_SET} codegen")
1548 message(STATUS "Building with UWP support")
1552 message(STATUS "Building with legacy EAX extension support")
1556 if(ALSOFT_EMBED_HRTF_DATA)
1557 message(STATUS "Embedding HRTF datasets")
1561 # An alias for sub-project builds
1562 add_library(OpenAL::OpenAL ALIAS OpenAL)
1564 # Install main library
1566 configure_package_config_file(OpenALConfig.cmake.in OpenALConfig.cmake
1567 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL)
1568 install(TARGETS OpenAL EXPORT OpenAL
1569 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1570 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1571 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1572 FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
1573 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL)
1574 export(TARGETS OpenAL
1576 FILE OpenALTargets.cmake)
1577 install(EXPORT OpenAL
1578 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
1580 FILE OpenALTargets.cmake)
1581 install(DIRECTORY include/AL
1582 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
1583 install(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1584 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1585 install(FILES "${OpenAL_BINARY_DIR}/OpenALConfig.cmake"
1586 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL")
1588 install(TARGETS soft_oal
1589 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1591 message(STATUS "Installing library and headers")
1593 message(STATUS "NOT installing library and headers")
1596 if(ALSOFT_INSTALL_CONFIG)
1597 install(FILES alsoftrc.sample
1598 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1599 message(STATUS "Installing sample configuration")
1602 if(ALSOFT_INSTALL_HRTF_DATA)
1603 install(DIRECTORY hrtf
1604 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1605 message(STATUS "Installing HRTF data files")
1608 if(ALSOFT_INSTALL_AMBDEC_PRESETS)
1609 install(DIRECTORY presets
1610 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1611 message(STATUS "Installing AmbDec presets")
1617 set(UNICODE_FLAG ${UNICODE_FLAG} -municode)
1619 set(EXTRA_INSTALLS )
1621 add_executable(openal-info utils/openal-info.c)
1622 target_include_directories(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
1623 target_compile_options(openal-info PRIVATE ${C_FLAGS})
1624 target_link_libraries(openal-info PRIVATE ${LINKER_FLAGS} OpenAL ${UNICODE_FLAG})
1625 set_target_properties(openal-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1626 if(ALSOFT_INSTALL_EXAMPLES)
1627 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} openal-info)
1631 add_executable(uhjdecoder utils/uhjdecoder.cpp)
1632 target_compile_definitions(uhjdecoder PRIVATE ${CPP_DEFS})
1633 target_include_directories(uhjdecoder
1634 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1635 target_compile_options(uhjdecoder PRIVATE ${C_FLAGS})
1636 target_link_libraries(uhjdecoder PUBLIC alsoft.common
1637 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1638 set_target_properties(uhjdecoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1640 add_executable(uhjencoder utils/uhjencoder.cpp)
1641 target_compile_definitions(uhjencoder PRIVATE ${CPP_DEFS})
1642 target_include_directories(uhjencoder
1643 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1644 target_compile_options(uhjencoder PRIVATE ${C_FLAGS})
1645 target_link_libraries(uhjencoder PUBLIC alsoft.common
1646 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1647 set_target_properties(uhjencoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1651 set(SOFA_SUPPORT_SRCS
1652 utils/sofa-support.cpp
1653 utils/sofa-support.h)
1654 add_library(alsoft.sofa-support STATIC EXCLUDE_FROM_ALL ${SOFA_SUPPORT_SRCS})
1655 target_compile_definitions(alsoft.sofa-support PRIVATE ${CPP_DEFS})
1656 target_include_directories(alsoft.sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/common)
1657 target_compile_options(alsoft.sofa-support PRIVATE ${C_FLAGS})
1658 target_link_libraries(alsoft.sofa-support PUBLIC alsoft.common MySOFA::MySOFA
1659 PRIVATE ${LINKER_FLAGS})
1660 set_target_properties(alsoft.sofa-support PROPERTIES ${DEFAULT_TARGET_PROPS})
1663 utils/makemhr/loaddef.cpp
1664 utils/makemhr/loaddef.h
1665 utils/makemhr/loadsofa.cpp
1666 utils/makemhr/loadsofa.h
1667 utils/makemhr/makemhr.cpp
1668 utils/makemhr/makemhr.h)
1669 add_executable(makemhr ${MAKEMHR_SRCS})
1670 target_compile_definitions(makemhr PRIVATE ${CPP_DEFS})
1671 target_include_directories(makemhr
1672 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils)
1673 target_compile_options(makemhr PRIVATE ${C_FLAGS})
1674 target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} alsoft.sofa-support ${UNICODE_FLAG})
1675 set_target_properties(makemhr PROPERTIES ${DEFAULT_TARGET_PROPS})
1676 if(ALSOFT_INSTALL_EXAMPLES)
1677 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} makemhr)
1680 set(SOFAINFO_SRCS utils/sofa-info.cpp)
1681 add_executable(sofa-info ${SOFAINFO_SRCS})
1682 target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS})
1683 target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/utils)
1684 target_compile_options(sofa-info PRIVATE ${C_FLAGS})
1685 target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} alsoft.sofa-support
1687 set_target_properties(sofa-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1689 message(STATUS "Building utility programs")
1691 if(NOT ALSOFT_NO_CONFIG_UTIL)
1692 add_subdirectory(utils/alsoft-config)
1698 # Add a static library with common functions used by multiple example targets
1699 add_library(alsoft.excommon STATIC EXCLUDE_FROM_ALL
1700 examples/common/alhelpers.c
1701 examples/common/alhelpers.h)
1702 target_compile_definitions(alsoft.excommon PUBLIC ${CPP_DEFS})
1703 target_include_directories(alsoft.excommon PUBLIC ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1704 target_compile_options(alsoft.excommon PUBLIC ${C_FLAGS})
1705 target_link_libraries(alsoft.excommon PUBLIC OpenAL PRIVATE ${RT_LIB})
1706 set_target_properties(alsoft.excommon PROPERTIES ${DEFAULT_TARGET_PROPS})
1709 add_executable(altonegen examples/altonegen.c)
1710 target_link_libraries(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} alsoft.excommon
1712 set_target_properties(altonegen PROPERTIES ${DEFAULT_TARGET_PROPS})
1714 add_executable(alrecord examples/alrecord.c)
1715 target_link_libraries(alrecord PRIVATE ${LINKER_FLAGS} alsoft.excommon ${UNICODE_FLAG})
1716 set_target_properties(alrecord PROPERTIES ${DEFAULT_TARGET_PROPS})
1718 add_executable(aldebug examples/aldebug.cpp)
1719 target_link_libraries(aldebug PRIVATE ${LINKER_FLAGS} alsoft.excommon ${UNICODE_FLAG})
1720 set_target_properties(aldebug PROPERTIES ${DEFAULT_TARGET_PROPS})
1722 add_executable(allafplay examples/allafplay.cpp)
1723 target_link_libraries(allafplay PRIVATE ${LINKER_FLAGS} alsoft.common alsoft.excommon
1725 set_target_properties(allafplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1727 if(ALSOFT_INSTALL_EXAMPLES)
1728 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} altonegen alrecord aldebug allafplay)
1731 message(STATUS "Building example programs")
1734 add_executable(alplay examples/alplay.c)
1735 target_link_libraries(alplay PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1737 set_target_properties(alplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1739 add_executable(alstream examples/alstream.c)
1740 target_link_libraries(alstream PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1742 set_target_properties(alstream PROPERTIES ${DEFAULT_TARGET_PROPS})
1744 add_executable(alreverb examples/alreverb.c)
1745 target_link_libraries(alreverb PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1747 set_target_properties(alreverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1749 add_executable(almultireverb examples/almultireverb.c)
1750 target_link_libraries(almultireverb
1751 PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${MATH_LIB} ${UNICODE_FLAG})
1752 set_target_properties(almultireverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1754 add_executable(allatency examples/allatency.c)
1755 target_link_libraries(allatency PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1757 set_target_properties(allatency PROPERTIES ${DEFAULT_TARGET_PROPS})
1759 add_executable(alhrtf examples/alhrtf.c)
1760 target_link_libraries(alhrtf
1761 PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${MATH_LIB} ${UNICODE_FLAG})
1762 set_target_properties(alhrtf PROPERTIES ${DEFAULT_TARGET_PROPS})
1764 add_executable(alstreamcb examples/alstreamcb.cpp)
1765 target_link_libraries(alstreamcb PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1767 set_target_properties(alstreamcb PROPERTIES ${DEFAULT_TARGET_PROPS})
1769 add_executable(aldirect examples/aldirect.cpp)
1770 target_link_libraries(aldirect PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon
1772 set_target_properties(aldirect PROPERTIES ${DEFAULT_TARGET_PROPS})
1774 add_executable(alconvolve examples/alconvolve.c)
1775 target_link_libraries(alconvolve PRIVATE ${LINKER_FLAGS} alsoft.common SndFile::SndFile
1776 alsoft.excommon ${UNICODE_FLAG})
1777 set_target_properties(alconvolve PROPERTIES ${DEFAULT_TARGET_PROPS})
1779 if(ALSOFT_INSTALL_EXAMPLES)
1780 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alplay alstream alreverb almultireverb allatency
1784 message(STATUS "Building SndFile example programs")
1788 add_executable(alloopback examples/alloopback.c)
1789 target_link_libraries(alloopback
1790 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 alsoft.excommon ${MATH_LIB})
1791 set_target_properties(alloopback PROPERTIES ${DEFAULT_TARGET_PROPS})
1793 if(ALSOFT_INSTALL_EXAMPLES)
1794 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alloopback)
1797 message(STATUS "Building SDL example programs")
1802 if(AVFORMAT_VERSION VERSION_LESS "59.27.100")
1803 message(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 59.27.100)")
1806 if(AVCODEC_VERSION VERSION_LESS "59.37.100")
1807 message(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 59.37.100)")
1810 if(AVUTIL_VERSION VERSION_LESS "57.28.100")
1811 message(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 57.28.100)")
1814 if(SWSCALE_VERSION VERSION_LESS "6.7.100")
1815 message(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 6.7.100)")
1818 if(SWRESAMPLE_VERSION VERSION_LESS "4.7.100")
1819 message(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 4.7.100)")
1824 add_executable(alffplay examples/alffplay.cpp)
1825 target_include_directories(alffplay PRIVATE ${FFMPEG_INCLUDE_DIRS})
1826 target_link_libraries(alffplay
1827 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 ${FFMPEG_LIBRARIES} alsoft.excommon)
1828 set_target_properties(alffplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1830 if(ALSOFT_INSTALL_EXAMPLES)
1831 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alffplay)
1833 message(STATUS "Building SDL+FFmpeg example programs")
1840 add_subdirectory(tests)
1844 install(TARGETS ${EXTRA_INSTALLS}
1845 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1846 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
1847 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1848 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})