1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
7 IF(COMMAND CMAKE_POLICY)
8 CMAKE_POLICY(SET CMP0003 NEW)
9 CMAKE_POLICY(SET CMP0005 NEW)
11 CMAKE_POLICY(SET CMP0042 NEW)
13 ENDIF(COMMAND CMAKE_POLICY)
15 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
17 INCLUDE(CheckFunctionExists)
18 INCLUDE(CheckLibraryExists)
19 INCLUDE(CheckSharedFunctionExists)
20 INCLUDE(CheckIncludeFile)
21 INCLUDE(CheckIncludeFiles)
22 INCLUDE(CheckSymbolExists)
23 INCLUDE(CheckCCompilerFlag)
24 INCLUDE(CheckCSourceCompiles)
25 INCLUDE(CheckTypeSize)
26 include(CheckFileOffsetBits)
29 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
32 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
34 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
36 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
37 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
39 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
40 OPTION(ALSOFT_TESTS "Build and install test programs" ON)
42 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
43 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
44 OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
45 OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
48 set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "The share install dir")
55 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
57 # This option is mainly for static linking OpenAL Soft into another project
58 # that already defines the IDs. It is up to that project to ensure all
59 # required IDs are defined.
60 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
63 OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
66 SET(DLLTOOL "${HOST}-dlltool")
68 SET(DLLTOOL "dlltool")
75 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
76 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
77 ADD_DEFINITIONS("-I/usr/include")
78 SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
85 SET(LIB_MAJOR_VERSION "1")
86 SET(LIB_MINOR_VERSION "17")
88 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
94 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
95 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
98 CHECK_C_COMPILER_FLAG(-std=c11 HAVE_STD_C11)
100 SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
102 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
104 SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
109 # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
110 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
111 IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
112 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
113 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500")
114 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
115 IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
116 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
118 ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500)
121 UNSET(OLD_REQUIRED_FLAGS)
124 # Set defines for large file support
125 CHECK_FILE_OFFSET_BITS()
126 IF(_FILE_OFFSET_BITS)
127 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
128 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
130 ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES)
131 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
133 # MSVC may need workarounds for C99 restrict and inline
135 # TODO: Once we truly require C99, these restrict and inline checks should go
137 CHECK_C_SOURCE_COMPILES("int *restrict foo;
138 int main() {return 0;}" HAVE_RESTRICT)
139 IF(NOT HAVE_RESTRICT)
140 ADD_DEFINITIONS("-Drestrict=")
141 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
144 CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
145 int main() {return 0;}" HAVE_INLINE)
147 CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
148 int main() {return 0;}" HAVE___INLINE)
149 IF(NOT HAVE___INLINE)
150 MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
153 ADD_DEFINITIONS(-Dinline=__inline)
154 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
158 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
159 IF(CMAKE_COMPILER_IS_GNUCC)
160 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
161 # Force no inlining for the next test.
162 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
164 CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
165 int main() {return foo();}" INLINE_IS_C99)
166 IF(NOT INLINE_IS_C99)
167 MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
168 Please update your compiler for better C99 compliance.")
171 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
174 # Check if we have C99 variable length arrays
175 CHECK_C_SOURCE_COMPILES(
176 "int main(int argc, char *argv[])
178 volatile int tmp[argc];
184 # Check if we have C99 bool
185 CHECK_C_SOURCE_COMPILES(
186 "int main(int argc, char *argv[])
189 ret = (argc > 1) ? 1 : 0;
194 # Check if we have C11 static_assert
195 CHECK_C_SOURCE_COMPILES(
198 _Static_assert(sizeof(int) == sizeof(int), \"What\");
201 HAVE_C11_STATIC_ASSERT)
203 # Check if we have C11 alignas
204 CHECK_C_SOURCE_COMPILES(
205 "_Alignas(16) int foo;
212 # Check if we have C11 _Atomic
213 CHECK_C_SOURCE_COMPILES(
214 "#include <stdatomic.h>
215 const int _Atomic foo = ATOMIC_VAR_INIT(~0);
218 return atomic_load(&foo);
222 # Add definitions, compiler switches, etc.
223 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
224 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
225 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
226 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
227 ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
231 IF(NOT CMAKE_BUILD_TYPE)
232 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
233 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
236 IF(NOT CMAKE_DEBUG_POSTFIX)
237 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
238 "Library postfix for debug builds. Normally left blank."
243 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
244 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
245 ADD_DEFINITIONS("/wd4098")
248 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
250 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
253 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
256 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
257 IF(FORCE_STATIC_VCRT)
259 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
260 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
261 IF(${flag_var} MATCHES "/MD")
262 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
267 ADD_DEFINITIONS(-Winline -Wall)
268 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
270 ADD_DEFINITIONS(-Wextra)
274 ADD_DEFINITIONS(-Werror)
277 # Force enable -fPIC for CMake versions before 2.8.9 (later versions have
278 # the POSITION_INDEPENDENT_CODE target property). The static common library
279 # will be linked into the dynamic openal library, which requires all its
280 # code to be position-independent.
281 IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
282 CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
284 ADD_DEFINITIONS(-fPIC)
288 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
290 FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
291 IF(${flag_var} MATCHES "-DNDEBUG")
292 STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
296 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
297 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
299 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
300 if(ALSOFT_STATIC_LIBGCC)
301 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
302 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
303 check_c_source_compiles(
309 HAVE_STATIC_LIBGCC_SWITCH
311 if(HAVE_STATIC_LIBGCC_SWITCH)
312 set(EXTRA_LIBS ${EXTRA_LIBS} -static-libgcc)
314 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
315 unset(OLD_REQUIRED_LIBRARIES)
319 # Set visibility/export options if available
321 SET(EXPORT_DECL "__declspec(dllexport)")
323 SET(ALIGN_DECL "__declspec(align(x))")
325 SET(ALIGN_DECL "__declspec(aligned(x))")
328 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
329 # Yes GCC, really don't accept visibility modes you don't support
330 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
332 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
333 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
334 IF(HAVE_GCC_PROTECTED_VISIBILITY)
335 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
337 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
338 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
339 IF(HAVE_GCC_DEFAULT_VISIBILITY)
340 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
344 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
345 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
346 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
347 ADD_DEFINITIONS(-fvisibility=hidden)
351 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
352 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
353 IF(HAVE_ATTRIBUTE_ALIGNED)
354 SET(ALIGN_DECL "__attribute__((aligned(x)))")
357 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
363 SET(SSE4_1_SWITCH "")
365 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
367 SET(SSE_SWITCH "-msse")
369 CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
370 IF(HAVE_MSSE2_SWITCH)
371 SET(SSE2_SWITCH "-msse2")
373 CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
374 IF(HAVE_MSSE3_SWITCH)
375 SET(SSE3_SWITCH "-msse3")
377 CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
378 IF(HAVE_MSSE4_1_SWITCH)
379 SET(SSE4_1_SWITCH "-msse4.1")
383 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
384 int main() {return 0;}" HAVE_GCC_FORMAT)
386 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
387 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
388 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
389 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
390 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
391 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
392 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
393 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
394 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
395 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
396 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
397 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
398 IF(NOT HAVE_GUIDDEF_H)
399 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
402 # Some systems need libm for some of the following math functions to work
403 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
405 SET(EXTRA_LIBS m ${EXTRA_LIBS})
406 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
409 # Check for the dlopen API (for dynamicly loading backend libs)
411 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
413 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
414 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
417 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
420 # Check for a cpuid intrinsic
422 CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
425 unsigned int eax, ebx, ecx, edx;
426 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
427 }" HAVE_GCC_GET_CPUID)
430 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
436 }" HAVE_CPUID_INTRINSIC)
439 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
440 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
441 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
442 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
443 CHECK_SYMBOL_EXISTS(modff math.h HAVE_MODFF)
445 CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
447 MESSAGE(FATAL_ERROR "No alloca function found, please report!")
452 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
453 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
456 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
457 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
458 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
459 IF(NOT HAVE_STRCASECMP)
460 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
461 IF(NOT HAVE__STRICMP)
462 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
465 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
468 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
469 IF(NOT HAVE_STRNCASECMP)
470 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
471 IF(NOT HAVE__STRNICMP)
472 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
475 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
478 CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
479 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
480 IF(NOT HAVE_SNPRINTF)
481 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
482 IF(NOT HAVE__SNPRINTF)
483 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
486 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
489 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
490 IF(NOT HAVE_ISFINITE)
491 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
493 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
495 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
497 ADD_DEFINITIONS(-Disfinite=_finite)
499 ADD_DEFINITIONS(-Disfinite=finite)
503 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
505 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
507 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
510 ADD_DEFINITIONS(-Disnan=_isnan)
514 # Check if we have Windows headers
515 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
516 IF(NOT HAVE_WINDOWS_H)
517 CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
518 IF(NOT HAVE_GETTIMEOFDAY)
519 MESSAGE(FATAL_ERROR "No timing function found!")
522 CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
523 IF(NOT HAVE_NANOSLEEP)
524 MESSAGE(FATAL_ERROR "No sleep function found!")
527 # We need pthreads outside of Windows
528 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
529 IF(NOT HAVE_PTHREAD_H)
530 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
532 # Some systems need pthread_np.h to get recursive mutexes
533 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
535 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
537 ADD_DEFINITIONS(-pthread)
538 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
539 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
542 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
544 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
547 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
549 IF(HAVE_PTHREAD_NP_H)
550 CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
551 IF(NOT HAVE_PTHREAD_SETNAME_NP)
552 CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
554 CHECK_C_SOURCE_COMPILES("
556 #include <pthread_np.h>
559 pthread_setname_np(\"testname\");
562 PTHREAD_SETNAME_NP_ONE_PARAM
565 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
567 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
568 IF(NOT HAVE_PTHREAD_SETNAME_NP)
569 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
571 CHECK_C_SOURCE_COMPILES("
575 pthread_setname_np(\"testname\");
578 PTHREAD_SETNAME_NP_ONE_PARAM
581 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
584 CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
586 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
588 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
592 # Check for a 64-bit type
593 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
594 IF(NOT HAVE_STDINT_H)
596 CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
599 int main() {return 0;}" HAVE___INT64)
602 IF(NOT SIZEOF_LONG MATCHES "8")
603 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
604 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
611 SET(COMMON_OBJS common/almalloc.c
617 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
621 OpenAL32/alExtension.c
623 OpenAL32/alListener.c
627 OpenAL32/sample_cvt.c
629 SET(ALC_OBJS Alc/ALc.c
634 Alc/effects/autowah.c
636 Alc/effects/compressor.c
637 Alc/effects/dedicated.c
638 Alc/effects/distortion.c
640 Alc/effects/equalizer.c
641 Alc/effects/flanger.c
642 Alc/effects/modulator.c
657 SET(CPU_EXTS "Default")
672 SET(HAVE_PORTAUDIO 0)
673 SET(HAVE_PULSEAUDIO 0)
674 SET(HAVE_COREAUDIO 0)
678 # Check for SSE support
679 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
680 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
682 OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
683 IF(ALSOFT_CPUEXT_SSE)
684 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
686 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
688 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
689 COMPILE_FLAGS "${SSE_SWITCH}")
691 SET(CPU_EXTS "${CPU_EXTS}, SSE")
695 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
696 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
699 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
700 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
702 OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
703 IF(HAVE_SSE AND ALSOFT_CPUEXT_SSE2)
704 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
706 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse2.c)
708 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse2.c PROPERTIES
709 COMPILE_FLAGS "${SSE2_SWITCH}")
711 SET(CPU_EXTS "${CPU_EXTS}, SSE2")
715 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
716 MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
719 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE3 support" OFF)
720 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
722 OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
723 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
724 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
726 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse3.c)
728 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse3.c PROPERTIES
729 COMPILE_FLAGS "${SSE3_SWITCH}")
731 SET(CPU_EXTS "${CPU_EXTS}, SSE3")
735 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
736 MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
739 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
740 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
742 OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
743 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE4_1)
744 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
746 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse41.c)
748 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse41.c PROPERTIES
749 COMPILE_FLAGS "${SSE4_1_SWITCH}")
751 SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
755 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
756 MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
759 # Check for ARM Neon support
760 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
761 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
763 OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
764 IF(ALSOFT_CPUEXT_NEON)
766 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
767 SET(CPU_EXTS "${CPU_EXTS}, Neon")
770 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
771 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
775 IF(WIN32 OR HAVE_DLFCN_H)
777 MACRO(ADD_BACKEND_LIBS _LIBS)
780 SET(IS_LINKED " (linked)")
781 MACRO(ADD_BACKEND_LIBS _LIBS)
782 SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
787 SET(ALC_OBJS ${ALC_OBJS}
789 # Default backends, always available
790 Alc/backends/loopback.c
795 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
798 OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
799 IF(ALSOFT_BACKEND_ALSA)
801 SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
802 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
803 ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
804 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
805 INCLUDE_DIRECTORIES(${ALSA_INCLUDE_DIRS})
809 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
810 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
814 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
817 OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
818 IF(ALSOFT_BACKEND_OSS)
820 SET(BACKENDS "${BACKENDS} OSS,")
821 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
822 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
823 INCLUDE_DIRECTORIES(${OSS_INCLUDE_DIRS})
827 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
828 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
831 # Check Solaris backend
832 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
833 FIND_PACKAGE(AudioIO)
835 OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
836 IF(ALSOFT_BACKEND_SOLARIS)
838 SET(BACKENDS "${BACKENDS} Solaris,")
839 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
840 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
841 INCLUDE_DIRECTORIES(${AUDIOIO_INCLUDE_DIRS})
845 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
846 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
849 # Check SndIO backend
850 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
851 FIND_PACKAGE(SoundIO)
853 OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
854 IF(ALSOFT_BACKEND_SNDIO)
856 SET(BACKENDS "${BACKENDS} SndIO (linked),")
857 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
858 SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
859 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
860 INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
864 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
865 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
869 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
872 OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
873 IF(ALSOFT_BACKEND_QSA)
875 SET(BACKENDS "${BACKENDS} QSA (linked),")
876 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
877 SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
878 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
879 INCLUDE_DIRECTORIES(${QSA_INCLUDE_DIRS})
883 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
884 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
887 # Check Windows-only backends
888 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
889 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
890 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
892 # Check MMSystem backend
893 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
895 CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
897 OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
898 IF(ALSOFT_BACKEND_WINMM)
900 SET(BACKENDS "${BACKENDS} WinMM,")
901 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
902 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
907 # Check DSound backend
910 OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
911 IF(ALSOFT_BACKEND_DSOUND)
913 SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
914 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
915 ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
916 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
917 INCLUDE_DIRECTORIES(${DSOUND_INCLUDE_DIRS})
922 # Check for MMDevApi backend
923 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
924 IF(HAVE_MMDEVICEAPI_H)
925 OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
926 IF(ALSOFT_BACKEND_MMDEVAPI)
928 SET(BACKENDS "${BACKENDS} MMDevApi,")
929 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
933 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
934 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
936 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
937 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
939 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
940 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
943 # Check PortAudio backend
944 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
945 FIND_PACKAGE(PortAudio)
947 OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
948 IF(ALSOFT_BACKEND_PORTAUDIO)
949 SET(HAVE_PORTAUDIO 1)
950 SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
951 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
952 ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
953 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
954 INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
958 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
959 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
962 # Check PulseAudio backend
963 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
964 FIND_PACKAGE(PulseAudio)
966 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
967 IF(ALSOFT_BACKEND_PULSEAUDIO)
968 SET(HAVE_PULSEAUDIO 1)
969 SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
970 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
971 ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
972 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
973 INCLUDE_DIRECTORIES(${PULSEAUDIO_INCLUDE_DIRS})
977 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
978 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
982 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
985 OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
986 IF(ALSOFT_BACKEND_JACK)
988 SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
989 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/jack.c)
990 ADD_BACKEND_LIBS(${JACK_LIBRARIES})
991 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
992 INCLUDE_DIRECTORIES(${JACK_INCLUDE_DIRS})
996 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
997 MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
1000 # Check CoreAudio backend
1001 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1002 FIND_LIBRARY(COREAUDIO_FRAMEWORK
1004 PATHS /System/Library/Frameworks
1006 IF(COREAUDIO_FRAMEWORK)
1007 OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1008 IF(ALSOFT_BACKEND_COREAUDIO)
1009 SET(HAVE_COREAUDIO 1)
1010 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
1011 SET(BACKENDS "${BACKENDS} CoreAudio,")
1012 SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1013 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1014 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1016 # Some versions of OSX may need the AudioToolbox framework. Add it if
1018 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1020 PATHS ~/Library/Frameworks
1022 /System/Library/Frameworks
1024 IF(AUDIOTOOLBOX_LIBRARY)
1025 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1029 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1030 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1033 # Check for OpenSL (Android) backend
1034 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1035 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
1036 IF(HAVE_SLES_OPENSLES_ANDROID_H)
1037 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
1038 IF(HAVE_LIBOPENSLES)
1039 OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1040 IF(ALSOFT_BACKEND_OPENSL)
1042 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
1043 SET(BACKENDS "${BACKENDS} OpenSL,")
1044 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
1048 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1049 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1052 # Optionally enable the Wave Writer backend
1053 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1054 IF(ALSOFT_BACKEND_WAVE)
1056 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
1057 SET(BACKENDS "${BACKENDS} WaveFile,")
1060 # This is always available
1061 SET(BACKENDS "${BACKENDS} Null")
1063 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1064 add_subdirectory(utils/alsoft-config)
1069 FIND_PACKAGE(SDL_sound)
1070 IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1071 INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1073 FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1074 IF(FFMPEG_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1075 INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
1080 IF(LIBTYPE STREQUAL "STATIC")
1081 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
1082 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
1085 # Needed for openal.pc.in
1086 SET(prefix ${CMAKE_INSTALL_PREFIX})
1087 SET(exec_prefix "\${prefix}")
1088 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
1089 SET(bindir "\${exec_prefix}/bin")
1090 SET(includedir "\${prefix}/include")
1091 SET(PACKAGE_VERSION "${LIB_VERSION}")
1095 "${OpenAL_SOURCE_DIR}/config.h.in"
1096 "${OpenAL_BINARY_DIR}/config.h")
1098 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1099 "${OpenAL_BINARY_DIR}/openal.pc"
1102 # Build a common library with reusable helpers
1103 ADD_LIBRARY(common STATIC ${COMMON_OBJS})
1104 IF(NOT LIBTYPE STREQUAL "STATIC")
1105 SET_PROPERTY(TARGET common PROPERTY POSITION_INDEPENDENT_CODE TRUE)
1108 # Build main library
1109 IF(LIBTYPE STREQUAL "STATIC")
1110 ADD_LIBRARY(${LIBNAME} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1112 ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
1114 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
1115 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1116 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
1118 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
1120 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
1123 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
1126 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
1129 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
1132 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
1135 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
1138 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
1141 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
1144 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
1146 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
1147 SOVERSION ${LIB_MAJOR_VERSION})
1148 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
1149 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
1151 IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
1152 FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1153 FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1154 IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1156 IF(NOT SED_EXECUTABLE)
1157 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1159 IF(NOT DLLTOOL_EXECUTABLE)
1160 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1163 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--output-def,${LIBNAME}.def")
1164 ADD_CUSTOM_COMMAND(TARGET ${LIBNAME} POST_BUILD
1165 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" ${LIBNAME}.def
1166 COMMAND "${DLLTOOL_EXECUTABLE}" -d ${LIBNAME}.def -l ${LIBNAME}.lib -D ${LIBNAME}.dll
1167 COMMENT "Stripping ordinals from ${LIBNAME}.def and generating ${LIBNAME}.lib..."
1174 TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
1177 # Add an install target here
1178 INSTALL(TARGETS ${LIBNAME}
1179 RUNTIME DESTINATION bin
1180 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1181 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1183 INSTALL(FILES include/AL/al.h
1187 include/AL/efx-creative.h
1188 include/AL/efx-presets.h
1189 DESTINATION include/AL
1191 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1192 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
1197 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1198 MESSAGE(STATUS " ${BACKENDS}")
1200 MESSAGE(STATUS "Building with support for CPU extensions:")
1201 MESSAGE(STATUS " ${CPU_EXTS}")
1206 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1207 MESSAGE(STATUS " This is probably NOT what you want!")
1212 # Install alsoft.conf configuration file
1214 INSTALL(FILES alsoftrc.sample
1215 DESTINATION ${SHARE_INSTALL_DIR}/openal
1217 MESSAGE(STATUS "Installing sample configuration")
1221 # Install HRTF definitions
1222 IF(ALSOFT_HRTF_DEFS)
1223 INSTALL(FILES hrtf/default-44100.mhr
1224 hrtf/default-48000.mhr
1225 DESTINATION ${SHARE_INSTALL_DIR}/openal/hrtf
1227 MESSAGE(STATUS "Installing HRTF definitions")
1231 # Install AmbDec presets
1232 IF(ALSOFT_AMBDEC_PRESETS)
1233 INSTALL(FILES presets/3D7.1.ambdec
1234 presets/hexagon.ambdec
1235 presets/itu5.1.ambdec
1236 presets/rectangle.ambdec
1237 presets/square.ambdec
1239 DESTINATION ${SHARE_INSTALL_DIR}/openal/presets
1241 MESSAGE(STATUS "Installing HRTF definitions")
1246 ADD_EXECUTABLE(openal-info utils/openal-info.c)
1247 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
1249 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1251 TARGET_LINK_LIBRARIES(makehrtf m)
1254 ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
1256 TARGET_LINK_LIBRARIES(bsincgen m)
1260 INSTALL(TARGETS openal-info makehrtf bsincgen
1261 RUNTIME DESTINATION bin
1262 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1263 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1267 MESSAGE(STATUS "Building utility programs")
1268 IF(TARGET alsoft-config)
1269 MESSAGE(STATUS "Building configuration program")
1275 ADD_LIBRARY(test-common STATIC examples/common/alhelpers.c)
1277 ADD_EXECUTABLE(altonegen examples/altonegen.c)
1278 TARGET_LINK_LIBRARIES(altonegen test-common ${LIBNAME})
1281 INSTALL(TARGETS altonegen
1282 RUNTIME DESTINATION bin
1283 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1284 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1288 MESSAGE(STATUS "Building test programs")
1293 IF(SDL2_FOUND AND SDL_SOUND_FOUND)
1294 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1295 examples/common/sdl_sound.c)
1296 SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1297 ${SDL_SOUND_INCLUDE_DIR})
1299 ADD_EXECUTABLE(alstream examples/alstream.c)
1300 TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1302 SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1303 ${SDL_SOUND_INCLUDE_DIR})
1305 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1306 TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1308 SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1309 ${SDL_SOUND_INCLUDE_DIR})
1311 ADD_EXECUTABLE(allatency examples/allatency.c)
1312 TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1314 SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1315 ${SDL_SOUND_INCLUDE_DIR})
1317 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1318 TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1320 SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1321 ${SDL_SOUND_INCLUDE_DIR})
1323 ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1324 TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1326 SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1327 ${SDL_SOUND_INCLUDE_DIR})
1330 INSTALL(TARGETS alstream alreverb allatency alloopback alhrtf
1331 RUNTIME DESTINATION bin
1332 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1333 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1340 IF(AVFORMAT_VERSION VERSION_LESS "55.33.100")
1341 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 55.33.100)")
1344 IF(AVCODEC_VERSION VERSION_LESS "55.52.102")
1345 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 55.52.102)")
1348 IF(AVUTIL_VERSION VERSION_LESS "52.66.100")
1349 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 52.66.100)")
1352 IF(SWSCALE_VERSION VERSION_LESS "2.5.102")
1353 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 2.5.102)")
1356 IF(SWRESAMPLE_VERSION VERSION_LESS "0.18.100")
1357 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 0.18.100)")
1361 IF(FFVER_OK AND NOT MSVC)
1362 ADD_EXECUTABLE(alffplay examples/alffplay.c)
1363 TARGET_LINK_LIBRARIES(alffplay common ex-common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
1364 SET_PROPERTY(TARGET alffplay APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1365 ${FFMPEG_INCLUDE_DIRS})
1368 INSTALL(TARGETS alffplay
1369 RUNTIME DESTINATION bin
1370 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1371 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1374 MESSAGE(STATUS "Building SDL and FFmpeg example programs")
1376 MESSAGE(STATUS "Building SDL example programs")