Use the converters to enable mmdevapi capture
[openal-soft.git] / CMakeLists.txt
blobee1c9e57c3c19177d12e5d372adfec765728b8f4
1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)
5 PROJECT(OpenAL)
7 IF(COMMAND CMAKE_POLICY)
8     CMAKE_POLICY(SET CMP0003 NEW)
9     CMAKE_POLICY(SET CMP0005 NEW)
10     IF(POLICY CMP0020)
11         CMAKE_POLICY(SET CMP0020 NEW)
12     ENDIF(POLICY CMP0020)
13     IF(POLICY CMP0042)
14         CMAKE_POLICY(SET CMP0042 NEW)
15     ENDIF(POLICY CMP0042)
16     IF(POLICY CMP0054)
17         CMAKE_POLICY(SET CMP0054 NEW)
18     ENDIF(POLICY CMP0054)
19 ENDIF(COMMAND CMAKE_POLICY)
21 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
23 INCLUDE(CheckFunctionExists)
24 INCLUDE(CheckLibraryExists)
25 INCLUDE(CheckSharedFunctionExists)
26 INCLUDE(CheckIncludeFile)
27 INCLUDE(CheckIncludeFiles)
28 INCLUDE(CheckSymbolExists)
29 INCLUDE(CheckCCompilerFlag)
30 INCLUDE(CheckCXXCompilerFlag)
31 INCLUDE(CheckCSourceCompiles)
32 INCLUDE(CheckTypeSize)
33 include(CheckStructHasMember)
34 include(CheckFileOffsetBits)
35 include(GNUInstallDirs)
37 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
40 OPTION(ALSOFT_DLOPEN  "Check for the dlopen API for loading optional libs"  ON)
42 OPTION(ALSOFT_WERROR  "Treat compile warnings as errors"      OFF)
44 OPTION(ALSOFT_UTILS          "Build and install utility programs"         ON)
45 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
47 OPTION(ALSOFT_EXAMPLES  "Build and install example programs"  ON)
48 OPTION(ALSOFT_TESTS     "Build and install test programs"     ON)
50 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
51 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
52 OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
53 OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
55 if(DEFINED SHARE_INSTALL_DIR)
56     message(WARNING "SHARE_INSTALL_DIR is deprecated.  Use the variables provided by the GNUInstallDirs module instead")
57     set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
58 endif()
60 if(DEFINED LIB_SUFFIX)
61     message(WARNING "LIB_SUFFIX is deprecated.  Use the variables provided by the GNUInstallDirs module instead")
62 endif()
65 IF(WIN32)
66     ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
68     # This option is mainly for static linking OpenAL Soft into another project
69     # that already defines the IDs. It is up to that project to ensure all
70     # required IDs are defined.
71     OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
73     IF(MINGW)
74         OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
75         IF(NOT DLLTOOL)
76             IF(HOST)
77                 SET(DLLTOOL "${HOST}-dlltool")
78             ELSE()
79                 SET(DLLTOOL "dlltool")
80             ENDIF()
81         ENDIF()
82     ENDIF()
83 ENDIF()
86 SET(EXTRA_LIBS "")
87 SET(EXTRA_LDFLAGS "")
89 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
90 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
91     ADD_DEFINITIONS("-I/usr/include")
92     SET(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} -L/usr/lib")
93 ENDIF()
95 IF(NOT LIBTYPE)
96     SET(LIBTYPE SHARED)
97 ENDIF()
99 SET(LIB_MAJOR_VERSION "1")
100 SET(LIB_MINOR_VERSION "17")
101 SET(LIB_REVISION "2")
102 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
104 SET(EXPORT_DECL "")
105 SET(ALIGN_DECL "")
108 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
109 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
112 CHECK_C_COMPILER_FLAG(-std=c11 HAVE_STD_C11)
113 IF(HAVE_STD_C11)
114     SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
115 ELSE()
116     CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
117     IF(HAVE_STD_C99)
118         SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
119     ENDIF()
120 ENDIF()
122 CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD_CXX11)
123 IF(HAVE_STD_CXX11)
124     SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
125 ENDIF()
127 if(NOT WIN32)
128     # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
129     CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
130     IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
131         SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
132         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600")
133         CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
134         IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
135             SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
136         ELSE()
137             ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600)
138         ENDIF()
139     ENDIF()
140     UNSET(OLD_REQUIRED_FLAGS)
141 ENDIF()
143 # Set defines for large file support
144 CHECK_FILE_OFFSET_BITS()
145 IF(_FILE_OFFSET_BITS)
146     ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
147     SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
148 ENDIF()
149 ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES)
150 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
152 # MSVC may need workarounds for C99 restrict and inline
153 IF(MSVC)
154     # TODO: Once we truly require C99, these restrict and inline checks should go
155     # away.
156     CHECK_C_SOURCE_COMPILES("int *restrict foo;
157                              int main() {return 0;}" HAVE_RESTRICT)
158     IF(NOT HAVE_RESTRICT)
159         ADD_DEFINITIONS("-Drestrict=")
160         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
161     ENDIF()
163     CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
164                              int main() {return 0;}" HAVE_INLINE)
165     IF(NOT HAVE_INLINE)
166         CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
167                                  int main() {return 0;}" HAVE___INLINE)
168         IF(NOT HAVE___INLINE)
169             MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
170         ENDIF()
172         ADD_DEFINITIONS(-Dinline=__inline)
173         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
174     ENDIF()
175 ENDIF()
177 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
178 IF(CMAKE_COMPILER_IS_GNUCC)
179     SET(CMAKE_C_FLAGS "-fno-gnu89-inline ${CMAKE_C_FLAGS}")
181     SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
182     # Force no inlining for the next test.
183     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
185     CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
186                              int main() {return foo();}" INLINE_IS_C99)
187     IF(NOT INLINE_IS_C99)
188         MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
189                              Please update your compiler for better C99 compliance.")
190     ENDIF()
192     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
193 ENDIF()
195 # Check if we have a proper timespec declaration
196 CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC)
197 IF(HAVE_STRUCT_TIMESPEC)
198     # Define it here so we don't have to include config.h for it
199     ADD_DEFINITIONS("-DHAVE_STRUCT_TIMESPEC")
200 ENDIF()
202 # Some systems may need libatomic for C11 atomic functions to work
203 SET(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
204 SET(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
205 CHECK_C_SOURCE_COMPILES("#include <stdatomic.h>
206 int _Atomic foo = ATOMIC_VAR_INIT(0);
207 int main()
209     return atomic_fetch_add(&foo, 2);
211 HAVE_LIBATOMIC)
212 IF(NOT HAVE_LIBATOMIC)
213     SET(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
214 ELSE()
215     SET(EXTRA_LIBS atomic ${EXTRA_LIBS})
216 ENDIF()
217 UNSET(OLD_REQUIRED_LIBRARIES)
219 # Include liblog for Android logging
220 CHECK_LIBRARY_EXISTS(log __android_log_print "" HAVE_LIBLOG)
221 IF(HAVE_LIBLOG)
222     SET(EXTRA_LIBS log ${EXTRA_LIBS})
223     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
224 ENDIF()
226 # Check if we have C99 variable length arrays
227 CHECK_C_SOURCE_COMPILES(
228 "int main(int argc, char *argv[])
230      volatile int tmp[argc];
231      tmp[0] = argv[0][0];
232      return tmp[0];
233  }"
234 HAVE_C99_VLA)
236 # Check if we have C99 bool
237 CHECK_C_SOURCE_COMPILES(
238 "int main(int argc, char *argv[])
240      volatile _Bool ret;
241      ret = (argc > 1) ? 1 : 0;
242      return ret ? -1 : 0;
243  }"
244 HAVE_C99_BOOL)
246 # Check if we have C11 static_assert
247 CHECK_C_SOURCE_COMPILES(
248 "int main()
250      _Static_assert(sizeof(int) == sizeof(int), \"What\");
251      return 0;
252  }"
253 HAVE_C11_STATIC_ASSERT)
255 # Check if we have C11 alignas
256 CHECK_C_SOURCE_COMPILES(
257 "_Alignas(16) int foo;
258  int main()
260      return 0;
261  }"
262 HAVE_C11_ALIGNAS)
264 # Check if we have C11 _Atomic
265 CHECK_C_SOURCE_COMPILES(
266 "#include <stdatomic.h>
267  const int _Atomic foo = ATOMIC_VAR_INIT(~0);
268  int _Atomic bar = ATOMIC_VAR_INIT(0);
269  int main()
271      atomic_fetch_add(&bar, 2);
272      return atomic_load(&foo);
273  }"
274 HAVE_C11_ATOMIC)
276 # Add definitions, compiler switches, etc.
277 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
279 IF(NOT CMAKE_BUILD_TYPE)
280     SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
281         "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
282         FORCE)
283 ENDIF()
284 IF(NOT CMAKE_DEBUG_POSTFIX)
285     SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
286         "Library postfix for debug builds. Normally left blank."
287         FORCE)
288 ENDIF()
290 SET(EXTRA_CFLAGS "")
291 IF(MSVC)
292     ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
293     ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
294     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} /wd4098")
296     IF(NOT DXSDK_DIR)
297         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
298     ELSE()
299         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
300     ENDIF()
301     IF(DXSDK_DIR)
302         MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
303     ENDIF()
305     OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
306     IF(FORCE_STATIC_VCRT)
307         FOREACH(flag_var
308                 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
309                 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
310             IF(${flag_var} MATCHES "/MD")
311                 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
312             ENDIF()
313         ENDFOREACH(flag_var)
314     ENDIF()
315 ELSE()
316     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Winline -Wall")
317     CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
318     IF(HAVE_W_EXTRA)
319         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wextra")
320     ENDIF()
322     IF(ALSOFT_WERROR)
323         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
324     ENDIF()
326     # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
327     # instead of NDEBUG)
328     FOREACH(flag_var  CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
329         IF(${flag_var} MATCHES "-DNDEBUG")
330             STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
331         ENDIF()
332     ENDFOREACH()
334     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
335                              int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
337     option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
338     if(ALSOFT_STATIC_LIBGCC)
339         set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
340         set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
341         check_c_source_compiles(
342 "#include <stdlib.h>
343 int main()
345     return 0;
347             HAVE_STATIC_LIBGCC_SWITCH
348         )
349         if(HAVE_STATIC_LIBGCC_SWITCH)
350             set(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} -static-libgcc")
351         endif()
352         set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
353         unset(OLD_REQUIRED_LIBRARIES)
354     endif()
355 ENDIF()
357 # Set visibility/export options if available
358 SET(HIDDEN_DECL "")
359 IF(WIN32)
360     SET(EXPORT_DECL "__declspec(dllexport)")
361     IF(NOT MINGW)
362         SET(ALIGN_DECL "__declspec(align(x))")
363     ELSE()
364         SET(ALIGN_DECL "__declspec(aligned(x))")
365     ENDIF()
366 ELSE()
367     SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
368     # Yes GCC, really don't accept visibility modes you don't support
369     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
371     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
372                              int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
373     IF(HAVE_GCC_PROTECTED_VISIBILITY)
374         SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
375     ELSE()
376         CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
377                                  int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
378         IF(HAVE_GCC_DEFAULT_VISIBILITY)
379             SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
380         ENDIF()
381     ENDIF()
383     IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
384         CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
385         IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
386             SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
387             SET(HIDDEN_DECL "__attribute__((visibility(\"hidden\")))")
388         ENDIF()
389     ENDIF()
391     CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
392                              int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
393     IF(HAVE_ATTRIBUTE_ALIGNED)
394         SET(ALIGN_DECL "__attribute__((aligned(x)))")
395     ENDIF()
397     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
398 ENDIF()
400 CHECK_C_SOURCE_COMPILES("
401 int main()
403     float *ptr;
404     ptr = __builtin_assume_aligned(ptr, 16);
405     return 0;
406 }" HAVE___BUILTIN_ASSUME_ALIGNED)
407 IF(HAVE___BUILTIN_ASSUME_ALIGNED)
408     SET(ASSUME_ALIGNED_DECL "__builtin_assume_aligned(x, y)")
409 ELSE()
410     SET(ASSUME_ALIGNED_DECL "x")
411 ENDIF()
413 SET(SSE_SWITCH "")
414 SET(SSE2_SWITCH "")
415 SET(SSE3_SWITCH "")
416 SET(SSE4_1_SWITCH "")
417 SET(FPU_NEON_SWITCH "")
418 IF(NOT MSVC)
419     CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
420     IF(HAVE_MSSE_SWITCH)
421         SET(SSE_SWITCH "-msse")
422     ENDIF()
423     CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
424     IF(HAVE_MSSE2_SWITCH)
425         SET(SSE2_SWITCH "-msse2")
426     ENDIF()
427     CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
428     IF(HAVE_MSSE3_SWITCH)
429         SET(SSE3_SWITCH "-msse3")
430     ENDIF()
431     CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
432     IF(HAVE_MSSE4_1_SWITCH)
433         SET(SSE4_1_SWITCH "-msse4.1")
434     ENDIF()
435     CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_MFPU_NEON_SWITCH)
436     IF(HAVE_MFPU_NEON_SWITCH)
437         SET(FPU_NEON_SWITCH "-mfpu=neon")
438     ENDIF()
439 ENDIF()
441 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
442                          int main() {return 0;}" HAVE_GCC_FORMAT)
444 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
445 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
446 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
447 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
448 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
449 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
450 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
451 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
452 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
453 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
454 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
455 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
456 IF(NOT HAVE_GUIDDEF_H)
457     CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
458 ENDIF()
460 # Some systems need libm for some of the following math functions to work
461 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
462 IF(HAVE_LIBM)
463     SET(EXTRA_LIBS m ${EXTRA_LIBS})
464     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
465 ENDIF()
467 # Check for the dlopen API (for dynamicly loading backend libs)
468 IF(ALSOFT_DLOPEN)
469     CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
470     IF(HAVE_LIBDL)
471         SET(EXTRA_LIBS dl ${EXTRA_LIBS})
472         SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
473     ENDIF()
475     CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
476 ENDIF()
478 # Check for a cpuid intrinsic
479 IF(HAVE_CPUID_H)
480     CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
481         int main()
482         {
483             unsigned int eax, ebx, ecx, edx;
484             return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
485         }" HAVE_GCC_GET_CPUID)
486 ENDIF()
487 IF(HAVE_INTRIN_H)
488     CHECK_C_SOURCE_COMPILES("#include <intrin.h>
489         int main()
490         {
491             int regs[4];
492             __cpuid(regs, 0);
493             return regs[0];
494         }" HAVE_CPUID_INTRINSIC)
495 ENDIF()
497 CHECK_SYMBOL_EXISTS(aligned_alloc    stdlib.h HAVE_ALIGNED_ALLOC)
498 CHECK_SYMBOL_EXISTS(posix_memalign   stdlib.h HAVE_POSIX_MEMALIGN)
499 CHECK_SYMBOL_EXISTS(_aligned_malloc  malloc.h HAVE__ALIGNED_MALLOC)
500 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
501 CHECK_SYMBOL_EXISTS(modff  math.h HAVE_MODFF)
502 IF(NOT HAVE_C99_VLA)
503     CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
504     IF(NOT HAVE_ALLOCA)
505         MESSAGE(FATAL_ERROR "No alloca function found, please report!")
506     ENDIF()
507 ENDIF()
509 IF(HAVE_FLOAT_H)
510     CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
511     CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
512 ENDIF()
514 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
515 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
516 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
517 IF(NOT HAVE_STRCASECMP)
518     CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
519     IF(NOT HAVE__STRICMP)
520         MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
521     ENDIF()
523     ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
524 ENDIF()
526 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
527 IF(NOT HAVE_STRNCASECMP)
528     CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
529     IF(NOT HAVE__STRNICMP)
530         MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
531     ENDIF()
533     ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
534 ENDIF()
536 CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
537 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
538 IF(NOT HAVE_SNPRINTF)
539     CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
540     IF(NOT HAVE__SNPRINTF)
541         MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
542     ENDIF()
544     ADD_DEFINITIONS(-Dsnprintf=_snprintf)
545 ENDIF()
547 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
548 IF(NOT HAVE_ISFINITE)
549     CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
550     IF(NOT HAVE_FINITE)
551         CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
552         IF(NOT HAVE__FINITE)
553             MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
554         ENDIF()
555         ADD_DEFINITIONS(-Disfinite=_finite)
556     ELSE()
557         ADD_DEFINITIONS(-Disfinite=finite)
558     ENDIF()
559 ENDIF()
561 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
562 IF(NOT HAVE_ISNAN)
563     CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
564     IF(NOT HAVE__ISNAN)
565         MESSAGE(FATAL_ERROR "No isnan function found, please report!")
566     ENDIF()
568     ADD_DEFINITIONS(-Disnan=_isnan)
569 ENDIF()
572 # Check if we have Windows headers
573 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
574 IF(NOT HAVE_WINDOWS_H)
575     CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
576     IF(NOT HAVE_GETTIMEOFDAY)
577         MESSAGE(FATAL_ERROR "No timing function found!")
578     ENDIF()
580     CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
581     IF(NOT HAVE_NANOSLEEP)
582         MESSAGE(FATAL_ERROR "No sleep function found!")
583     ENDIF()
585     # We need pthreads outside of Windows
586     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
587     IF(NOT HAVE_PTHREAD_H)
588         MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
589     ENDIF()
590     # Some systems need pthread_np.h to get recursive mutexes
591     CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
593     CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
594     IF(HAVE_PTHREAD)
595         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread")
596         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
597         SET(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} -pthread")
598     ENDIF()
600     CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
601     IF(HAVE_LIBPTHREAD)
602         SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
603     ENDIF()
605     CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
607     IF(HAVE_PTHREAD_NP_H)
608         CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
609         IF(NOT HAVE_PTHREAD_SETNAME_NP)
610             CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
611         ELSE()
612             CHECK_C_SOURCE_COMPILES("
613 #include <pthread.h>
614 #include <pthread_np.h>
615 int main()
617     pthread_setname_np(\"testname\");
618     return 0;
620                 PTHREAD_SETNAME_NP_ONE_PARAM
621             )
622         ENDIF()
623         CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
624     ELSE()
625         CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
626         IF(NOT HAVE_PTHREAD_SETNAME_NP)
627             CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
628         ELSE()
629             CHECK_C_SOURCE_COMPILES("
630 #include <pthread.h>
631 int main()
633     pthread_setname_np(\"testname\");
634     return 0;
636                 PTHREAD_SETNAME_NP_ONE_PARAM
637             )
638         ENDIF()
639         CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
640     ENDIF()
642     CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
644     CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
645     IF(HAVE_LIBRT)
646         SET(EXTRA_LIBS rt ${EXTRA_LIBS})
647     ENDIF()
648 ENDIF()
650 # Check for a 64-bit type
651 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
652 IF(NOT HAVE_STDINT_H)
653     IF(HAVE_WINDOWS_H)
654         CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
655                                  #include <windows.h>
656                                  __int64 foo;
657                                  int main() {return 0;}" HAVE___INT64)
658     ENDIF()
659     IF(NOT HAVE___INT64)
660         IF(NOT SIZEOF_LONG MATCHES "8")
661             IF(NOT SIZEOF_LONG_LONG MATCHES "8")
662                 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
663             ENDIF()
664         ENDIF()
665     ENDIF()
666 ENDIF()
669 SET(COMMON_OBJS  common/almalloc.c
670                  common/atomic.c
671                  common/rwlock.c
672                  common/threads.c
673                  common/uintmap.c
675 SET(OPENAL_OBJS  OpenAL32/alAuxEffectSlot.c
676                  OpenAL32/alBuffer.c
677                  OpenAL32/alEffect.c
678                  OpenAL32/alError.c
679                  OpenAL32/alExtension.c
680                  OpenAL32/alFilter.c
681                  OpenAL32/alListener.c
682                  OpenAL32/alSource.c
683                  OpenAL32/alState.c
684                  OpenAL32/alThunk.c
685                  OpenAL32/sample_cvt.c
687 SET(ALC_OBJS  Alc/ALc.c
688               Alc/ALu.c
689               Alc/alcConfig.c
690               Alc/alcRing.c
691               Alc/bs2b.c
692               Alc/converter.c
693               Alc/effects/chorus.c
694               Alc/effects/compressor.c
695               Alc/effects/dedicated.c
696               Alc/effects/distortion.c
697               Alc/effects/echo.c
698               Alc/effects/equalizer.c
699               Alc/effects/flanger.c
700               Alc/effects/modulator.c
701               Alc/effects/null.c
702               Alc/effects/reverb.c
703               Alc/helpers.c
704               Alc/bsinc.c
705               Alc/hrtf.c
706               Alc/uhjfilter.c
707               Alc/ambdec.c
708               Alc/bformatdec.c
709               Alc/nfcfilter.c
710               Alc/panning.c
711               Alc/mixer.c
712               Alc/mixer_c.c
716 SET(CPU_EXTS "Default")
717 SET(HAVE_SSE        0)
718 SET(HAVE_SSE2       0)
719 SET(HAVE_SSE3       0)
720 SET(HAVE_SSE4_1     0)
721 SET(HAVE_NEON       0)
723 SET(HAVE_ALSA       0)
724 SET(HAVE_OSS        0)
725 SET(HAVE_SOLARIS    0)
726 SET(HAVE_SNDIO      0)
727 SET(HAVE_QSA        0)
728 SET(HAVE_DSOUND     0)
729 SET(HAVE_MMDEVAPI   0)
730 SET(HAVE_WINMM      0)
731 SET(HAVE_PORTAUDIO  0)
732 SET(HAVE_PULSEAUDIO 0)
733 SET(HAVE_COREAUDIO  0)
734 SET(HAVE_OPENSL     0)
735 SET(HAVE_WAVE       0)
737 # Check for SSE support
738 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
739 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
740 IF(HAVE_XMMINTRIN_H)
741     OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
742     IF(ALSOFT_CPUEXT_SSE)
743         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
744             SET(HAVE_SSE 1)
745             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse.c)
746             IF(SSE_SWITCH)
747                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
748                                             COMPILE_FLAGS "${SSE_SWITCH}")
749             ENDIF()
750             SET(CPU_EXTS "${CPU_EXTS}, SSE")
751         ENDIF()
752     ENDIF()
753 ENDIF()
754 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
755     MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
756 ENDIF()
758 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
759 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
760 IF(HAVE_EMMINTRIN_H)
761     OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
762     IF(HAVE_SSE AND ALSOFT_CPUEXT_SSE2)
763         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
764             SET(HAVE_SSE2 1)
765             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse2.c)
766             IF(SSE2_SWITCH)
767                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse2.c PROPERTIES
768                                             COMPILE_FLAGS "${SSE2_SWITCH}")
769             ENDIF()
770             SET(CPU_EXTS "${CPU_EXTS}, SSE2")
771         ENDIF()
772     ENDIF()
773 ENDIF()
774 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
775     MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
776 ENDIF()
778 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE3 support" OFF)
779 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
780 IF(HAVE_EMMINTRIN_H)
781     OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
782     IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
783         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
784             SET(HAVE_SSE3 1)
785             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse3.c)
786             IF(SSE2_SWITCH)
787                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse3.c PROPERTIES
788                                             COMPILE_FLAGS "${SSE3_SWITCH}")
789             ENDIF()
790             SET(CPU_EXTS "${CPU_EXTS}, SSE3")
791         ENDIF()
792     ENDIF()
793 ENDIF()
794 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
795     MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
796 ENDIF()
798 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
799 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
800 IF(HAVE_SMMINTRIN_H)
801     OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
802     IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE4_1)
803         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
804             SET(HAVE_SSE4_1 1)
805             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse41.c)
806             IF(SSE4_1_SWITCH)
807                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse41.c PROPERTIES
808                                             COMPILE_FLAGS "${SSE4_1_SWITCH}")
809             ENDIF()
810             SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
811         ENDIF()
812     ENDIF()
813 ENDIF()
814 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
815     MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
816 ENDIF()
818 # Check for ARM Neon support
819 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
820 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
821 IF(HAVE_ARM_NEON_H)
822     OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
823     IF(ALSOFT_CPUEXT_NEON)
824         SET(HAVE_NEON 1)
825         SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_neon.c)
826         IF(FPU_NEON_SWITCH)
827             SET_SOURCE_FILES_PROPERTIES(Alc/mixer_neon.c PROPERTIES
828                                         COMPILE_FLAGS "${FPU_NEON_SWITCH}")
829         ENDIF()
830         SET(CPU_EXTS "${CPU_EXTS}, Neon")
831     ENDIF()
832 ENDIF()
833 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
834     MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
835 ENDIF()
838 IF(WIN32 OR HAVE_DLFCN_H)
839     SET(IS_LINKED "")
840     MACRO(ADD_BACKEND_LIBS _LIBS)
841     ENDMACRO()
842 ELSE()
843     SET(IS_LINKED " (linked)")
844     MACRO(ADD_BACKEND_LIBS _LIBS)
845         SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
846     ENDMACRO()
847 ENDIF()
849 SET(BACKENDS "")
850 SET(ALC_OBJS  ${ALC_OBJS}
851               Alc/backends/base.c
852               # Default backends, always available
853               Alc/backends/loopback.c
854               Alc/backends/null.c
857 # Check ALSA backend
858 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
859 FIND_PACKAGE(ALSA)
860 IF(ALSA_FOUND)
861     OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
862     IF(ALSOFT_BACKEND_ALSA)
863         SET(HAVE_ALSA 1)
864         SET(BACKENDS  "${BACKENDS} ALSA${IS_LINKED},")
865         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/alsa.c)
866         ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
867     ENDIF()
868 ENDIF()
869 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
870     MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
871 ENDIF()
873 # Check OSS backend
874 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
875 FIND_PACKAGE(OSS)
876 IF(OSS_FOUND)
877     OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
878     IF(ALSOFT_BACKEND_OSS)
879         SET(HAVE_OSS 1)
880         SET(BACKENDS  "${BACKENDS} OSS,")
881         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/oss.c)
882     ENDIF()
883 ENDIF()
884 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
885     MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
886 ENDIF()
888 # Check Solaris backend
889 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
890 FIND_PACKAGE(AudioIO)
891 IF(AUDIOIO_FOUND)
892     OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
893     IF(ALSOFT_BACKEND_SOLARIS)
894         SET(HAVE_SOLARIS 1)
895         SET(BACKENDS  "${BACKENDS} Solaris,")
896         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/solaris.c)
897     ENDIF()
898 ENDIF()
899 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
900     MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
901 ENDIF()
903 # Check SndIO backend
904 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
905 FIND_PACKAGE(SoundIO)
906 IF(SOUNDIO_FOUND)
907     OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
908     IF(ALSOFT_BACKEND_SNDIO)
909         SET(HAVE_SNDIO 1)
910         SET(BACKENDS  "${BACKENDS} SndIO (linked),")
911         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/sndio.c)
912         SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
913     ENDIF()
914 ENDIF()
915 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
916     MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
917 ENDIF()
919 # Check QSA backend
920 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
921 FIND_PACKAGE(QSA)
922 IF(QSA_FOUND)
923     OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
924     IF(ALSOFT_BACKEND_QSA)
925         SET(HAVE_QSA 1)
926         SET(BACKENDS  "${BACKENDS} QSA (linked),")
927         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/qsa.c)
928         SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
929     ENDIF()
930 ENDIF()
931 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
932     MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
933 ENDIF()
935 # Check Windows-only backends
936 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
937 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
938 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
939 IF(HAVE_WINDOWS_H)
940     # Check MMSystem backend
941     CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
942     IF(HAVE_MMSYSTEM_H)
943         CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
944         IF(HAVE_LIBWINMM)
945             OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
946             IF(ALSOFT_BACKEND_WINMM)
947                 SET(HAVE_WINMM 1)
948                 SET(BACKENDS  "${BACKENDS} WinMM,")
949                 SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/winmm.c)
950                 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
951             ENDIF()
952         ENDIF()
953     ENDIF()
955     # Check DSound backend
956     FIND_PACKAGE(DSound)
957     IF(DSOUND_FOUND)
958         OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
959         IF(ALSOFT_BACKEND_DSOUND)
960             SET(HAVE_DSOUND 1)
961             SET(BACKENDS  "${BACKENDS} DirectSound${IS_LINKED},")
962             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/dsound.c)
963             ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
964         ENDIF()
965     ENDIF()
967     # Check for MMDevApi backend
968     CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
969     IF(HAVE_MMDEVICEAPI_H)
970         OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
971         IF(ALSOFT_BACKEND_MMDEVAPI)
972             SET(HAVE_MMDEVAPI 1)
973             SET(BACKENDS  "${BACKENDS} MMDevApi,")
974             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/mmdevapi.c)
975         ENDIF()
976     ENDIF()
977 ENDIF()
978 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
979     MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
980 ENDIF()
981 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
982     MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
983 ENDIF()
984 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
985     MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
986 ENDIF()
988 # Check PortAudio backend
989 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
990 FIND_PACKAGE(PortAudio)
991 IF(PORTAUDIO_FOUND)
992     OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
993     IF(ALSOFT_BACKEND_PORTAUDIO)
994         SET(HAVE_PORTAUDIO 1)
995         SET(BACKENDS  "${BACKENDS} PortAudio${IS_LINKED},")
996         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/portaudio.c)
997         ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
998     ENDIF()
999 ENDIF()
1000 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
1001     MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
1002 ENDIF()
1004 # Check PulseAudio backend
1005 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
1006 FIND_PACKAGE(PulseAudio)
1007 IF(PULSEAUDIO_FOUND)
1008     OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
1009     IF(ALSOFT_BACKEND_PULSEAUDIO)
1010         SET(HAVE_PULSEAUDIO 1)
1011         SET(BACKENDS  "${BACKENDS} PulseAudio${IS_LINKED},")
1012         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/pulseaudio.c)
1013         ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
1014     ENDIF()
1015 ENDIF()
1016 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
1017     MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
1018 ENDIF()
1020 # Check JACK backend
1021 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
1022 FIND_PACKAGE(JACK)
1023 IF(JACK_FOUND)
1024     OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
1025     IF(ALSOFT_BACKEND_JACK)
1026         SET(HAVE_JACK 1)
1027         SET(BACKENDS  "${BACKENDS} JACK${IS_LINKED},")
1028         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/jack.c)
1029         ADD_BACKEND_LIBS(${JACK_LIBRARIES})
1030     ENDIF()
1031 ENDIF()
1032 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1033     MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
1034 ENDIF()
1036 # Check CoreAudio backend
1037 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1038 FIND_LIBRARY(COREAUDIO_FRAMEWORK
1039              NAMES CoreAudio
1040              PATHS /System/Library/Frameworks
1042 IF(COREAUDIO_FRAMEWORK)
1043     OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1044     IF(ALSOFT_BACKEND_COREAUDIO)
1045         SET(HAVE_COREAUDIO 1)
1046         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/coreaudio.c)
1047         SET(BACKENDS  "${BACKENDS} CoreAudio,")
1048         SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1049         SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1050         SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1052         # Some versions of OSX may need the AudioToolbox framework. Add it if
1053         # it's found.
1054         FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1055                      NAMES AudioToolbox
1056                      PATHS ~/Library/Frameworks
1057                            /Library/Frameworks
1058                            /System/Library/Frameworks
1059                     )
1060         IF(AUDIOTOOLBOX_LIBRARY)
1061             SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1062         ENDIF()
1063     ENDIF()
1064 ENDIF()
1065 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1066     MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1067 ENDIF()
1069 # Check for OpenSL (Android) backend
1070 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1071 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
1072 IF(HAVE_SLES_OPENSLES_ANDROID_H)
1073     CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
1074     IF(HAVE_LIBOPENSLES)
1075         OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1076         IF(ALSOFT_BACKEND_OPENSL)
1077             SET(HAVE_OPENSL 1)
1078             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/opensl.c)
1079             SET(BACKENDS  "${BACKENDS} OpenSL,")
1080             SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
1081         ENDIF()
1082     ENDIF()
1083 ENDIF()
1084 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1085     MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1086 ENDIF()
1088 # Optionally enable the Wave Writer backend
1089 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1090 IF(ALSOFT_BACKEND_WAVE)
1091     SET(HAVE_WAVE 1)
1092     SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/wave.c)
1093     SET(BACKENDS  "${BACKENDS} WaveFile,")
1094 ENDIF()
1096 # This is always available
1097 SET(BACKENDS  "${BACKENDS} Null")
1099 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" OFF)
1100 if(ALSOFT_EMBED_HRTF_DATA)
1101     if(WIN32)
1102         set(ALC_OBJS  ${ALC_OBJS} Alc/hrtf_res.rc)
1103     elseif(APPLE)
1104         macro(add_custom_binary FILENAME BIN_NAME)
1105             set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
1106             set(stubsrcfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}.stub.c)
1107             set(stubfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}.stub${CMAKE_C_OUTPUT_EXTENSION})
1108             add_custom_command(OUTPUT ${outfile}
1109                 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
1110                 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
1111                 COMMAND touch "${stubsrcfile}"
1112                 COMMAND "${CMAKE_C_COMPILER}" -o "${stubfile}" -c "${stubsrcfile}"
1113                 COMMAND "${CMAKE_LINKER}" -r -o "${outfile}" -sectcreate binary ${BIN_NAME} ${FILENAME} "${stubfile}"
1114                 COMMAND rm "${stubsrcfile}" "${stubfile}"
1115                 COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
1116                 VERBATIM
1117             )
1118             set(ALC_OBJS  ${ALC_OBJS} ${outfile})
1119         endmacro()
1120         add_custom_binary(default-44100.mhr "default_44100")
1121         add_custom_binary(default-48000.mhr "default_48000")
1122     else()
1123         set(FILENAMES default-44100.mhr default-48000.mhr)
1124         foreach(FILENAME ${FILENAMES})
1125             set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
1126             add_custom_command(OUTPUT ${outfile}
1127                 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
1128                 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
1129                 COMMAND "${CMAKE_LINKER}" -r -b binary -o "${outfile}" ${FILENAME}
1130                 COMMAND "${CMAKE_OBJCOPY}" --rename-section .data=.rodata,alloc,load,readonly,data,contents "${outfile}" "${outfile}"
1131                 COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
1132                 VERBATIM
1133             )
1134             set(ALC_OBJS  ${ALC_OBJS} ${outfile})
1135         endforeach()
1136         unset(outfile)
1137         unset(FILENAMES)
1138     endif()
1139 endif()
1142 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1143     add_subdirectory(utils/alsoft-config)
1144 ENDIF()
1145 IF(ALSOFT_EXAMPLES)
1146     FIND_PACKAGE(SDL2)
1147     IF(SDL2_FOUND)
1148         FIND_PACKAGE(SDL_sound)
1149         FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1150     ENDIF()
1151 ENDIF()
1153 IF(LIBTYPE STREQUAL "STATIC")
1154     ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
1155     SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
1156 ENDIF()
1158 IF(NOT WIN32)
1159     SET(LIBNAME "openal")
1160 ELSE()
1161     SET(LIBNAME "OpenAL32")
1162 ENDIF()
1164 FIND_PACKAGE(Git)
1165 IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
1166     # Get the current working branch and its latest abbreviated commit hash
1167     ADD_CUSTOM_TARGET(build_version
1168         ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
1169                          -D LIB_VERSION=${LIB_VERSION}
1170                          -D SRC=${OpenAL_SOURCE_DIR}/version.h.in
1171                          -D DST=${OpenAL_BINARY_DIR}/version.h
1172                          -P ${OpenAL_SOURCE_DIR}/version.cmake
1173         WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
1174         VERBATIM
1175     )
1176 ELSE()
1177     SET(GIT_BRANCH "UNKNOWN")
1178     SET(GIT_COMMIT_HASH "unknown")
1179     CONFIGURE_FILE(
1180         "${OpenAL_SOURCE_DIR}/version.h.in"
1181         "${OpenAL_BINARY_DIR}/version.h")
1182 ENDIF()
1184 # Needed for openal.pc.in
1185 SET(prefix ${CMAKE_INSTALL_PREFIX})
1186 SET(exec_prefix "\${prefix}")
1187 SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
1188 SET(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}")
1189 SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
1190 SET(PACKAGE_VERSION "${LIB_VERSION}")
1192 # End configuration
1193 CONFIGURE_FILE(
1194     "${OpenAL_SOURCE_DIR}/config.h.in"
1195     "${OpenAL_BINARY_DIR}/config.h")
1196 CONFIGURE_FILE(
1197     "${OpenAL_SOURCE_DIR}/openal.pc.in"
1198     "${OpenAL_BINARY_DIR}/openal.pc"
1199     @ONLY)
1201 # Build main library
1202 IF(LIBTYPE STREQUAL "STATIC")
1203     ADD_LIBRARY(OpenAL STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1204 ELSE()
1205     ADD_LIBRARY(OpenAL SHARED ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1206 ENDIF()
1207 SET_PROPERTY(TARGET OpenAL APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1208 SET_PROPERTY(TARGET OpenAL APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
1209 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1210     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
1211 ENDIF()
1212 SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
1213 IF(HAVE_ALSA)
1214     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
1215 ENDIF()
1216 IF(HAVE_OSS)
1217     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
1218 ENDIF()
1219 IF(HAVE_SOLARIS)
1220     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
1221 ENDIF()
1222 IF(HAVE_SNDIO)
1223     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
1224 ENDIF()
1225 IF(HAVE_QSA)
1226     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
1227 ENDIF()
1228 IF(HAVE_DSOUND)
1229     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
1230 ENDIF()
1231 IF(HAVE_PORTAUDIO)
1232     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
1233 ENDIF()
1234 IF(HAVE_PULSEAUDIO)
1235     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
1236 ENDIF()
1237 IF(HAVE_JACK)
1238     SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
1239 ENDIF()
1240 IF(WIN32)
1241     IF(MSVC)
1242         SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:WINDOWS")
1243     ELSEIF(CMAKE_COMPILER_IS_GNUCC)
1244         SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " -mwindows")
1245     ENDIF()
1246 ENDIF()
1248 SET_TARGET_PROPERTIES(OpenAL PROPERTIES VERSION ${LIB_VERSION}
1249                                         SOVERSION ${LIB_MAJOR_VERSION})
1250 SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME ${LIBNAME})
1252 if(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
1253     SET_TARGET_PROPERTIES(OpenAL PROPERTIES PREFIX "")
1255     IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
1256         FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1257         FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1258         IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1259             MESSAGE(STATUS "")
1260             IF(NOT SED_EXECUTABLE)
1261                 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1262             ENDIF()
1263             IF(NOT DLLTOOL_EXECUTABLE)
1264                 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1265             ENDIF()
1266         ELSE()
1267             SET(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} -Wl,--output-def,OpenAL32.def")
1268             ADD_CUSTOM_COMMAND(TARGET OpenAL POST_BUILD
1269                 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
1270                 COMMAND "${DLLTOOL_EXECUTABLE}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
1271                 COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
1272                 VERBATIM
1273             )
1274         ENDIF()
1275     ENDIF()
1276 ENDIF()
1278 SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS ${EXTRA_LDFLAGS})
1279 TARGET_LINK_LIBRARIES(OpenAL ${EXTRA_LIBS})
1280 IF(TARGET build_version)
1281     ADD_DEPENDENCIES(OpenAL build_version)
1282 ENDIF()
1284 IF(ALSOFT_INSTALL)
1285     # Add an install target here
1286     INSTALL(TARGETS OpenAL EXPORT OpenAL
1287             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1288             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1289             ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1290             INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL
1291     )
1292     EXPORT(TARGETS OpenAL
1293            NAMESPACE OpenAL::
1294            FILE OpenALConfig.cmake)
1295     INSTALL(EXPORT OpenAL
1296             DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
1297             NAMESPACE OpenAL::
1298             FILE OpenALConfig.cmake)
1299     INSTALL(FILES include/AL/al.h
1300                   include/AL/alc.h
1301                   include/AL/alext.h
1302                   include/AL/efx.h
1303                   include/AL/efx-creative.h
1304                   include/AL/efx-presets.h
1305             DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/AL
1306     )
1307     INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1308             DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1309 ENDIF()
1312 MESSAGE(STATUS "")
1313 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1314 MESSAGE(STATUS "    ${BACKENDS}")
1315 MESSAGE(STATUS "")
1316 MESSAGE(STATUS "Building with support for CPU extensions:")
1317 MESSAGE(STATUS "    ${CPU_EXTS}")
1318 MESSAGE(STATUS "")
1320 IF(WIN32)
1321     IF(NOT HAVE_DSOUND)
1322         MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1323         MESSAGE(STATUS "         This is probably NOT what you want!")
1324         MESSAGE(STATUS "")
1325     ENDIF()
1326 ENDIF()
1328 if(ALSOFT_EMBED_HRTF_DATA)
1329     message(STATUS "Embedding HRTF datasets")
1330     message(STATUS "")
1331 endif()
1333 # Install alsoft.conf configuration file
1334 IF(ALSOFT_CONFIG)
1335     INSTALL(FILES alsoftrc.sample
1336             DESTINATION ${CMAKE_INSTALL_DATADIR}/openal
1337     )
1338     MESSAGE(STATUS "Installing sample configuration")
1339     MESSAGE(STATUS "")
1340 ENDIF()
1342 # Install HRTF definitions
1343 IF(ALSOFT_HRTF_DEFS)
1344     INSTALL(FILES hrtf/default-44100.mhr
1345                   hrtf/default-48000.mhr
1346             DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/hrtf
1347     )
1348     MESSAGE(STATUS "Installing HRTF definitions")
1349     MESSAGE(STATUS "")
1350 ENDIF()
1352 # Install AmbDec presets
1353 IF(ALSOFT_AMBDEC_PRESETS)
1354     INSTALL(FILES presets/3D7.1.ambdec
1355                   presets/hexagon.ambdec
1356                   presets/itu5.1.ambdec
1357                   presets/rectangle.ambdec
1358                   presets/square.ambdec
1359                   presets/presets.txt
1360             DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/presets
1361     )
1362     MESSAGE(STATUS "Installing AmbDec presets")
1363     MESSAGE(STATUS "")
1364 ENDIF()
1366 IF(ALSOFT_UTILS)
1367     ADD_EXECUTABLE(openal-info utils/openal-info.c)
1368     SET_PROPERTY(TARGET openal-info APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1369     TARGET_LINK_LIBRARIES(openal-info OpenAL)
1371     ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1372     SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1373     IF(HAVE_LIBM)
1374         TARGET_LINK_LIBRARIES(makehrtf m)
1375     ENDIF()
1377     ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
1378     SET_PROPERTY(TARGET bsincgen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1379     IF(HAVE_LIBM)
1380         TARGET_LINK_LIBRARIES(bsincgen m)
1381     ENDIF()
1383     IF(ALSOFT_INSTALL)
1384         INSTALL(TARGETS openal-info makehrtf bsincgen
1385                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1386                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1387                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1388         )
1389     ENDIF()
1391     MESSAGE(STATUS "Building utility programs")
1392     IF(TARGET alsoft-config)
1393         MESSAGE(STATUS "Building configuration program")
1394     ENDIF()
1395     MESSAGE(STATUS "")
1396 ENDIF()
1398 IF(ALSOFT_TESTS)
1399     SET(TEST_COMMON_OBJS  examples/common/alhelpers.c)
1401     ADD_EXECUTABLE(altonegen examples/altonegen.c ${COMMON_OBJS} ${TEST_COMMON_OBJS})
1402     TARGET_LINK_LIBRARIES(altonegen OpenAL)
1403     SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1405     IF(ALSOFT_INSTALL)
1406         INSTALL(TARGETS altonegen
1407                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1408                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1409                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1410         )
1411     ENDIF()
1413     MESSAGE(STATUS "Building test programs")
1414     MESSAGE(STATUS "")
1415 ENDIF()
1417 IF(ALSOFT_EXAMPLES)
1418     IF(SDL2_FOUND)
1419         IF(SDL_SOUND_FOUND)
1420             SET(EX_COMMON_OBJS  examples/common/alhelpers.c)
1422             ADD_EXECUTABLE(alstream examples/alstream.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
1423             TARGET_LINK_LIBRARIES(alstream ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
1424             SET_PROPERTY(TARGET alstream APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1425             SET_PROPERTY(TARGET alstream APPEND PROPERTY
1426                 INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
1427             )
1429             ADD_EXECUTABLE(alreverb examples/alreverb.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
1430             TARGET_LINK_LIBRARIES(alreverb ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
1431             SET_PROPERTY(TARGET alreverb APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1432             SET_PROPERTY(TARGET alreverb APPEND PROPERTY
1433                 INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
1434             )
1436             ADD_EXECUTABLE(allatency examples/allatency.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
1437             TARGET_LINK_LIBRARIES(allatency ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
1438             SET_PROPERTY(TARGET allatency APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1439             SET_PROPERTY(TARGET allatency APPEND PROPERTY
1440                 INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
1441             )
1443             ADD_EXECUTABLE(alloopback examples/alloopback.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
1444             TARGET_LINK_LIBRARIES(alloopback ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
1445             SET_PROPERTY(TARGET alloopback APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1446             SET_PROPERTY(TARGET alloopback APPEND PROPERTY
1447                 INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
1448             )
1450             ADD_EXECUTABLE(alhrtf examples/alhrtf.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
1451             TARGET_LINK_LIBRARIES(alhrtf ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
1452             SET_PROPERTY(TARGET alhrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1453             SET_PROPERTY(TARGET alhrtf APPEND PROPERTY
1454                 INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
1455             )
1457             IF(ALSOFT_INSTALL)
1458                 INSTALL(TARGETS alstream alreverb allatency alloopback alhrtf
1459                         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1460                         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1461                         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1462                 )
1463             ENDIF()
1465             MESSAGE(STATUS "Building SDL_sound example programs")
1466         ENDIF()
1468         SET(FFVER_OK FALSE)
1469         IF(FFMPEG_FOUND)
1470             SET(FFVER_OK TRUE)
1471             IF(AVFORMAT_VERSION VERSION_LESS "57.56.101")
1472                 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 57.56.101)")
1473                 SET(FFVER_OK FALSE)
1474             ENDIF()
1475             IF(AVCODEC_VERSION VERSION_LESS "57.64.101")
1476                 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 57.64.101)")
1477                 SET(FFVER_OK FALSE)
1478             ENDIF()
1479             IF(AVUTIL_VERSION VERSION_LESS "55.34.101")
1480                 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 55.34.101)")
1481                 SET(FFVER_OK FALSE)
1482             ENDIF()
1483             IF(SWSCALE_VERSION VERSION_LESS "4.2.100")
1484                 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 4.2.100)")
1485                 SET(FFVER_OK FALSE)
1486             ENDIF()
1487             IF(SWRESAMPLE_VERSION VERSION_LESS "2.3.100")
1488                 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 2.3.100)")
1489                 SET(FFVER_OK FALSE)
1490             ENDIF()
1491         ENDIF()
1492         IF(FFVER_OK)
1493             ADD_EXECUTABLE(alffplay examples/alffplay.cpp ${COMMON_OBJS})
1494             TARGET_LINK_LIBRARIES(alffplay ${SDL2_LIBRARY} OpenAL ${FFMPEG_LIBRARIES})
1495             SET_PROPERTY(TARGET alffplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1496             SET_PROPERTY(TARGET alffplay APPEND PROPERTY
1497                 INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS}
1498             )
1500             IF(ALSOFT_INSTALL)
1501                 INSTALL(TARGETS alffplay
1502                         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1503                         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1504                         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1505                 )
1506             ENDIF()
1507             MESSAGE(STATUS "Building SDL+FFmpeg example programs")
1508         ENDIF()
1509         MESSAGE(STATUS "")
1510     ENDIF()
1511 ENDIF()