Make a MAX_AMBI2D_COEFFS macro instead of a magic number
[openal-soft.git] / CMakeLists.txt
blob85bc0dda778556c9dd4da3730a11f724328b5110
1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
5 PROJECT(OpenAL)
7 IF(COMMAND CMAKE_POLICY)
8     CMAKE_POLICY(SET CMP0003 NEW)
9     CMAKE_POLICY(SET CMP0005 NEW)
10     IF(POLICY CMP0042)
11         CMAKE_POLICY(SET CMP0042 NEW)
12     ENDIF(POLICY CMP0042)
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")
51 IF(NOT WIN32)
52     SET(LIBNAME openal)
53 ELSE()
54     SET(LIBNAME OpenAL32)
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)
62     IF(MINGW)
63         OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
64         IF(NOT DLLTOOL)
65             IF(HOST)
66                 SET(DLLTOOL "${HOST}-dlltool")
67             ELSE()
68                 SET(DLLTOOL "dlltool")
69             ENDIF()
70         ENDIF()
71     ENDIF()
72 ENDIF()
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)
79 ENDIF()
81 IF(NOT LIBTYPE)
82     SET(LIBTYPE SHARED)
83 ENDIF()
85 SET(LIB_MAJOR_VERSION "1")
86 SET(LIB_MINOR_VERSION "17")
87 SET(LIB_REVISION "2")
88 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
90 SET(EXPORT_DECL "")
91 SET(ALIGN_DECL "")
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)
99 IF(HAVE_STD_C11)
100     SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
101 ELSE()
102     CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
103     IF(HAVE_STD_C99)
104         SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
105     ENDIF()
106 ENDIF()
108 if(NOT WIN32)
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})
117         ELSE()
118             ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500)
119         ENDIF()
120     ENDIF()
121     UNSET(OLD_REQUIRED_FLAGS)
122 ENDIF()
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}")
129 ENDIF()
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
134 IF(MSVC)
135     # TODO: Once we truly require C99, these restrict and inline checks should go
136     # away.
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=")
142     ENDIF()
144     CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
145                              int main() {return 0;}" HAVE_INLINE)
146     IF(NOT 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!")
151         ENDIF()
153         ADD_DEFINITIONS(-Dinline=__inline)
154         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
155     ENDIF()
156 ENDIF()
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.")
169     ENDIF()
171     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
172 ENDIF()
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];
179      tmp[0] = argv[0][0];
180      return tmp[0];
181  }"
182 HAVE_C99_VLA)
184 # Check if we have C99 bool
185 CHECK_C_SOURCE_COMPILES(
186 "int main(int argc, char *argv[])
188      volatile _Bool ret;
189      ret = (argc > 1) ? 1 : 0;
190      return ret ? -1 : 0;
191  }"
192 HAVE_C99_BOOL)
194 # Check if we have C11 static_assert
195 CHECK_C_SOURCE_COMPILES(
196 "int main()
198      _Static_assert(sizeof(int) == sizeof(int), \"What\");
199      return 0;
200  }"
201 HAVE_C11_STATIC_ASSERT)
203 # Check if we have C11 alignas
204 CHECK_C_SOURCE_COMPILES(
205 "_Alignas(16) int foo;
206  int main()
208      return 0;
209  }"
210 HAVE_C11_ALIGNAS)
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);
216  int main()
218      return atomic_load(&foo);
219  }"
220 HAVE_C11_ATOMIC)
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")
228     ENDIF()
229 ENDIF()
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."
234         FORCE)
235 ENDIF()
236 IF(NOT CMAKE_DEBUG_POSTFIX)
237     SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
238         "Library postfix for debug builds. Normally left blank."
239         FORCE)
240 ENDIF()
242 SET(EXTRA_CFLAGS "")
243 IF(MSVC)
244     ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
245     ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
246     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} /wd4098")
248     IF(NOT DXSDK_DIR)
249         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
250     ELSE()
251         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
252     ENDIF()
253     IF(DXSDK_DIR)
254         MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
255     ENDIF()
257     OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
258     IF(FORCE_STATIC_VCRT)
259         FOREACH(flag_var
260                 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
261                 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
262             IF(${flag_var} MATCHES "/MD")
263                 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
264             ENDIF()
265         ENDFOREACH(flag_var)
266     ENDIF()
267 ELSE()
268     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Winline -Wall")
269     CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
270     IF(HAVE_W_EXTRA)
271         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wextra")
272     ENDIF()
274     IF(ALSOFT_WERROR)
275         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
276     ENDIF()
278     # Force enable -fPIC for CMake versions before 2.8.9 (later versions have
279     # the POSITION_INDEPENDENT_CODE target property). The static common library
280     # will be linked into the dynamic openal library, which requires all its
281     # code to be position-independent.
282     IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
283         CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
284         IF(HAVE_FPIC_SWITCH)
285             SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC")
286         ENDIF()
287     ENDIF()
289     # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
290     # instead of NDEBUG)
291     FOREACH(flag_var  CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
292         IF(${flag_var} MATCHES "-DNDEBUG")
293             STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
294         ENDIF()
295     ENDFOREACH()
297     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
298                              int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
300     option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
301     if(ALSOFT_STATIC_LIBGCC)
302         set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
303         set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
304         check_c_source_compiles(
305 "#include <stdlib.h>
306 int main()
308     return 0;
310             HAVE_STATIC_LIBGCC_SWITCH
311         )
312         if(HAVE_STATIC_LIBGCC_SWITCH)
313             set(EXTRA_LIBS ${EXTRA_LIBS} -static-libgcc)
314         endif()
315         set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
316         unset(OLD_REQUIRED_LIBRARIES)
317     endif()
318 ENDIF()
320 # Set visibility/export options if available
321 SET(HIDDEN_DECL "")
322 IF(WIN32)
323     SET(EXPORT_DECL "__declspec(dllexport)")
324     IF(NOT MINGW)
325         SET(ALIGN_DECL "__declspec(align(x))")
326     ELSE()
327         SET(ALIGN_DECL "__declspec(aligned(x))")
328     ENDIF()
329 ELSE()
330     SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
331     # Yes GCC, really don't accept visibility modes you don't support
332     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
334     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
335                              int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
336     IF(HAVE_GCC_PROTECTED_VISIBILITY)
337         SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
338     ELSE()
339         CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
340                                  int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
341         IF(HAVE_GCC_DEFAULT_VISIBILITY)
342             SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
343         ENDIF()
344     ENDIF()
346     IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
347         CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
348         IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
349             SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
350             SET(HIDDEN_DECL "__attribute__((visibility(\"hidden\")))")
351         ENDIF()
352     ENDIF()
354     CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
355                              int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
356     IF(HAVE_ATTRIBUTE_ALIGNED)
357         SET(ALIGN_DECL "__attribute__((aligned(x)))")
358     ENDIF()
360     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
361 ENDIF()
363 SET(SSE_SWITCH "")
364 SET(SSE2_SWITCH "")
365 SET(SSE3_SWITCH "")
366 SET(SSE4_1_SWITCH "")
367 IF(NOT MSVC)
368     CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
369     IF(HAVE_MSSE_SWITCH)
370         SET(SSE_SWITCH "-msse")
371     ENDIF()
372     CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
373     IF(HAVE_MSSE2_SWITCH)
374         SET(SSE2_SWITCH "-msse2")
375     ENDIF()
376     CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
377     IF(HAVE_MSSE3_SWITCH)
378         SET(SSE3_SWITCH "-msse3")
379     ENDIF()
380     CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
381     IF(HAVE_MSSE4_1_SWITCH)
382         SET(SSE4_1_SWITCH "-msse4.1")
383     ENDIF()
384 ENDIF()
386 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
387                          int main() {return 0;}" HAVE_GCC_FORMAT)
389 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
390 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
391 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
392 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
393 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
394 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
395 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
396 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
397 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
398 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
399 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
400 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
401 IF(NOT HAVE_GUIDDEF_H)
402     CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
403 ENDIF()
405 # Some systems need libm for some of the following math functions to work
406 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
407 IF(HAVE_LIBM)
408     SET(EXTRA_LIBS m ${EXTRA_LIBS})
409     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
410 ENDIF()
412 # Check for the dlopen API (for dynamicly loading backend libs)
413 IF(ALSOFT_DLOPEN)
414     CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
415     IF(HAVE_LIBDL)
416         SET(EXTRA_LIBS dl ${EXTRA_LIBS})
417         SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
418     ENDIF()
420     CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
421 ENDIF()
423 # Check for a cpuid intrinsic
424 IF(HAVE_CPUID_H)
425     CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
426         int main()
427         {
428             unsigned int eax, ebx, ecx, edx;
429             return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
430         }" HAVE_GCC_GET_CPUID)
431 ENDIF()
432 IF(HAVE_INTRIN_H)
433     CHECK_C_SOURCE_COMPILES("#include <intrin.h>
434         int main()
435         {
436             int regs[4];
437             __cpuid(regs, 0);
438             return regs[0];
439         }" HAVE_CPUID_INTRINSIC)
440 ENDIF()
442 CHECK_SYMBOL_EXISTS(aligned_alloc    stdlib.h HAVE_ALIGNED_ALLOC)
443 CHECK_SYMBOL_EXISTS(posix_memalign   stdlib.h HAVE_POSIX_MEMALIGN)
444 CHECK_SYMBOL_EXISTS(_aligned_malloc  malloc.h HAVE__ALIGNED_MALLOC)
445 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
446 CHECK_SYMBOL_EXISTS(modff  math.h HAVE_MODFF)
447 IF(NOT HAVE_C99_VLA)
448     CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
449     IF(NOT HAVE_ALLOCA)
450         MESSAGE(FATAL_ERROR "No alloca function found, please report!")
451     ENDIF()
452 ENDIF()
454 IF(HAVE_FLOAT_H)
455     CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
456     CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
457 ENDIF()
459 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
460 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
461 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
462 IF(NOT HAVE_STRCASECMP)
463     CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
464     IF(NOT HAVE__STRICMP)
465         MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
466     ENDIF()
468     ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
469 ENDIF()
471 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
472 IF(NOT HAVE_STRNCASECMP)
473     CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
474     IF(NOT HAVE__STRNICMP)
475         MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
476     ENDIF()
478     ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
479 ENDIF()
481 CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
482 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
483 IF(NOT HAVE_SNPRINTF)
484     CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
485     IF(NOT HAVE__SNPRINTF)
486         MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
487     ENDIF()
489     ADD_DEFINITIONS(-Dsnprintf=_snprintf)
490 ENDIF()
492 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
493 IF(NOT HAVE_ISFINITE)
494     CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
495     IF(NOT HAVE_FINITE)
496         CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
497         IF(NOT HAVE__FINITE)
498             MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
499         ENDIF()
500         ADD_DEFINITIONS(-Disfinite=_finite)
501     ELSE()
502         ADD_DEFINITIONS(-Disfinite=finite)
503     ENDIF()
504 ENDIF()
506 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
507 IF(NOT HAVE_ISNAN)
508     CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
509     IF(NOT HAVE__ISNAN)
510         MESSAGE(FATAL_ERROR "No isnan function found, please report!")
511     ENDIF()
513     ADD_DEFINITIONS(-Disnan=_isnan)
514 ENDIF()
517 # Check if we have Windows headers
518 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
519 IF(NOT HAVE_WINDOWS_H)
520     CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
521     IF(NOT HAVE_GETTIMEOFDAY)
522         MESSAGE(FATAL_ERROR "No timing function found!")
523     ENDIF()
525     CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
526     IF(NOT HAVE_NANOSLEEP)
527         MESSAGE(FATAL_ERROR "No sleep function found!")
528     ENDIF()
530     # We need pthreads outside of Windows
531     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
532     IF(NOT HAVE_PTHREAD_H)
533         MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
534     ENDIF()
535     # Some systems need pthread_np.h to get recursive mutexes
536     CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
538     CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
539     IF(HAVE_PTHREAD)
540         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread")
541         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
542         SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
543     ENDIF()
545     CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
546     IF(HAVE_LIBPTHREAD)
547         SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
548     ENDIF()
550     CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
552     IF(HAVE_PTHREAD_NP_H)
553         CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
554         IF(NOT HAVE_PTHREAD_SETNAME_NP)
555             CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
556         ELSE()
557             CHECK_C_SOURCE_COMPILES("
558 #include <pthread.h>
559 #include <pthread_np.h>
560 int main()
562     pthread_setname_np(\"testname\");
563     return 0;
565                 PTHREAD_SETNAME_NP_ONE_PARAM
566             )
567         ENDIF()
568         CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
569     ELSE()
570         CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
571         IF(NOT HAVE_PTHREAD_SETNAME_NP)
572             CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
573         ELSE()
574             CHECK_C_SOURCE_COMPILES("
575 #include <pthread.h>
576 int main()
578     pthread_setname_np(\"testname\");
579     return 0;
581                 PTHREAD_SETNAME_NP_ONE_PARAM
582             )
583         ENDIF()
584         CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
585     ENDIF()
587     CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
589     CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
590     IF(HAVE_LIBRT)
591         SET(EXTRA_LIBS rt ${EXTRA_LIBS})
592     ENDIF()
593 ENDIF()
595 # Check for a 64-bit type
596 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
597 IF(NOT HAVE_STDINT_H)
598     IF(HAVE_WINDOWS_H)
599         CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
600                                  #include <windows.h>
601                                  __int64 foo;
602                                  int main() {return 0;}" HAVE___INT64)
603     ENDIF()
604     IF(NOT HAVE___INT64)
605         IF(NOT SIZEOF_LONG MATCHES "8")
606             IF(NOT SIZEOF_LONG_LONG MATCHES "8")
607                 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
608             ENDIF()
609         ENDIF()
610     ENDIF()
611 ENDIF()
614 SET(COMMON_OBJS  common/almalloc.c
615                  common/atomic.c
616                  common/rwlock.c
617                  common/threads.c
618                  common/uintmap.c
620 SET(OPENAL_OBJS  OpenAL32/alAuxEffectSlot.c
621                  OpenAL32/alBuffer.c
622                  OpenAL32/alEffect.c
623                  OpenAL32/alError.c
624                  OpenAL32/alExtension.c
625                  OpenAL32/alFilter.c
626                  OpenAL32/alListener.c
627                  OpenAL32/alSource.c
628                  OpenAL32/alState.c
629                  OpenAL32/alThunk.c
630                  OpenAL32/sample_cvt.c
632 SET(ALC_OBJS  Alc/ALc.c
633               Alc/ALu.c
634               Alc/alcConfig.c
635               Alc/alcRing.c
636               Alc/bs2b.c
637               Alc/effects/autowah.c
638               Alc/effects/chorus.c
639               Alc/effects/compressor.c
640               Alc/effects/dedicated.c
641               Alc/effects/distortion.c
642               Alc/effects/echo.c
643               Alc/effects/equalizer.c
644               Alc/effects/flanger.c
645               Alc/effects/modulator.c
646               Alc/effects/null.c
647               Alc/effects/reverb.c
648               Alc/helpers.c
649               Alc/bsinc.c
650               Alc/hrtf.c
651               Alc/uhjfilter.c
652               Alc/ambdec.c
653               Alc/bformatdec.c
654               Alc/panning.c
655               Alc/mixer.c
656               Alc/mixer_c.c
660 SET(CPU_EXTS "Default")
661 SET(HAVE_SSE        0)
662 SET(HAVE_SSE2       0)
663 SET(HAVE_SSE3       0)
664 SET(HAVE_SSE4_1     0)
665 SET(HAVE_NEON       0)
667 SET(HAVE_ALSA       0)
668 SET(HAVE_OSS        0)
669 SET(HAVE_SOLARIS    0)
670 SET(HAVE_SNDIO      0)
671 SET(HAVE_QSA        0)
672 SET(HAVE_DSOUND     0)
673 SET(HAVE_MMDEVAPI   0)
674 SET(HAVE_WINMM      0)
675 SET(HAVE_PORTAUDIO  0)
676 SET(HAVE_PULSEAUDIO 0)
677 SET(HAVE_COREAUDIO  0)
678 SET(HAVE_OPENSL     0)
679 SET(HAVE_WAVE       0)
681 # Check for SSE support
682 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
683 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
684 IF(HAVE_XMMINTRIN_H)
685     OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
686     IF(ALSOFT_CPUEXT_SSE)
687         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
688             SET(HAVE_SSE 1)
689             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse.c)
690             IF(SSE_SWITCH)
691                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
692                                             COMPILE_FLAGS "${SSE_SWITCH}")
693             ENDIF()
694             SET(CPU_EXTS "${CPU_EXTS}, SSE")
695         ENDIF()
696     ENDIF()
697 ENDIF()
698 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
699     MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
700 ENDIF()
702 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
703 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
704 IF(HAVE_EMMINTRIN_H)
705     OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
706     IF(HAVE_SSE AND ALSOFT_CPUEXT_SSE2)
707         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
708             SET(HAVE_SSE2 1)
709             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse2.c)
710             IF(SSE2_SWITCH)
711                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse2.c PROPERTIES
712                                             COMPILE_FLAGS "${SSE2_SWITCH}")
713             ENDIF()
714             SET(CPU_EXTS "${CPU_EXTS}, SSE2")
715         ENDIF()
716     ENDIF()
717 ENDIF()
718 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
719     MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
720 ENDIF()
722 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE3 support" OFF)
723 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
724 IF(HAVE_EMMINTRIN_H)
725     OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
726     IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
727         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
728             SET(HAVE_SSE3 1)
729             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse3.c)
730             IF(SSE2_SWITCH)
731                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse3.c PROPERTIES
732                                             COMPILE_FLAGS "${SSE3_SWITCH}")
733             ENDIF()
734             SET(CPU_EXTS "${CPU_EXTS}, SSE3")
735         ENDIF()
736     ENDIF()
737 ENDIF()
738 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
739     MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
740 ENDIF()
742 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
743 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
744 IF(HAVE_SMMINTRIN_H)
745     OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
746     IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE4_1)
747         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
748             SET(HAVE_SSE4_1 1)
749             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse41.c)
750             IF(SSE4_1_SWITCH)
751                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse41.c PROPERTIES
752                                             COMPILE_FLAGS "${SSE4_1_SWITCH}")
753             ENDIF()
754             SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
755         ENDIF()
756     ENDIF()
757 ENDIF()
758 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
759     MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
760 ENDIF()
762 # Check for ARM Neon support
763 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
764 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
765 IF(HAVE_ARM_NEON_H)
766     OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
767     IF(ALSOFT_CPUEXT_NEON)
768         SET(HAVE_NEON 1)
769         SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_neon.c)
770         SET(CPU_EXTS "${CPU_EXTS}, Neon")
771     ENDIF()
772 ENDIF()
773 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
774     MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
775 ENDIF()
778 IF(WIN32 OR HAVE_DLFCN_H)
779     SET(IS_LINKED "")
780     MACRO(ADD_BACKEND_LIBS _LIBS)
781     ENDMACRO()
782 ELSE()
783     SET(IS_LINKED " (linked)")
784     MACRO(ADD_BACKEND_LIBS _LIBS)
785         SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
786     ENDMACRO()
787 ENDIF()
789 SET(BACKENDS "")
790 SET(ALC_OBJS  ${ALC_OBJS}
791               Alc/backends/base.c
792               # Default backends, always available
793               Alc/backends/loopback.c
794               Alc/backends/null.c
797 # Check ALSA backend
798 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
799 FIND_PACKAGE(ALSA)
800 IF(ALSA_FOUND)
801     OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
802     IF(ALSOFT_BACKEND_ALSA)
803         SET(HAVE_ALSA 1)
804         SET(BACKENDS  "${BACKENDS} ALSA${IS_LINKED},")
805         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/alsa.c)
806         ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
807         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
808             INCLUDE_DIRECTORIES(${ALSA_INCLUDE_DIRS})
809         ENDIF()
810     ENDIF()
811 ENDIF()
812 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
813     MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
814 ENDIF()
816 # Check OSS backend
817 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
818 FIND_PACKAGE(OSS)
819 IF(OSS_FOUND)
820     OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
821     IF(ALSOFT_BACKEND_OSS)
822         SET(HAVE_OSS 1)
823         SET(BACKENDS  "${BACKENDS} OSS,")
824         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/oss.c)
825         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
826             INCLUDE_DIRECTORIES(${OSS_INCLUDE_DIRS})
827         ENDIF()
828     ENDIF()
829 ENDIF()
830 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
831     MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
832 ENDIF()
834 # Check Solaris backend
835 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
836 FIND_PACKAGE(AudioIO)
837 IF(AUDIOIO_FOUND)
838     OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
839     IF(ALSOFT_BACKEND_SOLARIS)
840         SET(HAVE_SOLARIS 1)
841         SET(BACKENDS  "${BACKENDS} Solaris,")
842         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/solaris.c)
843         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
844             INCLUDE_DIRECTORIES(${AUDIOIO_INCLUDE_DIRS})
845         ENDIF()
846     ENDIF()
847 ENDIF()
848 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
849     MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
850 ENDIF()
852 # Check SndIO backend
853 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
854 FIND_PACKAGE(SoundIO)
855 IF(SOUNDIO_FOUND)
856     OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
857     IF(ALSOFT_BACKEND_SNDIO)
858         SET(HAVE_SNDIO 1)
859         SET(BACKENDS  "${BACKENDS} SndIO (linked),")
860         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/sndio.c)
861         SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
862         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
863             INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
864         ENDIF()
865     ENDIF()
866 ENDIF()
867 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
868     MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
869 ENDIF()
871 # Check QSA backend
872 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
873 FIND_PACKAGE(QSA)
874 IF(QSA_FOUND)
875     OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
876     IF(ALSOFT_BACKEND_QSA)
877         SET(HAVE_QSA 1)
878         SET(BACKENDS  "${BACKENDS} QSA (linked),")
879         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/qsa.c)
880         SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
881         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
882             INCLUDE_DIRECTORIES(${QSA_INCLUDE_DIRS})
883         ENDIF()
884     ENDIF()
885 ENDIF()
886 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
887     MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
888 ENDIF()
890 # Check Windows-only backends
891 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
892 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
893 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
894 IF(HAVE_WINDOWS_H)
895     # Check MMSystem backend
896     CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
897     IF(HAVE_MMSYSTEM_H)
898         CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
899         IF(HAVE_LIBWINMM)
900             OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
901             IF(ALSOFT_BACKEND_WINMM)
902                 SET(HAVE_WINMM 1)
903                 SET(BACKENDS  "${BACKENDS} WinMM,")
904                 SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/winmm.c)
905                 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
906             ENDIF()
907         ENDIF()
908     ENDIF()
910     # Check DSound backend
911     FIND_PACKAGE(DSound)
912     IF(DSOUND_FOUND)
913         OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
914         IF(ALSOFT_BACKEND_DSOUND)
915             SET(HAVE_DSOUND 1)
916             SET(BACKENDS  "${BACKENDS} DirectSound${IS_LINKED},")
917             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/dsound.c)
918             ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
919             IF(CMAKE_VERSION VERSION_LESS "2.8.8")
920                 INCLUDE_DIRECTORIES(${DSOUND_INCLUDE_DIRS})
921             ENDIF()
922         ENDIF()
923     ENDIF()
925     # Check for MMDevApi backend
926     CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
927     IF(HAVE_MMDEVICEAPI_H)
928         OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
929         IF(ALSOFT_BACKEND_MMDEVAPI)
930             SET(HAVE_MMDEVAPI 1)
931             SET(BACKENDS  "${BACKENDS} MMDevApi,")
932             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/mmdevapi.c)
933         ENDIF()
934     ENDIF()
935 ENDIF()
936 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
937     MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
938 ENDIF()
939 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
940     MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
941 ENDIF()
942 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
943     MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
944 ENDIF()
946 # Check PortAudio backend
947 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
948 FIND_PACKAGE(PortAudio)
949 IF(PORTAUDIO_FOUND)
950     OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
951     IF(ALSOFT_BACKEND_PORTAUDIO)
952         SET(HAVE_PORTAUDIO 1)
953         SET(BACKENDS  "${BACKENDS} PortAudio${IS_LINKED},")
954         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/portaudio.c)
955         ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
956         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
957             INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
958         ENDIF()
959     ENDIF()
960 ENDIF()
961 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
962     MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
963 ENDIF()
965 # Check PulseAudio backend
966 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
967 FIND_PACKAGE(PulseAudio)
968 IF(PULSEAUDIO_FOUND)
969     OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
970     IF(ALSOFT_BACKEND_PULSEAUDIO)
971         SET(HAVE_PULSEAUDIO 1)
972         SET(BACKENDS  "${BACKENDS} PulseAudio${IS_LINKED},")
973         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/pulseaudio.c)
974         ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
975         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
976             INCLUDE_DIRECTORIES(${PULSEAUDIO_INCLUDE_DIRS})
977         ENDIF()
978     ENDIF()
979 ENDIF()
980 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
981     MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
982 ENDIF()
984 # Check JACK backend
985 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
986 FIND_PACKAGE(JACK)
987 IF(JACK_FOUND)
988     OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
989     IF(ALSOFT_BACKEND_JACK)
990         SET(HAVE_JACK 1)
991         SET(BACKENDS  "${BACKENDS} JACK${IS_LINKED},")
992         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/jack.c)
993         ADD_BACKEND_LIBS(${JACK_LIBRARIES})
994         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
995             INCLUDE_DIRECTORIES(${JACK_INCLUDE_DIRS})
996         ENDIF()
997     ENDIF()
998 ENDIF()
999 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1000     MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
1001 ENDIF()
1003 # Check CoreAudio backend
1004 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1005 FIND_LIBRARY(COREAUDIO_FRAMEWORK
1006              NAMES CoreAudio
1007              PATHS /System/Library/Frameworks
1009 IF(COREAUDIO_FRAMEWORK)
1010     OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1011     IF(ALSOFT_BACKEND_COREAUDIO)
1012         SET(HAVE_COREAUDIO 1)
1013         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/coreaudio.c)
1014         SET(BACKENDS  "${BACKENDS} CoreAudio,")
1015         SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1016         SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1017         SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1019         # Some versions of OSX may need the AudioToolbox framework. Add it if
1020         # it's found.
1021         FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1022                      NAMES AudioToolbox
1023                      PATHS ~/Library/Frameworks
1024                            /Library/Frameworks
1025                            /System/Library/Frameworks
1026                     )
1027         IF(AUDIOTOOLBOX_LIBRARY)
1028             SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1029         ENDIF()
1030     ENDIF()
1031 ENDIF()
1032 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1033     MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1034 ENDIF()
1036 # Check for OpenSL (Android) backend
1037 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1038 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
1039 IF(HAVE_SLES_OPENSLES_ANDROID_H)
1040     CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
1041     IF(HAVE_LIBOPENSLES)
1042         OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1043         IF(ALSOFT_BACKEND_OPENSL)
1044             SET(HAVE_OPENSL 1)
1045             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/opensl.c)
1046             SET(BACKENDS  "${BACKENDS} OpenSL,")
1047             SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
1048         ENDIF()
1049     ENDIF()
1050 ENDIF()
1051 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1052     MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1053 ENDIF()
1055 # Optionally enable the Wave Writer backend
1056 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1057 IF(ALSOFT_BACKEND_WAVE)
1058     SET(HAVE_WAVE 1)
1059     SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/wave.c)
1060     SET(BACKENDS  "${BACKENDS} WaveFile,")
1061 ENDIF()
1063 # This is always available
1064 SET(BACKENDS  "${BACKENDS} Null")
1066 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" OFF)
1067 if(ALSOFT_EMBED_HRTF_DATA)
1068     if(WIN32)
1069         set(ALC_OBJS  ${ALC_OBJS} Alc/hrtf_res.rc)
1070     else()
1071         set(FILENAMES default-44100.mhr default-48000.mhr)
1072         foreach(FILENAME ${FILENAMES})
1073             set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
1074             add_custom_command(OUTPUT ${outfile}
1075                 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
1076                 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
1077                 COMMAND "${CMAKE_LINKER}" -r -b binary -o "${outfile}" ${FILENAME}
1078                 COMMAND "${CMAKE_OBJCOPY}" --rename-section .data=.rodata,alloc,load,readonly,data,contents "${outfile}" "${outfile}"
1079                 COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
1080                 VERBATIM
1081             )
1082             set(ALC_OBJS  ${ALC_OBJS} ${outfile})
1083         endforeach()
1084         unset(outfile)
1085         unset(FILENAMES)
1086     endif()
1087 endif()
1090 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1091     add_subdirectory(utils/alsoft-config)
1092 ENDIF()
1093 IF(ALSOFT_EXAMPLES)
1094     FIND_PACKAGE(SDL2)
1095     IF(SDL2_FOUND)
1096         FIND_PACKAGE(SDL_sound)
1097         IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1098             INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1099         ENDIF()
1100         FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1101         IF(FFMPEG_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1102             INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
1103         ENDIF()
1104     ENDIF()
1105 ENDIF()
1107 IF(LIBTYPE STREQUAL "STATIC")
1108     ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
1109     SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
1110 ENDIF()
1112 # Needed for openal.pc.in
1113 SET(prefix ${CMAKE_INSTALL_PREFIX})
1114 SET(exec_prefix "\${prefix}")
1115 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
1116 SET(bindir "\${exec_prefix}/bin")
1117 SET(includedir "\${prefix}/include")
1118 SET(PACKAGE_VERSION "${LIB_VERSION}")
1120 # End configuration
1121 CONFIGURE_FILE(
1122     "${OpenAL_SOURCE_DIR}/config.h.in"
1123     "${OpenAL_BINARY_DIR}/config.h")
1124 CONFIGURE_FILE(
1125     "${OpenAL_SOURCE_DIR}/openal.pc.in"
1126     "${OpenAL_BINARY_DIR}/openal.pc"
1127     @ONLY)
1129 # Build a common library with reusable helpers
1130 ADD_LIBRARY(common STATIC ${COMMON_OBJS})
1131 SET_PROPERTY(TARGET common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1132 IF(NOT LIBTYPE STREQUAL "STATIC")
1133     SET_PROPERTY(TARGET common PROPERTY POSITION_INDEPENDENT_CODE TRUE)
1134 ENDIF()
1136 # Build main library
1137 IF(LIBTYPE STREQUAL "STATIC")
1138     ADD_LIBRARY(${LIBNAME} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1139 ELSE()
1140     ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
1141 ENDIF()
1142 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1143 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
1144 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1145     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
1146 ENDIF()
1147 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
1148 IF(HAVE_ALSA)
1149     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
1150 ENDIF()
1151 IF(HAVE_OSS)
1152     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
1153 ENDIF()
1154 IF(HAVE_SOLARIS)
1155     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
1156 ENDIF()
1157 IF(HAVE_SNDIO)
1158     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
1159 ENDIF()
1160 IF(HAVE_QSA)
1161     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
1162 ENDIF()
1163 IF(HAVE_DSOUND)
1164     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
1165 ENDIF()
1166 IF(HAVE_PORTAUDIO)
1167     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
1168 ENDIF()
1169 IF(HAVE_PULSEAUDIO)
1170     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
1171 ENDIF()
1172 IF(HAVE_JACK)
1173     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
1174 ENDIF()
1175 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
1176                                             SOVERSION ${LIB_MAJOR_VERSION})
1177 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
1178     SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
1180     IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
1181         FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1182         FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1183         IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1184             MESSAGE(STATUS "")
1185             IF(NOT SED_EXECUTABLE)
1186                 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1187             ENDIF()
1188             IF(NOT DLLTOOL_EXECUTABLE)
1189                 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1190             ENDIF()
1191         ELSE()
1192             SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--output-def,${LIBNAME}.def")
1193             ADD_CUSTOM_COMMAND(TARGET ${LIBNAME} POST_BUILD
1194                 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" ${LIBNAME}.def
1195                 COMMAND "${DLLTOOL_EXECUTABLE}" -d ${LIBNAME}.def -l ${LIBNAME}.lib -D ${LIBNAME}.dll
1196                 COMMENT "Stripping ordinals from ${LIBNAME}.def and generating ${LIBNAME}.lib..."
1197                 VERBATIM
1198             )
1199         ENDIF()
1200     ENDIF()
1201 ENDIF()
1203 TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
1205 IF(ALSOFT_INSTALL)
1206     # Add an install target here
1207     INSTALL(TARGETS ${LIBNAME}
1208             RUNTIME DESTINATION bin
1209             LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1210             ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1211     )
1212     INSTALL(FILES include/AL/al.h
1213                   include/AL/alc.h
1214                   include/AL/alext.h
1215                   include/AL/efx.h
1216                   include/AL/efx-creative.h
1217                   include/AL/efx-presets.h
1218             DESTINATION include/AL
1219     )
1220     INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1221             DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
1222 ENDIF()
1225 MESSAGE(STATUS "")
1226 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1227 MESSAGE(STATUS "    ${BACKENDS}")
1228 MESSAGE(STATUS "")
1229 MESSAGE(STATUS "Building with support for CPU extensions:")
1230 MESSAGE(STATUS "    ${CPU_EXTS}")
1231 MESSAGE(STATUS "")
1233 IF(WIN32)
1234     IF(NOT HAVE_DSOUND)
1235         MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1236         MESSAGE(STATUS "         This is probably NOT what you want!")
1237         MESSAGE(STATUS "")
1238     ENDIF()
1239 ENDIF()
1241 if(ALSOFT_EMBED_HRTF_DATA)
1242     message(STATUS "Embedding HRTF datasets")
1243     message(STATUS "")
1244 endif()
1246 # Install alsoft.conf configuration file
1247 IF(ALSOFT_CONFIG)
1248     INSTALL(FILES alsoftrc.sample
1249             DESTINATION ${SHARE_INSTALL_DIR}/openal
1250     )
1251     MESSAGE(STATUS "Installing sample configuration")
1252     MESSAGE(STATUS "")
1253 ENDIF()
1255 # Install HRTF definitions
1256 IF(ALSOFT_HRTF_DEFS)
1257     INSTALL(FILES hrtf/default-44100.mhr
1258                   hrtf/default-48000.mhr
1259             DESTINATION ${SHARE_INSTALL_DIR}/openal/hrtf
1260     )
1261     MESSAGE(STATUS "Installing HRTF definitions")
1262     MESSAGE(STATUS "")
1263 ENDIF()
1265 # Install AmbDec presets
1266 IF(ALSOFT_AMBDEC_PRESETS)
1267     INSTALL(FILES presets/3D7.1.ambdec
1268                   presets/hexagon.ambdec
1269                   presets/itu5.1.ambdec
1270                   presets/rectangle.ambdec
1271                   presets/square.ambdec
1272                   presets/presets.txt
1273             DESTINATION ${SHARE_INSTALL_DIR}/openal/presets
1274     )
1275     MESSAGE(STATUS "Installing AmbDec presets")
1276     MESSAGE(STATUS "")
1277 ENDIF()
1279 IF(ALSOFT_UTILS)
1280     ADD_EXECUTABLE(openal-info utils/openal-info.c)
1281     SET_PROPERTY(TARGET openal-info APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1282     TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
1284     ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1285     SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1286     IF(HAVE_LIBM)
1287         TARGET_LINK_LIBRARIES(makehrtf m)
1288     ENDIF()
1290     ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
1291     SET_PROPERTY(TARGET bsincgen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1292     IF(HAVE_LIBM)
1293         TARGET_LINK_LIBRARIES(bsincgen m)
1294     ENDIF()
1296     IF(ALSOFT_INSTALL)
1297         INSTALL(TARGETS openal-info makehrtf bsincgen
1298                 RUNTIME DESTINATION bin
1299                 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1300                 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1301         )
1302     ENDIF()
1304     MESSAGE(STATUS "Building utility programs")
1305     IF(TARGET alsoft-config)
1306         MESSAGE(STATUS "Building configuration program")
1307     ENDIF()
1308     MESSAGE(STATUS "")
1309 ENDIF()
1311 IF(ALSOFT_TESTS)
1312     ADD_LIBRARY(test-common STATIC examples/common/alhelpers.c)
1313     SET_PROPERTY(TARGET test-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1315     ADD_EXECUTABLE(altonegen examples/altonegen.c)
1316     TARGET_LINK_LIBRARIES(altonegen test-common ${LIBNAME})
1317     SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1319     IF(ALSOFT_INSTALL)
1320         INSTALL(TARGETS altonegen
1321                 RUNTIME DESTINATION bin
1322                 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1323                 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1324         )
1325     ENDIF()
1327     MESSAGE(STATUS "Building test programs")
1328     MESSAGE(STATUS "")
1329 ENDIF()
1331 IF(ALSOFT_EXAMPLES)
1332     IF(SDL2_FOUND AND SDL_SOUND_FOUND)
1333         ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1334                                      examples/common/sdl_sound.c)
1335         SET_PROPERTY(TARGET ex-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1336         SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1337                                                                           ${SDL_SOUND_INCLUDE_DIR})
1339         ADD_EXECUTABLE(alstream examples/alstream.c)
1340         TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1341                                        common ${LIBNAME})
1342         SET_PROPERTY(TARGET alstream APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1343         SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1344                                                                          ${SDL_SOUND_INCLUDE_DIR})
1346         ADD_EXECUTABLE(alreverb examples/alreverb.c)
1347         TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1348                                        common ${LIBNAME})
1349         SET_PROPERTY(TARGET alreverb APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1350         SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1351                                                                          ${SDL_SOUND_INCLUDE_DIR})
1353         ADD_EXECUTABLE(allatency examples/allatency.c)
1354         TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1355                                         common ${LIBNAME})
1356         SET_PROPERTY(TARGET allatency APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1357         SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1358                                                                           ${SDL_SOUND_INCLUDE_DIR})
1360         ADD_EXECUTABLE(alloopback examples/alloopback.c)
1361         TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1362                                          common ${LIBNAME})
1363         SET_PROPERTY(TARGET alloopback APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1364         SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1365                                                                            ${SDL_SOUND_INCLUDE_DIR})
1367         ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1368         TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1369                                      common ${LIBNAME})
1370         SET_PROPERTY(TARGET alhrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1371         SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1372                                                                        ${SDL_SOUND_INCLUDE_DIR})
1374         IF(ALSOFT_INSTALL)
1375             INSTALL(TARGETS alstream alreverb allatency alloopback alhrtf
1376                     RUNTIME DESTINATION bin
1377                     LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1378                     ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1379             )
1380         ENDIF()
1382         SET(FFVER_OK FALSE)
1383         IF(FFMPEG_FOUND)
1384             SET(FFVER_OK TRUE)
1385             IF(AVFORMAT_VERSION VERSION_LESS "55.33.100")
1386                 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 55.33.100)")
1387                 SET(FFVER_OK FALSE)
1388             ENDIF()
1389             IF(AVCODEC_VERSION VERSION_LESS "55.52.102")
1390                 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 55.52.102)")
1391                 SET(FFVER_OK FALSE)
1392             ENDIF()
1393             IF(AVUTIL_VERSION VERSION_LESS "52.66.100")
1394                 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 52.66.100)")
1395                 SET(FFVER_OK FALSE)
1396             ENDIF()
1397             IF(SWSCALE_VERSION VERSION_LESS "2.5.102")
1398                 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 2.5.102)")
1399                 SET(FFVER_OK FALSE)
1400             ENDIF()
1401             IF(SWRESAMPLE_VERSION VERSION_LESS "0.18.100")
1402                 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 0.18.100)")
1403                 SET(FFVER_OK FALSE)
1404             ENDIF()
1405         ENDIF()
1406         IF(FFVER_OK AND NOT MSVC)
1407             ADD_EXECUTABLE(alffplay examples/alffplay.c)
1408             TARGET_LINK_LIBRARIES(alffplay common ex-common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
1409             SET_PROPERTY(TARGET alffplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1410             SET_PROPERTY(TARGET alffplay APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1411                                                                              ${FFMPEG_INCLUDE_DIRS})
1413             IF(ALSOFT_INSTALL)
1414                 INSTALL(TARGETS alffplay
1415                         RUNTIME DESTINATION bin
1416                         LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1417                         ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1418                 )
1419             ENDIF()
1420             MESSAGE(STATUS "Building SDL and FFmpeg example programs")
1421         ELSE()
1422             MESSAGE(STATUS "Building SDL example programs")
1423         ENDIF()
1424         MESSAGE(STATUS "")
1425     ENDIF()
1426 ENDIF()