Increment the device's mix count closer to the mixing loops
[openal-soft.git] / CMakeLists.txt
blob6deb43a435f69210444565ecac9f0ac0c0365342
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 IF(MSVC)
243     ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
244     ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
245     ADD_DEFINITIONS("/wd4098")
247     IF(NOT DXSDK_DIR)
248         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
249     ELSE()
250         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
251     ENDIF()
252     IF(DXSDK_DIR)
253         MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
254     ENDIF()
256     OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
257     IF(FORCE_STATIC_VCRT)
258         FOREACH(flag_var
259                 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
260                 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
261             IF(${flag_var} MATCHES "/MD")
262                 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
263             ENDIF()
264         ENDFOREACH(flag_var)
265     ENDIF()
266 ELSE()
267     ADD_DEFINITIONS(-Winline -Wall)
268     CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
269     IF(HAVE_W_EXTRA)
270         ADD_DEFINITIONS(-Wextra)
271     ENDIF()
273     IF(ALSOFT_WERROR)
274         ADD_DEFINITIONS(-Werror)
275     ENDIF()
277     # Force enable -fPIC for CMake versions before 2.8.9 (later versions have
278     # the POSITION_INDEPENDENT_CODE target property). The static common library
279     # will be linked into the dynamic openal library, which requires all its
280     # code to be position-independent.
281     IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
282         CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
283         IF(HAVE_FPIC_SWITCH)
284             ADD_DEFINITIONS(-fPIC)
285         ENDIF()
286     ENDIF()
288     # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
289     # instead of NDEBUG)
290     FOREACH(flag_var  CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
291         IF(${flag_var} MATCHES "-DNDEBUG")
292             STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
293         ENDIF()
294     ENDFOREACH()
296     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
297                              int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
299     option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
300     if(ALSOFT_STATIC_LIBGCC)
301         set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
302         set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
303         check_c_source_compiles(
304 "#include <stdlib.h>
305 int main()
307     return 0;
309             HAVE_STATIC_LIBGCC_SWITCH
310         )
311         if(HAVE_STATIC_LIBGCC_SWITCH)
312             set(EXTRA_LIBS ${EXTRA_LIBS} -static-libgcc)
313         endif()
314         set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
315         unset(OLD_REQUIRED_LIBRARIES)
316     endif()
317 ENDIF()
319 # Set visibility/export options if available
320 IF(WIN32)
321     SET(EXPORT_DECL "__declspec(dllexport)")
322     IF(NOT MINGW)
323         SET(ALIGN_DECL "__declspec(align(x))")
324     ELSE()
325         SET(ALIGN_DECL "__declspec(aligned(x))")
326     ENDIF()
327 ELSE()
328     SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
329     # Yes GCC, really don't accept visibility modes you don't support
330     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
332     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
333                              int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
334     IF(HAVE_GCC_PROTECTED_VISIBILITY)
335         SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
336     ELSE()
337         CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
338                                  int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
339         IF(HAVE_GCC_DEFAULT_VISIBILITY)
340             SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
341         ENDIF()
342     ENDIF()
344     IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
345         CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
346         IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
347             ADD_DEFINITIONS(-fvisibility=hidden)
348         ENDIF()
349     ENDIF()
351     CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
352                              int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
353     IF(HAVE_ATTRIBUTE_ALIGNED)
354         SET(ALIGN_DECL "__attribute__((aligned(x)))")
355     ENDIF()
357     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
358 ENDIF()
360 SET(SSE_SWITCH "")
361 SET(SSE2_SWITCH "")
362 SET(SSE3_SWITCH "")
363 SET(SSE4_1_SWITCH "")
364 IF(NOT MSVC)
365     CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
366     IF(HAVE_MSSE_SWITCH)
367         SET(SSE_SWITCH "-msse")
368     ENDIF()
369     CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
370     IF(HAVE_MSSE2_SWITCH)
371         SET(SSE2_SWITCH "-msse2")
372     ENDIF()
373     CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
374     IF(HAVE_MSSE3_SWITCH)
375         SET(SSE3_SWITCH "-msse3")
376     ENDIF()
377     CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
378     IF(HAVE_MSSE4_1_SWITCH)
379         SET(SSE4_1_SWITCH "-msse4.1")
380     ENDIF()
381 ENDIF()
383 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
384                          int main() {return 0;}" HAVE_GCC_FORMAT)
386 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
387 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
388 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
389 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
390 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
391 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
392 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
393 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
394 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
395 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
396 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
397 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
398 IF(NOT HAVE_GUIDDEF_H)
399     CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
400 ENDIF()
402 # Some systems need libm for some of the following math functions to work
403 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
404 IF(HAVE_LIBM)
405     SET(EXTRA_LIBS m ${EXTRA_LIBS})
406     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
407 ENDIF()
409 # Check for the dlopen API (for dynamicly loading backend libs)
410 IF(ALSOFT_DLOPEN)
411     CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
412     IF(HAVE_LIBDL)
413         SET(EXTRA_LIBS dl ${EXTRA_LIBS})
414         SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
415     ENDIF()
417     CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
418 ENDIF()
420 # Check for a cpuid intrinsic
421 IF(HAVE_CPUID_H)
422     CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
423         int main()
424         {
425             unsigned int eax, ebx, ecx, edx;
426             return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
427         }" HAVE_GCC_GET_CPUID)
428 ENDIF()
429 IF(HAVE_INTRIN_H)
430     CHECK_C_SOURCE_COMPILES("#include <intrin.h>
431         int main()
432         {
433             int regs[4];
434             __cpuid(regs, 0);
435             return regs[0];
436         }" HAVE_CPUID_INTRINSIC)
437 ENDIF()
439 CHECK_SYMBOL_EXISTS(aligned_alloc    stdlib.h HAVE_ALIGNED_ALLOC)
440 CHECK_SYMBOL_EXISTS(posix_memalign   stdlib.h HAVE_POSIX_MEMALIGN)
441 CHECK_SYMBOL_EXISTS(_aligned_malloc  malloc.h HAVE__ALIGNED_MALLOC)
442 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
443 CHECK_SYMBOL_EXISTS(modff  math.h HAVE_MODFF)
444 IF(NOT HAVE_C99_VLA)
445     CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
446     IF(NOT HAVE_ALLOCA)
447         MESSAGE(FATAL_ERROR "No alloca function found, please report!")
448     ENDIF()
449 ENDIF()
451 IF(HAVE_FLOAT_H)
452     CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
453     CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
454 ENDIF()
456 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
457 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
458 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
459 IF(NOT HAVE_STRCASECMP)
460     CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
461     IF(NOT HAVE__STRICMP)
462         MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
463     ENDIF()
465     ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
466 ENDIF()
468 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
469 IF(NOT HAVE_STRNCASECMP)
470     CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
471     IF(NOT HAVE__STRNICMP)
472         MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
473     ENDIF()
475     ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
476 ENDIF()
478 CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
479 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
480 IF(NOT HAVE_SNPRINTF)
481     CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
482     IF(NOT HAVE__SNPRINTF)
483         MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
484     ENDIF()
486     ADD_DEFINITIONS(-Dsnprintf=_snprintf)
487 ENDIF()
489 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
490 IF(NOT HAVE_ISFINITE)
491     CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
492     IF(NOT HAVE_FINITE)
493         CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
494         IF(NOT HAVE__FINITE)
495             MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
496         ENDIF()
497         ADD_DEFINITIONS(-Disfinite=_finite)
498     ELSE()
499         ADD_DEFINITIONS(-Disfinite=finite)
500     ENDIF()
501 ENDIF()
503 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
504 IF(NOT HAVE_ISNAN)
505     CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
506     IF(NOT HAVE__ISNAN)
507         MESSAGE(FATAL_ERROR "No isnan function found, please report!")
508     ENDIF()
510     ADD_DEFINITIONS(-Disnan=_isnan)
511 ENDIF()
514 # Check if we have Windows headers
515 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
516 IF(NOT HAVE_WINDOWS_H)
517     CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
518     IF(NOT HAVE_GETTIMEOFDAY)
519         MESSAGE(FATAL_ERROR "No timing function found!")
520     ENDIF()
522     CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
523     IF(NOT HAVE_NANOSLEEP)
524         MESSAGE(FATAL_ERROR "No sleep function found!")
525     ENDIF()
527     # We need pthreads outside of Windows
528     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
529     IF(NOT HAVE_PTHREAD_H)
530         MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
531     ENDIF()
532     # Some systems need pthread_np.h to get recursive mutexes
533     CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
535     CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
536     IF(HAVE_PTHREAD)
537         ADD_DEFINITIONS(-pthread)
538         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
539         SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
540     ENDIF()
542     CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
543     IF(HAVE_LIBPTHREAD)
544         SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
545     ENDIF()
547     CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
549     IF(HAVE_PTHREAD_NP_H)
550         CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
551         IF(NOT HAVE_PTHREAD_SETNAME_NP)
552             CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
553         ELSE()
554             CHECK_C_SOURCE_COMPILES("
555 #include <pthread.h>
556 #include <pthread_np.h>
557 int main()
559     pthread_setname_np(\"testname\");
560     return 0;
562                 PTHREAD_SETNAME_NP_ONE_PARAM
563             )
564         ENDIF()
565         CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
566     ELSE()
567         CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
568         IF(NOT HAVE_PTHREAD_SETNAME_NP)
569             CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
570         ELSE()
571             CHECK_C_SOURCE_COMPILES("
572 #include <pthread.h>
573 int main()
575     pthread_setname_np(\"testname\");
576     return 0;
578                 PTHREAD_SETNAME_NP_ONE_PARAM
579             )
580         ENDIF()
581         CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
582     ENDIF()
584     CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
586     CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
587     IF(HAVE_LIBRT)
588         SET(EXTRA_LIBS rt ${EXTRA_LIBS})
589     ENDIF()
590 ENDIF()
592 # Check for a 64-bit type
593 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
594 IF(NOT HAVE_STDINT_H)
595     IF(HAVE_WINDOWS_H)
596         CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
597                                  #include <windows.h>
598                                  __int64 foo;
599                                  int main() {return 0;}" HAVE___INT64)
600     ENDIF()
601     IF(NOT HAVE___INT64)
602         IF(NOT SIZEOF_LONG MATCHES "8")
603             IF(NOT SIZEOF_LONG_LONG MATCHES "8")
604                 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
605             ENDIF()
606         ENDIF()
607     ENDIF()
608 ENDIF()
611 SET(COMMON_OBJS  common/almalloc.c
612                  common/atomic.c
613                  common/rwlock.c
614                  common/threads.c
615                  common/uintmap.c
617 SET(OPENAL_OBJS  OpenAL32/alAuxEffectSlot.c
618                  OpenAL32/alBuffer.c
619                  OpenAL32/alEffect.c
620                  OpenAL32/alError.c
621                  OpenAL32/alExtension.c
622                  OpenAL32/alFilter.c
623                  OpenAL32/alListener.c
624                  OpenAL32/alSource.c
625                  OpenAL32/alState.c
626                  OpenAL32/alThunk.c
627                  OpenAL32/sample_cvt.c
629 SET(ALC_OBJS  Alc/ALc.c
630               Alc/ALu.c
631               Alc/alcConfig.c
632               Alc/alcRing.c
633               Alc/bs2b.c
634               Alc/effects/autowah.c
635               Alc/effects/chorus.c
636               Alc/effects/compressor.c
637               Alc/effects/dedicated.c
638               Alc/effects/distortion.c
639               Alc/effects/echo.c
640               Alc/effects/equalizer.c
641               Alc/effects/flanger.c
642               Alc/effects/modulator.c
643               Alc/effects/null.c
644               Alc/effects/reverb.c
645               Alc/helpers.c
646               Alc/bsinc.c
647               Alc/hrtf.c
648               Alc/uhjfilter.c
649               Alc/ambdec.c
650               Alc/bformatdec.c
651               Alc/panning.c
652               Alc/mixer.c
653               Alc/mixer_c.c
657 SET(CPU_EXTS "Default")
658 SET(HAVE_SSE        0)
659 SET(HAVE_SSE2       0)
660 SET(HAVE_SSE3       0)
661 SET(HAVE_SSE4_1     0)
662 SET(HAVE_NEON       0)
664 SET(HAVE_ALSA       0)
665 SET(HAVE_OSS        0)
666 SET(HAVE_SOLARIS    0)
667 SET(HAVE_SNDIO      0)
668 SET(HAVE_QSA        0)
669 SET(HAVE_DSOUND     0)
670 SET(HAVE_MMDEVAPI   0)
671 SET(HAVE_WINMM      0)
672 SET(HAVE_PORTAUDIO  0)
673 SET(HAVE_PULSEAUDIO 0)
674 SET(HAVE_COREAUDIO  0)
675 SET(HAVE_OPENSL     0)
676 SET(HAVE_WAVE       0)
678 # Check for SSE support
679 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
680 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
681 IF(HAVE_XMMINTRIN_H)
682     OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
683     IF(ALSOFT_CPUEXT_SSE)
684         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
685             SET(HAVE_SSE 1)
686             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse.c)
687             IF(SSE_SWITCH)
688                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
689                                             COMPILE_FLAGS "${SSE_SWITCH}")
690             ENDIF()
691             SET(CPU_EXTS "${CPU_EXTS}, SSE")
692         ENDIF()
693     ENDIF()
694 ENDIF()
695 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
696     MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
697 ENDIF()
699 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
700 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
701 IF(HAVE_EMMINTRIN_H)
702     OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
703     IF(HAVE_SSE AND ALSOFT_CPUEXT_SSE2)
704         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
705             SET(HAVE_SSE2 1)
706             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse2.c)
707             IF(SSE2_SWITCH)
708                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse2.c PROPERTIES
709                                             COMPILE_FLAGS "${SSE2_SWITCH}")
710             ENDIF()
711             SET(CPU_EXTS "${CPU_EXTS}, SSE2")
712         ENDIF()
713     ENDIF()
714 ENDIF()
715 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
716     MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
717 ENDIF()
719 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE3 support" OFF)
720 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
721 IF(HAVE_EMMINTRIN_H)
722     OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
723     IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
724         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
725             SET(HAVE_SSE3 1)
726             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse3.c)
727             IF(SSE2_SWITCH)
728                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse3.c PROPERTIES
729                                             COMPILE_FLAGS "${SSE3_SWITCH}")
730             ENDIF()
731             SET(CPU_EXTS "${CPU_EXTS}, SSE3")
732         ENDIF()
733     ENDIF()
734 ENDIF()
735 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
736     MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
737 ENDIF()
739 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
740 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
741 IF(HAVE_SMMINTRIN_H)
742     OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
743     IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE4_1)
744         IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
745             SET(HAVE_SSE4_1 1)
746             SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse41.c)
747             IF(SSE4_1_SWITCH)
748                 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse41.c PROPERTIES
749                                             COMPILE_FLAGS "${SSE4_1_SWITCH}")
750             ENDIF()
751             SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
752         ENDIF()
753     ENDIF()
754 ENDIF()
755 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
756     MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
757 ENDIF()
759 # Check for ARM Neon support
760 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
761 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
762 IF(HAVE_ARM_NEON_H)
763     OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
764     IF(ALSOFT_CPUEXT_NEON)
765         SET(HAVE_NEON 1)
766         SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_neon.c)
767         SET(CPU_EXTS "${CPU_EXTS}, Neon")
768     ENDIF()
769 ENDIF()
770 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
771     MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
772 ENDIF()
775 IF(WIN32 OR HAVE_DLFCN_H)
776     SET(IS_LINKED "")
777     MACRO(ADD_BACKEND_LIBS _LIBS)
778     ENDMACRO()
779 ELSE()
780     SET(IS_LINKED " (linked)")
781     MACRO(ADD_BACKEND_LIBS _LIBS)
782         SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
783     ENDMACRO()
784 ENDIF()
786 SET(BACKENDS "")
787 SET(ALC_OBJS  ${ALC_OBJS}
788               Alc/backends/base.c
789               # Default backends, always available
790               Alc/backends/loopback.c
791               Alc/backends/null.c
794 # Check ALSA backend
795 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
796 FIND_PACKAGE(ALSA)
797 IF(ALSA_FOUND)
798     OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
799     IF(ALSOFT_BACKEND_ALSA)
800         SET(HAVE_ALSA 1)
801         SET(BACKENDS  "${BACKENDS} ALSA${IS_LINKED},")
802         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/alsa.c)
803         ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
804         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
805             INCLUDE_DIRECTORIES(${ALSA_INCLUDE_DIRS})
806         ENDIF()
807     ENDIF()
808 ENDIF()
809 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
810     MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
811 ENDIF()
813 # Check OSS backend
814 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
815 FIND_PACKAGE(OSS)
816 IF(OSS_FOUND)
817     OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
818     IF(ALSOFT_BACKEND_OSS)
819         SET(HAVE_OSS 1)
820         SET(BACKENDS  "${BACKENDS} OSS,")
821         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/oss.c)
822         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
823             INCLUDE_DIRECTORIES(${OSS_INCLUDE_DIRS})
824         ENDIF()
825     ENDIF()
826 ENDIF()
827 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
828     MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
829 ENDIF()
831 # Check Solaris backend
832 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
833 FIND_PACKAGE(AudioIO)
834 IF(AUDIOIO_FOUND)
835     OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
836     IF(ALSOFT_BACKEND_SOLARIS)
837         SET(HAVE_SOLARIS 1)
838         SET(BACKENDS  "${BACKENDS} Solaris,")
839         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/solaris.c)
840         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
841             INCLUDE_DIRECTORIES(${AUDIOIO_INCLUDE_DIRS})
842         ENDIF()
843     ENDIF()
844 ENDIF()
845 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
846     MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
847 ENDIF()
849 # Check SndIO backend
850 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
851 FIND_PACKAGE(SoundIO)
852 IF(SOUNDIO_FOUND)
853     OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
854     IF(ALSOFT_BACKEND_SNDIO)
855         SET(HAVE_SNDIO 1)
856         SET(BACKENDS  "${BACKENDS} SndIO (linked),")
857         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/sndio.c)
858         SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
859         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
860             INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
861         ENDIF()
862     ENDIF()
863 ENDIF()
864 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
865     MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
866 ENDIF()
868 # Check QSA backend
869 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
870 FIND_PACKAGE(QSA)
871 IF(QSA_FOUND)
872     OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
873     IF(ALSOFT_BACKEND_QSA)
874         SET(HAVE_QSA 1)
875         SET(BACKENDS  "${BACKENDS} QSA (linked),")
876         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/qsa.c)
877         SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
878         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
879             INCLUDE_DIRECTORIES(${QSA_INCLUDE_DIRS})
880         ENDIF()
881     ENDIF()
882 ENDIF()
883 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
884     MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
885 ENDIF()
887 # Check Windows-only backends
888 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
889 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
890 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
891 IF(HAVE_WINDOWS_H)
892     # Check MMSystem backend
893     CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
894     IF(HAVE_MMSYSTEM_H)
895         CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
896         IF(HAVE_LIBWINMM)
897             OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
898             IF(ALSOFT_BACKEND_WINMM)
899                 SET(HAVE_WINMM 1)
900                 SET(BACKENDS  "${BACKENDS} WinMM,")
901                 SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/winmm.c)
902                 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
903             ENDIF()
904         ENDIF()
905     ENDIF()
907     # Check DSound backend
908     FIND_PACKAGE(DSound)
909     IF(DSOUND_FOUND)
910         OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
911         IF(ALSOFT_BACKEND_DSOUND)
912             SET(HAVE_DSOUND 1)
913             SET(BACKENDS  "${BACKENDS} DirectSound${IS_LINKED},")
914             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/dsound.c)
915             ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
916             IF(CMAKE_VERSION VERSION_LESS "2.8.8")
917                 INCLUDE_DIRECTORIES(${DSOUND_INCLUDE_DIRS})
918             ENDIF()
919         ENDIF()
920     ENDIF()
922     # Check for MMDevApi backend
923     CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
924     IF(HAVE_MMDEVICEAPI_H)
925         OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
926         IF(ALSOFT_BACKEND_MMDEVAPI)
927             SET(HAVE_MMDEVAPI 1)
928             SET(BACKENDS  "${BACKENDS} MMDevApi,")
929             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/mmdevapi.c)
930         ENDIF()
931     ENDIF()
932 ENDIF()
933 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
934     MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
935 ENDIF()
936 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
937     MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
938 ENDIF()
939 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
940     MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
941 ENDIF()
943 # Check PortAudio backend
944 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
945 FIND_PACKAGE(PortAudio)
946 IF(PORTAUDIO_FOUND)
947     OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
948     IF(ALSOFT_BACKEND_PORTAUDIO)
949         SET(HAVE_PORTAUDIO 1)
950         SET(BACKENDS  "${BACKENDS} PortAudio${IS_LINKED},")
951         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/portaudio.c)
952         ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
953         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
954             INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
955         ENDIF()
956     ENDIF()
957 ENDIF()
958 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
959     MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
960 ENDIF()
962 # Check PulseAudio backend
963 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
964 FIND_PACKAGE(PulseAudio)
965 IF(PULSEAUDIO_FOUND)
966     OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
967     IF(ALSOFT_BACKEND_PULSEAUDIO)
968         SET(HAVE_PULSEAUDIO 1)
969         SET(BACKENDS  "${BACKENDS} PulseAudio${IS_LINKED},")
970         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/pulseaudio.c)
971         ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
972         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
973             INCLUDE_DIRECTORIES(${PULSEAUDIO_INCLUDE_DIRS})
974         ENDIF()
975     ENDIF()
976 ENDIF()
977 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
978     MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
979 ENDIF()
981 # Check JACK backend
982 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
983 FIND_PACKAGE(JACK)
984 IF(JACK_FOUND)
985     OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
986     IF(ALSOFT_BACKEND_JACK)
987         SET(HAVE_JACK 1)
988         SET(BACKENDS  "${BACKENDS} JACK${IS_LINKED},")
989         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/jack.c)
990         ADD_BACKEND_LIBS(${JACK_LIBRARIES})
991         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
992             INCLUDE_DIRECTORIES(${JACK_INCLUDE_DIRS})
993         ENDIF()
994     ENDIF()
995 ENDIF()
996 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
997     MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
998 ENDIF()
1000 # Check CoreAudio backend
1001 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1002 FIND_LIBRARY(COREAUDIO_FRAMEWORK
1003              NAMES CoreAudio
1004              PATHS /System/Library/Frameworks
1006 IF(COREAUDIO_FRAMEWORK)
1007     OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1008     IF(ALSOFT_BACKEND_COREAUDIO)
1009         SET(HAVE_COREAUDIO 1)
1010         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/coreaudio.c)
1011         SET(BACKENDS  "${BACKENDS} CoreAudio,")
1012         SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1013         SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1014         SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1016         # Some versions of OSX may need the AudioToolbox framework. Add it if
1017         # it's found.
1018         FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1019                      NAMES AudioToolbox
1020                      PATHS ~/Library/Frameworks
1021                            /Library/Frameworks
1022                            /System/Library/Frameworks
1023                     )
1024         IF(AUDIOTOOLBOX_LIBRARY)
1025             SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1026         ENDIF()
1027     ENDIF()
1028 ENDIF()
1029 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1030     MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1031 ENDIF()
1033 # Check for OpenSL (Android) backend
1034 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1035 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
1036 IF(HAVE_SLES_OPENSLES_ANDROID_H)
1037     CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
1038     IF(HAVE_LIBOPENSLES)
1039         OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1040         IF(ALSOFT_BACKEND_OPENSL)
1041             SET(HAVE_OPENSL 1)
1042             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/opensl.c)
1043             SET(BACKENDS  "${BACKENDS} OpenSL,")
1044             SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
1045         ENDIF()
1046     ENDIF()
1047 ENDIF()
1048 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1049     MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1050 ENDIF()
1052 # Optionally enable the Wave Writer backend
1053 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1054 IF(ALSOFT_BACKEND_WAVE)
1055     SET(HAVE_WAVE 1)
1056     SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/wave.c)
1057     SET(BACKENDS  "${BACKENDS} WaveFile,")
1058 ENDIF()
1060 # This is always available
1061 SET(BACKENDS  "${BACKENDS} Null")
1063 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1064     add_subdirectory(utils/alsoft-config)
1065 ENDIF()
1066 IF(ALSOFT_EXAMPLES)
1067     FIND_PACKAGE(SDL2)
1068     IF(SDL2_FOUND)
1069         FIND_PACKAGE(SDL_sound)
1070         IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1071             INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1072         ENDIF()
1073         FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1074         IF(FFMPEG_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1075             INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
1076         ENDIF()
1077     ENDIF()
1078 ENDIF()
1080 IF(LIBTYPE STREQUAL "STATIC")
1081     ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
1082     SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
1083 ENDIF()
1085 # Needed for openal.pc.in
1086 SET(prefix ${CMAKE_INSTALL_PREFIX})
1087 SET(exec_prefix "\${prefix}")
1088 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
1089 SET(bindir "\${exec_prefix}/bin")
1090 SET(includedir "\${prefix}/include")
1091 SET(PACKAGE_VERSION "${LIB_VERSION}")
1093 # End configuration
1094 CONFIGURE_FILE(
1095     "${OpenAL_SOURCE_DIR}/config.h.in"
1096     "${OpenAL_BINARY_DIR}/config.h")
1097 CONFIGURE_FILE(
1098     "${OpenAL_SOURCE_DIR}/openal.pc.in"
1099     "${OpenAL_BINARY_DIR}/openal.pc"
1100     @ONLY)
1102 # Build a common library with reusable helpers
1103 ADD_LIBRARY(common STATIC ${COMMON_OBJS})
1104 IF(NOT LIBTYPE STREQUAL "STATIC")
1105     SET_PROPERTY(TARGET common PROPERTY POSITION_INDEPENDENT_CODE TRUE)
1106 ENDIF()
1108 # Build main library
1109 IF(LIBTYPE STREQUAL "STATIC")
1110     ADD_LIBRARY(${LIBNAME} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1111 ELSE()
1112     ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
1113 ENDIF()
1114 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
1115 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1116     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
1117 ENDIF()
1118 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
1119 IF(HAVE_ALSA)
1120     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
1121 ENDIF()
1122 IF(HAVE_OSS)
1123     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
1124 ENDIF()
1125 IF(HAVE_SOLARIS)
1126     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
1127 ENDIF()
1128 IF(HAVE_SNDIO)
1129     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
1130 ENDIF()
1131 IF(HAVE_QSA)
1132     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
1133 ENDIF()
1134 IF(HAVE_DSOUND)
1135     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
1136 ENDIF()
1137 IF(HAVE_PORTAUDIO)
1138     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
1139 ENDIF()
1140 IF(HAVE_PULSEAUDIO)
1141     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
1142 ENDIF()
1143 IF(HAVE_JACK)
1144     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
1145 ENDIF()
1146 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
1147                                             SOVERSION ${LIB_MAJOR_VERSION})
1148 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
1149     SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
1151     IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
1152         FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1153         FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1154         IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1155             MESSAGE(STATUS "")
1156             IF(NOT SED_EXECUTABLE)
1157                 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1158             ENDIF()
1159             IF(NOT DLLTOOL_EXECUTABLE)
1160                 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1161             ENDIF()
1162         ELSE()
1163             SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--output-def,${LIBNAME}.def")
1164             ADD_CUSTOM_COMMAND(TARGET ${LIBNAME} POST_BUILD
1165                 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" ${LIBNAME}.def
1166                 COMMAND "${DLLTOOL_EXECUTABLE}" -d ${LIBNAME}.def -l ${LIBNAME}.lib -D ${LIBNAME}.dll
1167                 COMMENT "Stripping ordinals from ${LIBNAME}.def and generating ${LIBNAME}.lib..."
1168                 VERBATIM
1169             )
1170         ENDIF()
1171     ENDIF()
1172 ENDIF()
1174 TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
1176 IF(ALSOFT_INSTALL)
1177     # Add an install target here
1178     INSTALL(TARGETS ${LIBNAME}
1179             RUNTIME DESTINATION bin
1180             LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1181             ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1182     )
1183     INSTALL(FILES include/AL/al.h
1184                   include/AL/alc.h
1185                   include/AL/alext.h
1186                   include/AL/efx.h
1187                   include/AL/efx-creative.h
1188                   include/AL/efx-presets.h
1189             DESTINATION include/AL
1190     )
1191     INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1192             DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
1193 ENDIF()
1196 MESSAGE(STATUS "")
1197 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1198 MESSAGE(STATUS "    ${BACKENDS}")
1199 MESSAGE(STATUS "")
1200 MESSAGE(STATUS "Building with support for CPU extensions:")
1201 MESSAGE(STATUS "    ${CPU_EXTS}")
1202 MESSAGE(STATUS "")
1204 IF(WIN32)
1205     IF(NOT HAVE_DSOUND)
1206         MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1207         MESSAGE(STATUS "         This is probably NOT what you want!")
1208         MESSAGE(STATUS "")
1209     ENDIF()
1210 ENDIF()
1212 # Install alsoft.conf configuration file
1213 IF(ALSOFT_CONFIG)
1214     INSTALL(FILES alsoftrc.sample
1215             DESTINATION ${SHARE_INSTALL_DIR}/openal
1216     )
1217     MESSAGE(STATUS "Installing sample configuration")
1218     MESSAGE(STATUS "")
1219 ENDIF()
1221 # Install HRTF definitions
1222 IF(ALSOFT_HRTF_DEFS)
1223     INSTALL(FILES hrtf/default-44100.mhr
1224                   hrtf/default-48000.mhr
1225             DESTINATION ${SHARE_INSTALL_DIR}/openal/hrtf
1226     )
1227     MESSAGE(STATUS "Installing HRTF definitions")
1228     MESSAGE(STATUS "")
1229 ENDIF()
1231 # Install AmbDec presets
1232 IF(ALSOFT_AMBDEC_PRESETS)
1233     INSTALL(FILES presets/3D7.1.ambdec
1234                   presets/hexagon.ambdec
1235                   presets/itu5.1.ambdec
1236                   presets/rectangle.ambdec
1237                   presets/square.ambdec
1238                   presets/presets.txt
1239             DESTINATION ${SHARE_INSTALL_DIR}/openal/presets
1240     )
1241     MESSAGE(STATUS "Installing HRTF definitions")
1242     MESSAGE(STATUS "")
1243 ENDIF()
1245 IF(ALSOFT_UTILS)
1246     ADD_EXECUTABLE(openal-info utils/openal-info.c)
1247     TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
1249     ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1250     IF(HAVE_LIBM)
1251         TARGET_LINK_LIBRARIES(makehrtf m)
1252     ENDIF()
1254     ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
1255     IF(HAVE_LIBM)
1256         TARGET_LINK_LIBRARIES(bsincgen m)
1257     ENDIF()
1259     IF(ALSOFT_INSTALL)
1260         INSTALL(TARGETS openal-info makehrtf bsincgen
1261                 RUNTIME DESTINATION bin
1262                 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1263                 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1264         )
1265     ENDIF()
1267     MESSAGE(STATUS "Building utility programs")
1268     IF(TARGET alsoft-config)
1269         MESSAGE(STATUS "Building configuration program")
1270     ENDIF()
1271     MESSAGE(STATUS "")
1272 ENDIF()
1274 IF(ALSOFT_TESTS)
1275         ADD_LIBRARY(test-common STATIC examples/common/alhelpers.c)
1277         ADD_EXECUTABLE(altonegen examples/altonegen.c)
1278         TARGET_LINK_LIBRARIES(altonegen test-common ${LIBNAME})
1280         IF(ALSOFT_INSTALL)
1281             INSTALL(TARGETS altonegen
1282                     RUNTIME DESTINATION bin
1283                     LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1284                     ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1285             )
1286         ENDIF()
1288         MESSAGE(STATUS "Building test programs")
1289         MESSAGE(STATUS "")
1290 ENDIF()
1292 IF(ALSOFT_EXAMPLES)
1293     IF(SDL2_FOUND AND SDL_SOUND_FOUND)
1294         ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1295                                      examples/common/sdl_sound.c)
1296         SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1297                                                                           ${SDL_SOUND_INCLUDE_DIR})
1299         ADD_EXECUTABLE(alstream examples/alstream.c)
1300         TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1301                                        common ${LIBNAME})
1302         SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1303                                                                          ${SDL_SOUND_INCLUDE_DIR})
1305         ADD_EXECUTABLE(alreverb examples/alreverb.c)
1306         TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1307                                        common ${LIBNAME})
1308         SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1309                                                                          ${SDL_SOUND_INCLUDE_DIR})
1311         ADD_EXECUTABLE(allatency examples/allatency.c)
1312         TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1313                                         common ${LIBNAME})
1314         SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1315                                                                           ${SDL_SOUND_INCLUDE_DIR})
1317         ADD_EXECUTABLE(alloopback examples/alloopback.c)
1318         TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1319                                          common ${LIBNAME})
1320         SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1321                                                                            ${SDL_SOUND_INCLUDE_DIR})
1323         ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1324         TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1325                                      common ${LIBNAME})
1326         SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1327                                                                        ${SDL_SOUND_INCLUDE_DIR})
1329         IF(ALSOFT_INSTALL)
1330             INSTALL(TARGETS alstream alreverb allatency alloopback alhrtf
1331                     RUNTIME DESTINATION bin
1332                     LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1333                     ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1334             )
1335         ENDIF()
1337         SET(FFVER_OK FALSE)
1338         IF(FFMPEG_FOUND)
1339             SET(FFVER_OK TRUE)
1340             IF(AVFORMAT_VERSION VERSION_LESS "55.33.100")
1341                 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 55.33.100)")
1342                 SET(FFVER_OK FALSE)
1343             ENDIF()
1344             IF(AVCODEC_VERSION VERSION_LESS "55.52.102")
1345                 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 55.52.102)")
1346                 SET(FFVER_OK FALSE)
1347             ENDIF()
1348             IF(AVUTIL_VERSION VERSION_LESS "52.66.100")
1349                 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 52.66.100)")
1350                 SET(FFVER_OK FALSE)
1351             ENDIF()
1352             IF(SWSCALE_VERSION VERSION_LESS "2.5.102")
1353                 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 2.5.102)")
1354                 SET(FFVER_OK FALSE)
1355             ENDIF()
1356             IF(SWRESAMPLE_VERSION VERSION_LESS "0.18.100")
1357                 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 0.18.100)")
1358                 SET(FFVER_OK FALSE)
1359             ENDIF()
1360         ENDIF()
1361         IF(FFVER_OK AND NOT MSVC)
1362             ADD_EXECUTABLE(alffplay examples/alffplay.c)
1363             TARGET_LINK_LIBRARIES(alffplay common ex-common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
1364             SET_PROPERTY(TARGET alffplay APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1365                                                                              ${FFMPEG_INCLUDE_DIRS})
1367             IF(ALSOFT_INSTALL)
1368                 INSTALL(TARGETS alffplay
1369                         RUNTIME DESTINATION bin
1370                         LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1371                         ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1372                 )
1373             ENDIF()
1374             MESSAGE(STATUS "Building SDL and FFmpeg example programs")
1375         ELSE()
1376             MESSAGE(STATUS "Building SDL example programs")
1377         ENDIF()
1378         MESSAGE(STATUS "")
1379     ENDIF()
1380 ENDIF()