1 # CMake build file list for OpenAL
3 cmake_minimum_required(VERSION 3.13)
7 # The workaround for try_compile failing with code signing
8 # since cmake-3.18.2, not required
9 set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
10 ${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}
11 "CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED"
12 "CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED")
13 set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO)
14 set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
17 if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
18 # Fix compile failure with armv7 deployment target >= 11.0, xcode clang
20 # error: invalid iOS deployment version '--target=armv7-apple-ios13.6',
21 # iOS 10 is the maximum deployment target for 32-bit targets
22 # If CMAKE_OSX_DEPLOYMENT_TARGET is not defined, cmake will choose latest
24 if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*armv7.*")
25 if(NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET
26 OR NOT CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "11.0")
27 message(STATUS "Forcing iOS deployment target to 10.0 for armv7")
28 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.0" CACHE STRING "Minimum OS X deployment version"
32 elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
36 if(COMMAND CMAKE_POLICY)
37 cmake_policy(SET CMP0003 NEW)
38 cmake_policy(SET CMP0005 NEW)
40 cmake_policy(SET CMP0020 NEW)
43 cmake_policy(SET CMP0042 NEW)
46 cmake_policy(SET CMP0054 NEW)
49 cmake_policy(SET CMP0058 NEW)
52 cmake_policy(SET CMP0063 NEW)
55 cmake_policy(SET CMP0075 NEW)
58 cmake_policy(SET CMP0092 NEW)
61 cmake_policy(SET CMP0117 NEW)
63 endif(COMMAND CMAKE_POLICY)
67 if(NOT CMAKE_BUILD_TYPE)
68 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
69 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
72 if(NOT CMAKE_DEBUG_POSTFIX)
73 set(CMAKE_DEBUG_POSTFIX "" CACHE STRING
74 "Library postfix for debug builds. Normally left blank."
78 set(DEFAULT_TARGET_PROPS
81 CXX_STANDARD_REQUIRED TRUE
82 # Prefer C11, but support C99 and earlier when possible.
85 set(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
87 include(CheckFunctionExists)
88 include(CheckLibraryExists)
89 include(CheckIncludeFile)
90 include(CheckIncludeFiles)
91 include(CheckSymbolExists)
92 include(CheckCCompilerFlag)
93 include(CheckCXXCompilerFlag)
94 include(CheckCSourceCompiles)
95 include(CheckCXXSourceCompiles)
96 include(CheckStructHasMember)
97 include(CMakePackageConfigHelpers)
98 include(GNUInstallDirs)
100 find_package(PkgConfig)
101 find_package(SDL2 QUIET)
104 option(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
106 option(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
108 option(ALSOFT_UTILS "Build utility programs" ON)
109 option(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
111 option(ALSOFT_EXAMPLES "Build example programs" ON)
112 option(ALSOFT_TESTS "Build test programs" OFF)
114 option(ALSOFT_INSTALL "Install main library" ON)
115 option(ALSOFT_INSTALL_CONFIG "Install alsoft.conf sample configuration file" ON)
116 option(ALSOFT_INSTALL_HRTF_DATA "Install HRTF data files" ON)
117 option(ALSOFT_INSTALL_AMBDEC_PRESETS "Install AmbDec preset files" ON)
118 option(ALSOFT_INSTALL_EXAMPLES "Install example programs (alplay, alstream, ...)" ON)
119 option(ALSOFT_INSTALL_UTILS "Install utility programs (openal-info, alsoft-config, ...)" ON)
120 option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON)
122 option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32})
124 option(ALSOFT_SEARCH_INSTALL_DATADIR "Search the installation data directory" OFF)
125 if(ALSOFT_SEARCH_INSTALL_DATADIR)
126 set(ALSOFT_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
129 if(DEFINED SHARE_INSTALL_DIR)
130 message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
131 set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
134 if(DEFINED LIB_SUFFIX)
135 message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
137 if(DEFINED ALSOFT_CONFIG)
138 message(WARNING "ALSOFT_CONFIG is deprecated. Use ALSOFT_INSTALL_CONFIG instead")
140 if(DEFINED ALSOFT_HRTF_DEFS)
141 message(WARNING "ALSOFT_HRTF_DEFS is deprecated. Use ALSOFT_INSTALL_HRTF_DATA instead")
143 if(DEFINED ALSOFT_AMBDEC_PRESETS)
144 message(WARNING "ALSOFT_AMBDEC_PRESETS is deprecated. Use ALSOFT_INSTALL_AMBDEC_PRESETS instead")
148 set(CPP_DEFS ) # C pre-processor, not C++
152 set(LINKER_FLAGS_DEBUG )
153 set(LINKER_FLAGS_RELEASE )
157 set(CPP_DEFS ${CPP_DEFS} _WIN32 NOMINMAX)
159 set(CPP_DEFS ${CPP_DEFS} __USE_MINGW_ANSI_STDIO)
162 option(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
164 option(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
167 option(ALSOFT_OSX_FRAMEWORK "Build as macOS framework" OFF)
171 # QNX's gcc do not uses /usr/include and /usr/lib paths by default
172 if("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
173 set(INC_PATHS ${INC_PATHS} /usr/include)
174 set(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
177 # When the library is built for static linking, apps should define
178 # AL_LIBTYPE_STATIC when including the AL headers.
183 set(LIB_MAJOR_VERSION "1")
184 set(LIB_MINOR_VERSION "23")
185 set(LIB_REVISION "1")
186 set(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
187 set(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0)
192 # Some systems erroneously require the __STDC_FORMAT_MACROS macro to be defined
193 # to get the fixed-width integer type formatter macros.
194 check_cxx_source_compiles("#include <cinttypes>
199 std::printf(\"%\" PRId64, i64);
201 HAVE_STDC_FORMAT_MACROS)
202 if(NOT HAVE_STDC_FORMAT_MACROS)
203 set(CPP_DEFS ${CPP_DEFS} __STDC_FORMAT_MACROS)
207 # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
208 check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
209 if(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
210 set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
211 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600")
212 check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
213 if(NOT HAVE_POSIX_MEMALIGN_POSIX)
214 set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
216 set(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600)
219 unset(OLD_REQUIRED_FLAGS)
222 # C99 has restrict, but C++ does not, so we can only utilize __restrict.
223 check_cxx_source_compiles("int *__restrict foo;
224 int main() { return 0; }" HAVE___RESTRICT)
226 set(CPP_DEFS ${CPP_DEFS} RESTRICT=__restrict)
228 set(CPP_DEFS ${CPP_DEFS} "RESTRICT=")
231 # Some systems may need libatomic for atomic functions to work
232 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
233 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
234 check_cxx_source_compiles("#include <atomic>
235 std::atomic<int> foo{0};
236 int main() { return foo.fetch_add(2); }"
238 if(NOT HAVE_LIBATOMIC)
239 set(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
241 set(EXTRA_LIBS atomic ${EXTRA_LIBS})
243 unset(OLD_REQUIRED_LIBRARIES)
246 # Include liblog for Android logging
247 check_library_exists(log __android_log_print "" HAVE_LIBLOG)
249 set(EXTRA_LIBS log ${EXTRA_LIBS})
250 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
255 set(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS)
256 check_cxx_compiler_flag(/permissive- HAVE_PERMISSIVE_SWITCH)
257 if(HAVE_PERMISSIVE_SWITCH)
258 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:/permissive->)
260 set(C_FLAGS ${C_FLAGS} /W4 /w14640 /wd4065 /wd4127 /wd4268 /wd4324 /wd5030 /wd5051)
263 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
265 string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
268 message(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
271 option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
272 if(FORCE_STATIC_VCRT)
274 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
275 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
276 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
277 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
278 if(${flag_var} MATCHES "/MD")
279 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
284 set(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align
286 $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>)
288 check_cxx_compiler_flag(-Wno-c++20-attribute-extensions HAVE_WNO_CXX20_ATTR_EXT)
289 if(HAVE_WNO_CXX20_ATTR_EXT)
290 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-attribute-extensions>)
292 check_cxx_compiler_flag(-Wno-c++20-extensions HAVE_WNO_CXX20_EXT)
293 if(HAVE_WNO_CXX20_EXT)
294 set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-extensions>)
299 set(C_FLAGS ${C_FLAGS} -Werror)
302 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
304 foreach(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
305 if(${flag_var} MATCHES "-DNDEBUG")
306 string(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
310 check_c_compiler_flag(-fno-math-errno HAVE_FNO_MATH_ERRNO)
311 if(HAVE_FNO_MATH_ERRNO)
312 set(C_FLAGS ${C_FLAGS} -fno-math-errno)
315 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
316 if(ALSOFT_STATIC_LIBGCC)
317 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
318 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
319 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBGCC_SWITCH)
320 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
321 unset(OLD_REQUIRED_LIBRARIES)
323 if(NOT HAVE_STATIC_LIBGCC_SWITCH)
324 message(FATAL_ERROR "Cannot static link libgcc")
326 set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
329 option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF)
330 if(ALSOFT_STATIC_STDCXX)
331 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
332 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-static-libstdc++")
333 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBSTDCXX_SWITCH)
334 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
335 unset(OLD_REQUIRED_LIBRARIES)
337 if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH)
338 message(FATAL_ERROR "Cannot static link libstdc++")
340 set(LINKER_FLAGS ${LINKER_FLAGS} "-static-libstdc++")
344 option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
345 if(ALSOFT_STATIC_WINPTHREAD)
346 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
347 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
348 check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBWINPTHREAD_SWITCH)
349 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
350 unset(OLD_REQUIRED_LIBRARIES)
352 if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
353 message(FATAL_ERROR "Cannot static link libwinpthread")
355 set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state")
360 # Set visibility/export options if available
361 if(NOT LIBTYPE STREQUAL "STATIC")
363 set(EXPORT_DECL "__declspec(dllexport)")
365 set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
366 # Yes GCC, really don't accept visibility modes you don't support
367 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
369 check_c_source_compiles("int foo() __attribute__((visibility(\"protected\")));
370 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
371 if(HAVE_GCC_PROTECTED_VISIBILITY)
372 set(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
374 check_c_source_compiles("int foo() __attribute__((visibility(\"default\")));
375 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
376 if(HAVE_GCC_DEFAULT_VISIBILITY)
377 set(EXPORT_DECL "__attribute__((visibility(\"default\")))")
380 if(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
381 set(CMAKE_C_VISIBILITY_PRESET hidden)
382 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
385 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
393 set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
394 # Yes GCC, really don't accept command line options you don't support
395 set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
396 check_c_compiler_flag(-msse2 HAVE_MSSE2_SWITCH)
397 if(HAVE_MSSE2_SWITCH)
398 set(SSE2_SWITCH "-msse2")
400 set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
401 unset(OLD_REQUIRED_FLAGS)
404 check_include_file(xmmintrin.h HAVE_XMMINTRIN_H)
405 check_include_file(emmintrin.h HAVE_EMMINTRIN_H)
406 check_include_file(pmmintrin.h HAVE_PMMINTRIN_H)
407 check_include_file(smmintrin.h HAVE_SMMINTRIN_H)
408 check_include_file(arm_neon.h HAVE_ARM_NEON_H)
416 # Check for SSE support
417 option(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
418 option(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
419 if(ALSOFT_CPUEXT_SSE AND HAVE_XMMINTRIN_H)
422 if(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
423 message(FATAL_ERROR "Failed to enable required SSE CPU extensions")
426 option(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
427 option(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
428 if(ALSOFT_CPUEXT_SSE2 AND HAVE_SSE AND HAVE_EMMINTRIN_H)
431 if(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
432 message(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
435 option(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
436 option(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF)
437 if(ALSOFT_CPUEXT_SSE3 AND HAVE_SSE2 AND HAVE_PMMINTRIN_H)
440 if(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
441 message(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
444 option(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
445 option(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
446 if(ALSOFT_CPUEXT_SSE4_1 AND HAVE_SSE3 AND HAVE_SMMINTRIN_H)
449 if(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
450 message(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
453 # Check for ARM Neon support
454 option(ALSOFT_CPUEXT_NEON "Enable ARM NEON support" ON)
455 option(ALSOFT_REQUIRE_NEON "Require ARM NEON support" OFF)
456 if(ALSOFT_CPUEXT_NEON AND HAVE_ARM_NEON_H)
457 check_c_source_compiles("#include <arm_neon.h>
460 int32x4_t ret4 = vdupq_n_s32(0);
461 return vgetq_lane_s32(ret4, 0);
462 }" HAVE_NEON_INTRINSICS)
463 if(HAVE_NEON_INTRINSICS)
467 if(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
468 message(FATAL_ERROR "Failed to enable required ARM NEON CPU extensions")
472 set(ALSOFT_FORCE_ALIGN )
475 if(CMAKE_SIZEOF_VOID_P MATCHES "4" AND HAVE_SSE2)
476 option(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
477 if(ALSOFT_ENABLE_SSE2_CODEGEN)
479 check_c_compiler_flag("/arch:SSE2" HAVE_ARCH_SSE2)
481 set(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
482 set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
486 check_c_compiler_flag("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
487 if(HAVE_MFPMATH_SSE_2)
488 set(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
489 set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
492 # SSE depends on a 16-byte aligned stack, and by default, GCC
493 # assumes the stack is suitably aligned. Older Linux code or other
494 # OSs don't guarantee this on 32-bit, so externally-callable
495 # functions need to ensure an aligned stack.
496 set(EXPORT_DECL "${EXPORT_DECL}__attribute__((force_align_arg_pointer))")
497 set(ALSOFT_FORCE_ALIGN "__attribute__((force_align_arg_pointer))")
503 set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
504 foreach(flag_var ${SSE_FLAGS})
505 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
508 check_c_source_compiles("#include <emmintrin.h>
509 int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
511 set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
515 check_include_file(malloc.h HAVE_MALLOC_H)
516 check_include_file(cpuid.h HAVE_CPUID_H)
517 check_include_file(intrin.h HAVE_INTRIN_H)
518 check_include_file(guiddef.h HAVE_GUIDDEF_H)
519 if(NOT HAVE_GUIDDEF_H)
520 check_include_file(initguid.h HAVE_INITGUID_H)
523 # Some systems need libm for some math functions to work
525 check_library_exists(m pow "" HAVE_LIBM)
527 set(MATH_LIB ${MATH_LIB} m)
528 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
531 # Some systems need to link with -lrt for clock_gettime as used by the common
534 check_library_exists(rt clock_gettime "" HAVE_LIBRT)
539 # Check for the dlopen API (for dynamically loading backend libs)
541 check_include_file(dlfcn.h HAVE_DLFCN_H)
542 check_library_exists(dl dlopen "" HAVE_LIBDL)
544 set(EXTRA_LIBS dl ${EXTRA_LIBS})
545 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
549 # Check for a cpuid intrinsic
551 check_c_source_compiles("#include <cpuid.h>
554 unsigned int eax, ebx, ecx, edx;
555 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
556 }" HAVE_GCC_GET_CPUID)
559 check_c_source_compiles("#include <intrin.h>
565 }" HAVE_CPUID_INTRINSIC)
568 check_symbol_exists(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
571 # We need pthreads outside of Windows, for semaphores. It's also used to
572 # set the priority and name of threads, when possible.
573 check_include_file(pthread.h HAVE_PTHREAD_H)
574 if(NOT HAVE_PTHREAD_H)
575 message(FATAL_ERROR "PThreads is required for non-Windows builds!")
578 check_c_compiler_flag(-pthread HAVE_PTHREAD)
580 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
581 set(C_FLAGS ${C_FLAGS} -pthread)
582 set(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
585 check_symbol_exists(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
587 # Some systems need pthread_np.h to get pthread_setname_np
588 check_include_files("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
589 if(HAVE_PTHREAD_NP_H)
590 check_symbol_exists(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
591 if(NOT HAVE_PTHREAD_SETNAME_NP)
592 check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
595 check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
596 if(NOT HAVE_PTHREAD_SETNAME_NP)
597 check_symbol_exists(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
602 check_symbol_exists(getopt unistd.h HAVE_GETOPT)
605 # Common sources used by both the OpenAL implementation library, the OpenAL
606 # router, and certain tools and examples.
619 common/althrd_setname.cpp
620 common/althrd_setname.h
628 common/intrusive_ptr.h
632 common/phase_shifter.h
633 common/polyphase_resampler.cpp
634 common/polyphase_resampler.h
636 common/ringbuffer.cpp
643 # Core library routines
655 core/bsinc_tables.cpp
658 core/buffer_storage.cpp
659 core/buffer_storage.h
667 core/cubic_tables.cpp
678 core/filters/biquad.h
679 core/filters/biquad.cpp
682 core/filters/splitter.cpp
683 core/filters/splitter.h
688 core/front_stablizer.h
699 core/resampler_limits.h
709 option(ALSOFT_RTKIT "Enable RTKit support" ON)
710 option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE)
712 find_package(DBus1 QUIET)
713 if(NOT DBus1_FOUND AND PkgConfig_FOUND)
714 pkg_check_modules(DBUS dbus-1)
716 if(DBus1_FOUND OR DBUS_FOUND)
718 set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h
719 core/rtkit.cpp core/rtkit.h)
721 set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS})
722 set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER})
724 set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES})
727 set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS})
728 set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS})
730 set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES})
735 if(NOT DBus1_INCLUDE_DIRS)
736 set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS")
738 if(NOT DBus1_LIBRARIES)
739 set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES")
741 message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})")
745 if(ALSOFT_REQUIRE_RTKIT AND NOT HAVE_RTKIT)
746 message(FATAL_ERROR "Failed to enable required RTKit support")
749 # Default mixers, always available
750 set(CORE_OBJS ${CORE_OBJS}
752 core/mixer/hrtfbase.h
753 core/mixer/hrtfdefs.h
754 core/mixer/mixer_c.cpp)
756 # AL and related routines
767 al/effects/autowah.cpp
768 al/effects/chorus.cpp
769 al/effects/compressor.cpp
770 al/effects/convolution.cpp
771 al/effects/dedicated.cpp
772 al/effects/distortion.cpp
774 al/effects/effects.cpp
776 al/effects/equalizer.cpp
777 al/effects/fshifter.cpp
778 al/effects/modulator.cpp
780 al/effects/pshifter.cpp
781 al/effects/reverb.cpp
782 al/effects/vmorpher.cpp
795 # ALC and related routines
807 alc/effects/autowah.cpp
808 alc/effects/chorus.cpp
809 alc/effects/compressor.cpp
810 alc/effects/convolution.cpp
811 alc/effects/dedicated.cpp
812 alc/effects/distortion.cpp
814 alc/effects/equalizer.cpp
815 alc/effects/fshifter.cpp
816 alc/effects/modulator.cpp
818 alc/effects/pshifter.cpp
819 alc/effects/reverb.cpp
820 alc/effects/vmorpher.cpp
837 al/eax/fx_slot_index.cpp
838 al/eax/fx_slot_index.h
848 # Include SIMD mixers
849 set(CPU_EXTS "Default")
851 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse.cpp)
852 set(CPU_EXTS "${CPU_EXTS}, SSE")
855 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse2.cpp)
856 set(CPU_EXTS "${CPU_EXTS}, SSE2")
859 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse3.cpp)
860 set(CPU_EXTS "${CPU_EXTS}, SSE3")
863 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse41.cpp)
864 set(CPU_EXTS "${CPU_EXTS}, SSE4.1")
867 set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_neon.cpp)
868 set(CPU_EXTS "${CPU_EXTS}, Neon")
880 set(HAVE_PORTAUDIO 0)
881 set(HAVE_PULSEAUDIO 0)
882 set(HAVE_COREAUDIO 0)
888 if(WIN32 OR HAVE_DLFCN_H)
890 macro(ADD_BACKEND_LIBS _LIBS)
893 set(IS_LINKED " (linked)")
894 macro(ADD_BACKEND_LIBS _LIBS)
895 set(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
900 set(ALC_OBJS ${ALC_OBJS}
901 alc/backends/base.cpp
903 # Default backends, always available
904 alc/backends/loopback.cpp
905 alc/backends/loopback.h
906 alc/backends/null.cpp
910 # Check PipeWire backend
911 option(ALSOFT_BACKEND_PIPEWIRE "Enable PipeWire backend" ON)
912 option(ALSOFT_REQUIRE_PIPEWIRE "Require PipeWire backend" OFF)
913 if(ALSOFT_BACKEND_PIPEWIRE AND PkgConfig_FOUND)
914 pkg_check_modules(PIPEWIRE libpipewire-0.3>=0.3.23)
917 set(BACKENDS "${BACKENDS} PipeWire${IS_LINKED},")
918 set(ALC_OBJS ${ALC_OBJS} alc/backends/pipewire.cpp alc/backends/pipewire.h)
919 add_backend_libs(${PIPEWIRE_LIBRARIES})
920 set(INC_PATHS ${INC_PATHS} ${PIPEWIRE_INCLUDE_DIRS})
923 if(ALSOFT_REQUIRE_PIPEWIRE AND NOT HAVE_PIPEWIRE)
924 message(FATAL_ERROR "Failed to enable required PipeWire backend")
927 # Check PulseAudio backend
928 option(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
929 option(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
930 if(ALSOFT_BACKEND_PULSEAUDIO)
931 find_package(PulseAudio)
933 set(HAVE_PULSEAUDIO 1)
934 set(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
935 set(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h)
936 add_backend_libs(${PULSEAUDIO_LIBRARY})
937 set(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIR})
940 if(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
941 message(FATAL_ERROR "Failed to enable required PulseAudio backend")
946 option(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
947 option(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
948 if(ALSOFT_BACKEND_ALSA)
952 set(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
953 set(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h)
954 add_backend_libs(${ALSA_LIBRARIES})
955 set(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
960 option(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
961 option(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
962 if(ALSOFT_BACKEND_OSS)
966 set(BACKENDS "${BACKENDS} OSS,")
967 set(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h)
969 set(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
971 set(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
975 # Check Solaris backend
976 option(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
977 option(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
978 if(ALSOFT_BACKEND_SOLARIS)
979 find_package(AudioIO)
982 set(BACKENDS "${BACKENDS} Solaris,")
983 set(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h)
984 set(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
988 # Check SndIO backend
989 option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
990 option(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
991 if(ALSOFT_BACKEND_SNDIO)
992 find_package(SoundIO)
995 set(BACKENDS "${BACKENDS} SndIO (linked),")
996 set(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h)
997 set(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
998 set(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
1002 if(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
1003 message(FATAL_ERROR "Failed to enable required ALSA backend")
1005 if(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
1006 message(FATAL_ERROR "Failed to enable required OSS backend")
1008 if(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
1009 message(FATAL_ERROR "Failed to enable required Solaris backend")
1011 if(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
1012 message(FATAL_ERROR "Failed to enable required SndIO backend")
1015 # Check Windows-only backends
1018 # Check MMSystem backend
1019 option(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
1020 option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
1021 if(ALSOFT_BACKEND_WINMM)
1023 set(BACKENDS "${BACKENDS} WinMM,")
1024 set(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h)
1025 # There doesn't seem to be good way to search for winmm.lib for MSVC.
1026 # find_library doesn't find it without being told to look in a specific
1027 # place in the WindowsSDK, but it links anyway. If there ends up being
1028 # Windows targets without this, another means to detect it is needed.
1029 set(EXTRA_LIBS winmm ${EXTRA_LIBS})
1032 # Check DSound backend
1033 option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
1034 option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
1035 if(ALSOFT_BACKEND_DSOUND)
1036 check_include_file(dsound.h HAVE_DSOUND_H)
1038 find_path(DSOUND_INCLUDE_DIR NAMES "dsound.h"
1039 PATHS "${DXSDK_DIR}" PATH_SUFFIXES include
1040 DOC "The DirectSound include directory")
1042 if(HAVE_DSOUND_H OR DSOUND_INCLUDE_DIR)
1044 set(BACKENDS "${BACKENDS} DirectSound,")
1045 set(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h)
1047 if(NOT HAVE_DSOUND_H)
1048 set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR})
1054 # Check for WASAPI backend
1055 option(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
1056 option(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
1057 if(ALSOFT_BACKEND_WASAPI)
1058 check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
1059 if(HAVE_MMDEVICEAPI_H)
1061 set(BACKENDS "${BACKENDS} WASAPI,")
1062 set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h)
1066 if(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
1067 message(FATAL_ERROR "Failed to enable required WinMM backend")
1069 if(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
1070 message(FATAL_ERROR "Failed to enable required DSound backend")
1072 if(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
1073 message(FATAL_ERROR "Failed to enable required WASAPI 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)
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 SDL2_FOUND)
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(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}/openal.pc.in"
1333 "${OpenAL_BINARY_DIR}/openal.pc"
1337 add_library(alcommon STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS})
1338 target_include_directories(alcommon PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/include
1339 PUBLIC ${OpenAL_SOURCE_DIR}/common)
1340 target_compile_definitions(alcommon PRIVATE ${CPP_DEFS})
1341 target_compile_options(alcommon PRIVATE ${C_FLAGS})
1342 set_target_properties(alcommon PROPERTIES ${DEFAULT_TARGET_PROPS} POSITION_INDEPENDENT_CODE TRUE)
1346 set(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal.
1348 # Build main library
1349 if(LIBTYPE STREQUAL "STATIC")
1350 add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS})
1351 target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC)
1352 target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1355 # This option is for static linking OpenAL Soft into another project
1356 # that already defines the IDs. It is up to that project to ensure all
1357 # required IDs are defined.
1358 option(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
1359 if(ALSOFT_NO_UID_DEFS)
1360 target_compile_definitions(${IMPL_TARGET} PRIVATE AL_NO_UID_DEFS)
1364 set(RC_CONFIG resources/openal32.rc)
1365 if(WIN32 AND ALSOFT_BUILD_ROUTER)
1366 add_library(OpenAL SHARED
1373 target_compile_definitions(OpenAL
1374 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}"
1375 "AL_API=${EXPORT_DECL}" ${CPP_DEFS})
1376 target_compile_options(OpenAL PRIVATE ${C_FLAGS})
1377 target_link_libraries(OpenAL PRIVATE alcommon ${LINKER_FLAGS})
1378 target_include_directories(OpenAL
1380 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1381 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1383 ${OpenAL_SOURCE_DIR}/common
1384 ${OpenAL_BINARY_DIR}
1386 set_target_properties(OpenAL PROPERTIES ${DEFAULT_TARGET_PROPS} PREFIX ""
1387 OUTPUT_NAME ${LIBNAME})
1388 if(TARGET build_version)
1389 add_dependencies(OpenAL build_version)
1393 set(LIBNAME "soft_oal")
1394 set(IMPL_TARGET soft_oal)
1395 set(RC_CONFIG resources/soft_oal.rc)
1398 # !important: for osx framework public header works, the headers must be in
1400 set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h
1401 include/AL/efx-presets.h)
1403 add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS} ${RC_CONFIG}
1404 ${TARGET_PUBLIC_HEADERS})
1406 set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "")
1408 target_link_libraries(${IMPL_TARGET} PRIVATE alcommon ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
1411 set(ALSOFT_CPPWINRT_VERSION "2.0.230706.1" CACHE STRING "The soft-oal default cppwinrt version")
1413 find_program(NUGET_EXE NAMES nuget)
1415 message("NUGET.EXE not found.")
1416 message(FATAL_ERROR "Please install this executable, and run CMake again.")
1419 exec_program(${NUGET_EXE}
1420 ARGS install "Microsoft.Windows.CppWinRT" -Version ${ALSOFT_CPPWINRT_VERSION} -ExcludeVersion -OutputDirectory "\"${CMAKE_BINARY_DIR}/packages\"")
1422 set_target_properties(${IMPL_TARGET} PROPERTIES
1423 VS_PROJECT_IMPORT ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.props
1425 target_link_libraries(${IMPL_TARGET} PRIVATE ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets)
1428 if(NOT WIN32 AND NOT APPLE)
1429 # FIXME: This doesn't put a dependency on the version script. Changing
1430 # the version script will not cause a relink as it should.
1431 target_link_options(${IMPL_TARGET} PRIVATE
1432 "-Wl,--version-script=${OpenAL_SOURCE_DIR}/libopenal.version")
1435 if(APPLE AND ALSOFT_OSX_FRAMEWORK)
1436 # Sets framework name to soft_oal to avoid ambiguity with the system OpenAL.framework
1437 set(LIBNAME "soft_oal")
1439 execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
1441 OUTPUT_VARIABLE BUNDLE_VERSION
1442 OUTPUT_STRIP_TRAILING_WHITESPACE)
1444 set(BUNDLE_VERSION 1)
1447 # Build: Fix rpath in iOS shared libraries
1448 # If this flag is not set, the final dylib binary ld path will be
1449 # /User/xxx/*/soft_oal.framework/soft_oal, which can't be loaded by iOS devices.
1450 # See also: https://github.com/libjpeg-turbo/libjpeg-turbo/commit/c80ddef7a4ce21ace9e3ca0fd190d320cc8cdaeb
1451 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
1452 set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
1455 set_target_properties(${IMPL_TARGET} PROPERTIES
1458 MACOSX_FRAMEWORK_NAME "${IMPL_TARGET}"
1459 MACOSX_FRAMEWORK_IDENTIFIER "org.openal-soft.openal"
1460 MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${LIB_VERSION}"
1461 MACOSX_FRAMEWORK_BUNDLE_VERSION "${BUNDLE_VERSION}"
1462 XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
1463 XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
1464 XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
1465 PUBLIC_HEADER "${TARGET_PUBLIC_HEADERS}"
1470 target_include_directories(${IMPL_TARGET}
1472 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
1474 $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include/AL>
1475 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1476 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/AL>
1479 ${OpenAL_BINARY_DIR}
1480 ${OpenAL_SOURCE_DIR}
1481 ${OpenAL_SOURCE_DIR}/common
1484 set_target_properties(${IMPL_TARGET} PROPERTIES ${DEFAULT_TARGET_PROPS}
1485 OUTPUT_NAME ${LIBNAME}
1486 VERSION ${LIB_VERSION}
1487 SOVERSION ${LIB_MAJOR_VERSION}
1489 target_compile_definitions(${IMPL_TARGET}
1490 PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}"
1492 target_compile_options(${IMPL_TARGET} PRIVATE ${C_FLAGS})
1494 if(TARGET build_version)
1495 add_dependencies(${IMPL_TARGET} build_version)
1498 if(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
1499 find_program(SED_EXECUTABLE NAMES sed DOC "sed executable")
1500 if(NOT SED_EXECUTABLE OR NOT CMAKE_DLLTOOL)
1502 if(NOT SED_EXECUTABLE)
1503 message(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1505 if(NOT CMAKE_DLLTOOL)
1506 message(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1509 target_link_options(OpenAL PRIVATE "-Wl,--output-def,OpenAL32.def")
1510 add_custom_command(TARGET OpenAL POST_BUILD
1511 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
1512 COMMAND "${CMAKE_DLLTOOL}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
1513 # Technically OpenAL32.def was created by the build, but cmake
1514 # doesn't recognize it due to -Wl,--output-def,OpenAL32.def being
1515 # manually specified. But declaring the file here allows it to be
1516 # properly cleaned, e.g. during make clean.
1517 BYPRODUCTS OpenAL32.def OpenAL32.lib
1518 COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
1526 message(STATUS "Building DLL router")
1530 message(STATUS "Building OpenAL with support for the following backends:")
1531 message(STATUS " ${BACKENDS}")
1533 message(STATUS "Building with support for CPU extensions:")
1534 message(STATUS " ${CPU_EXTS}")
1537 message(STATUS "Building with SSE${FPMATH_SET} codegen")
1541 message(STATUS "Building with UWP support")
1545 message(STATUS "Building with legacy EAX extension support")
1549 if(ALSOFT_EMBED_HRTF_DATA)
1550 message(STATUS "Embedding HRTF datasets")
1554 # An alias for sub-project builds
1555 add_library(OpenAL::OpenAL ALIAS OpenAL)
1557 # Install main library
1559 configure_package_config_file(OpenALConfig.cmake.in OpenALConfig.cmake
1560 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL)
1561 install(TARGETS OpenAL EXPORT OpenAL
1562 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1563 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1564 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1565 FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
1566 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL)
1567 export(TARGETS OpenAL
1569 FILE OpenALTargets.cmake)
1570 install(EXPORT OpenAL
1571 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
1573 FILE OpenALTargets.cmake)
1574 install(DIRECTORY include/AL
1575 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
1576 install(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1577 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1578 install(FILES "${OpenAL_BINARY_DIR}/OpenALConfig.cmake"
1579 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL")
1581 install(TARGETS soft_oal
1582 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1584 message(STATUS "Installing library and headers")
1586 message(STATUS "NOT installing library and headers")
1589 if(ALSOFT_INSTALL_CONFIG)
1590 install(FILES alsoftrc.sample
1591 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1592 message(STATUS "Installing sample configuration")
1595 if(ALSOFT_INSTALL_HRTF_DATA)
1596 install(DIRECTORY hrtf
1597 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1598 message(STATUS "Installing HRTF data files")
1601 if(ALSOFT_INSTALL_AMBDEC_PRESETS)
1602 install(DIRECTORY presets
1603 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal)
1604 message(STATUS "Installing AmbDec presets")
1610 set(UNICODE_FLAG ${UNICODE_FLAG} -municode)
1612 set(EXTRA_INSTALLS )
1614 add_executable(openal-info utils/openal-info.c)
1615 target_include_directories(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
1616 target_compile_options(openal-info PRIVATE ${C_FLAGS})
1617 target_link_libraries(openal-info PRIVATE ${LINKER_FLAGS} OpenAL ${UNICODE_FLAG})
1618 set_target_properties(openal-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1619 if(ALSOFT_INSTALL_EXAMPLES)
1620 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} openal-info)
1624 add_executable(uhjdecoder utils/uhjdecoder.cpp)
1625 target_compile_definitions(uhjdecoder PRIVATE ${CPP_DEFS})
1626 target_include_directories(uhjdecoder
1627 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1628 target_compile_options(uhjdecoder PRIVATE ${C_FLAGS})
1629 target_link_libraries(uhjdecoder PUBLIC alcommon
1630 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1631 set_target_properties(uhjdecoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1633 add_executable(uhjencoder utils/uhjencoder.cpp)
1634 target_compile_definitions(uhjencoder PRIVATE ${CPP_DEFS})
1635 target_include_directories(uhjencoder
1636 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common)
1637 target_compile_options(uhjencoder PRIVATE ${C_FLAGS})
1638 target_link_libraries(uhjencoder PUBLIC alcommon
1639 PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG})
1640 set_target_properties(uhjencoder PROPERTIES ${DEFAULT_TARGET_PROPS})
1644 set(SOFA_SUPPORT_SRCS
1645 utils/sofa-support.cpp
1646 utils/sofa-support.h)
1647 add_library(sofa-support STATIC EXCLUDE_FROM_ALL ${SOFA_SUPPORT_SRCS})
1648 target_compile_definitions(sofa-support PRIVATE ${CPP_DEFS})
1649 target_include_directories(sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/common)
1650 target_compile_options(sofa-support PRIVATE ${C_FLAGS})
1651 target_link_libraries(sofa-support PUBLIC alcommon MySOFA::MySOFA PRIVATE ${LINKER_FLAGS})
1652 set_target_properties(sofa-support PROPERTIES ${DEFAULT_TARGET_PROPS})
1655 utils/makemhr/loaddef.cpp
1656 utils/makemhr/loaddef.h
1657 utils/makemhr/loadsofa.cpp
1658 utils/makemhr/loadsofa.h
1659 utils/makemhr/makemhr.cpp
1660 utils/makemhr/makemhr.h)
1662 set(MAKEMHR_SRCS ${MAKEMHR_SRCS} utils/getopt.c utils/getopt.h)
1664 add_executable(makemhr ${MAKEMHR_SRCS})
1665 target_compile_definitions(makemhr PRIVATE ${CPP_DEFS})
1666 target_include_directories(makemhr
1667 PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils)
1668 target_compile_options(makemhr PRIVATE ${C_FLAGS})
1669 target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} sofa-support ${UNICODE_FLAG})
1670 set_target_properties(makemhr PROPERTIES ${DEFAULT_TARGET_PROPS})
1671 if(ALSOFT_INSTALL_EXAMPLES)
1672 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} makemhr)
1675 set(SOFAINFO_SRCS utils/sofa-info.cpp)
1676 add_executable(sofa-info ${SOFAINFO_SRCS})
1677 target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS})
1678 target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/utils)
1679 target_compile_options(sofa-info PRIVATE ${C_FLAGS})
1680 target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} sofa-support ${UNICODE_FLAG})
1681 set_target_properties(sofa-info PROPERTIES ${DEFAULT_TARGET_PROPS})
1683 message(STATUS "Building utility programs")
1685 if(NOT ALSOFT_NO_CONFIG_UTIL)
1686 add_subdirectory(utils/alsoft-config)
1692 # Add a static library with common functions used by multiple example targets
1693 add_library(al-excommon STATIC EXCLUDE_FROM_ALL
1694 examples/common/alhelpers.c
1695 examples/common/alhelpers.h)
1696 target_compile_definitions(al-excommon PUBLIC ${CPP_DEFS})
1697 target_include_directories(al-excommon PUBLIC ${OpenAL_SOURCE_DIR}/common)
1698 target_compile_options(al-excommon PUBLIC ${C_FLAGS})
1699 target_link_libraries(al-excommon PUBLIC OpenAL PRIVATE ${RT_LIB})
1700 set_target_properties(al-excommon PROPERTIES ${DEFAULT_TARGET_PROPS})
1703 add_executable(altonegen examples/altonegen.c)
1704 target_link_libraries(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} al-excommon ${UNICODE_FLAG})
1705 set_target_properties(altonegen PROPERTIES ${DEFAULT_TARGET_PROPS})
1707 add_executable(alrecord examples/alrecord.c)
1708 target_link_libraries(alrecord PRIVATE ${LINKER_FLAGS} al-excommon ${UNICODE_FLAG})
1709 set_target_properties(alrecord PROPERTIES ${DEFAULT_TARGET_PROPS})
1711 if(ALSOFT_INSTALL_EXAMPLES)
1712 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} altonegen alrecord)
1715 message(STATUS "Building example programs")
1718 add_executable(alplay examples/alplay.c)
1719 target_link_libraries(alplay PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1721 set_target_properties(alplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1723 add_executable(alstream examples/alstream.c)
1724 target_link_libraries(alstream PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1726 set_target_properties(alstream PROPERTIES ${DEFAULT_TARGET_PROPS})
1728 add_executable(alreverb examples/alreverb.c)
1729 target_link_libraries(alreverb PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1731 set_target_properties(alreverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1733 add_executable(almultireverb examples/almultireverb.c)
1734 target_link_libraries(almultireverb
1735 PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon ${MATH_LIB} ${UNICODE_FLAG})
1736 set_target_properties(almultireverb PROPERTIES ${DEFAULT_TARGET_PROPS})
1738 add_executable(allatency examples/allatency.c)
1739 target_link_libraries(allatency PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1741 set_target_properties(allatency PROPERTIES ${DEFAULT_TARGET_PROPS})
1743 add_executable(alhrtf examples/alhrtf.c)
1744 target_link_libraries(alhrtf
1745 PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon ${MATH_LIB} ${UNICODE_FLAG})
1746 set_target_properties(alhrtf PROPERTIES ${DEFAULT_TARGET_PROPS})
1748 add_executable(alstreamcb examples/alstreamcb.cpp)
1749 target_link_libraries(alstreamcb PRIVATE ${LINKER_FLAGS} SndFile::SndFile al-excommon
1751 set_target_properties(alstreamcb PROPERTIES ${DEFAULT_TARGET_PROPS})
1753 add_executable(alconvolve examples/alconvolve.c)
1754 target_link_libraries(alconvolve PRIVATE ${LINKER_FLAGS} alcommon SndFile::SndFile
1755 al-excommon ${UNICODE_FLAG})
1756 set_target_properties(alconvolve PROPERTIES ${DEFAULT_TARGET_PROPS})
1758 if(ALSOFT_INSTALL_EXAMPLES)
1759 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alplay alstream alreverb almultireverb allatency
1763 message(STATUS "Building SndFile example programs")
1767 add_executable(alloopback examples/alloopback.c)
1768 target_link_libraries(alloopback
1769 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 al-excommon ${MATH_LIB})
1770 set_target_properties(alloopback PROPERTIES ${DEFAULT_TARGET_PROPS})
1772 if(ALSOFT_INSTALL_EXAMPLES)
1773 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alloopback)
1776 message(STATUS "Building SDL example programs")
1781 if(AVFORMAT_VERSION VERSION_LESS "59.27.100")
1782 message(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 59.27.100)")
1785 if(AVCODEC_VERSION VERSION_LESS "59.37.100")
1786 message(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 59.37.100)")
1789 if(AVUTIL_VERSION VERSION_LESS "57.28.100")
1790 message(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 57.28.100)")
1793 if(SWSCALE_VERSION VERSION_LESS "6.7.100")
1794 message(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 6.7.100)")
1797 if(SWRESAMPLE_VERSION VERSION_LESS "4.7.100")
1798 message(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 4.7.100)")
1803 add_executable(alffplay examples/alffplay.cpp)
1804 target_include_directories(alffplay PRIVATE ${FFMPEG_INCLUDE_DIRS})
1805 target_link_libraries(alffplay
1806 PRIVATE ${LINKER_FLAGS} SDL2::SDL2 ${FFMPEG_LIBRARIES} al-excommon)
1807 set_target_properties(alffplay PROPERTIES ${DEFAULT_TARGET_PROPS})
1809 if(ALSOFT_INSTALL_EXAMPLES)
1810 set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alffplay)
1812 message(STATUS "Building SDL+FFmpeg example programs")
1819 add_subdirectory(tests)
1823 install(TARGETS ${EXTRA_INSTALLS}
1824 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1825 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
1826 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1827 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})