1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
7 IF(COMMAND CMAKE_POLICY)
8 CMAKE_POLICY(SET CMP0003 NEW)
9 CMAKE_POLICY(SET CMP0005 NEW)
11 CMAKE_POLICY(SET CMP0042 NEW)
13 ENDIF(COMMAND CMAKE_POLICY)
15 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
17 INCLUDE(CheckFunctionExists)
18 INCLUDE(CheckLibraryExists)
19 INCLUDE(CheckSharedFunctionExists)
20 INCLUDE(CheckIncludeFile)
21 INCLUDE(CheckIncludeFiles)
22 INCLUDE(CheckSymbolExists)
23 INCLUDE(CheckCCompilerFlag)
24 INCLUDE(CheckCSourceCompiles)
25 INCLUDE(CheckTypeSize)
26 include(CheckStructHasMember)
27 include(CheckFileOffsetBits)
28 include(GNUInstallDirs)
31 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
34 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
36 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
38 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
39 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
41 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
42 OPTION(ALSOFT_TESTS "Build and install test programs" ON)
44 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
45 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
46 OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
47 OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
49 if(DEFINED SHARE_INSTALL_DIR)
50 message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
51 set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
54 if(DEFINED LIB_SUFFIX)
55 message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
63 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
65 # This option is mainly for static linking OpenAL Soft into another project
66 # that already defines the IDs. It is up to that project to ensure all
67 # required IDs are defined.
68 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
71 OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
74 SET(DLLTOOL "${HOST}-dlltool")
76 SET(DLLTOOL "dlltool")
83 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
84 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
85 ADD_DEFINITIONS("-I/usr/include")
86 SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
93 SET(LIB_MAJOR_VERSION "1")
94 SET(LIB_MINOR_VERSION "17")
96 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
102 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
103 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
106 CHECK_C_COMPILER_FLAG(-std=c11 HAVE_STD_C11)
108 SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
110 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
112 SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
117 # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
118 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
119 IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
120 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
121 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500")
122 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
123 IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
124 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
126 ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500)
129 UNSET(OLD_REQUIRED_FLAGS)
132 # Set defines for large file support
133 CHECK_FILE_OFFSET_BITS()
134 IF(_FILE_OFFSET_BITS)
135 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
136 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
138 ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES)
139 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
141 # MSVC may need workarounds for C99 restrict and inline
143 # TODO: Once we truly require C99, these restrict and inline checks should go
145 CHECK_C_SOURCE_COMPILES("int *restrict foo;
146 int main() {return 0;}" HAVE_RESTRICT)
147 IF(NOT HAVE_RESTRICT)
148 ADD_DEFINITIONS("-Drestrict=")
149 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
152 CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
153 int main() {return 0;}" HAVE_INLINE)
155 CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
156 int main() {return 0;}" HAVE___INLINE)
157 IF(NOT HAVE___INLINE)
158 MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
161 ADD_DEFINITIONS(-Dinline=__inline)
162 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
166 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
167 IF(CMAKE_COMPILER_IS_GNUCC)
168 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
169 # Force no inlining for the next test.
170 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
172 CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
173 int main() {return foo();}" INLINE_IS_C99)
174 IF(NOT INLINE_IS_C99)
175 MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
176 Please update your compiler for better C99 compliance.")
179 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
182 # Check if we have a proper timespec declaration
183 CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC)
184 IF(HAVE_STRUCT_TIMESPEC)
185 # Define it here so we don't have to include config.h for it
186 ADD_DEFINITIONS("-DHAVE_STRUCT_TIMESPEC")
189 # Some systems may need libatomic for C11 atomic functions to work
190 SET(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
191 SET(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
192 CHECK_C_SOURCE_COMPILES("#include <stdatomic.h>
193 int _Atomic foo = ATOMIC_VAR_INIT(0);
196 return atomic_fetch_add(&foo, 2);
199 IF(NOT HAVE_LIBATOMIC)
200 SET(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
202 SET(EXTRA_LIBS atomic ${EXTRA_LIBS})
204 UNSET(OLD_REQUIRED_LIBRARIES)
206 # Check if we have C99 variable length arrays
207 CHECK_C_SOURCE_COMPILES(
208 "int main(int argc, char *argv[])
210 volatile int tmp[argc];
216 # Check if we have C99 bool
217 CHECK_C_SOURCE_COMPILES(
218 "int main(int argc, char *argv[])
221 ret = (argc > 1) ? 1 : 0;
226 # Check if we have C11 static_assert
227 CHECK_C_SOURCE_COMPILES(
230 _Static_assert(sizeof(int) == sizeof(int), \"What\");
233 HAVE_C11_STATIC_ASSERT)
235 # Check if we have C11 alignas
236 CHECK_C_SOURCE_COMPILES(
237 "_Alignas(16) int foo;
244 # Check if we have C11 _Atomic
245 CHECK_C_SOURCE_COMPILES(
246 "#include <stdatomic.h>
247 const int _Atomic foo = ATOMIC_VAR_INIT(~0);
248 int _Atomic bar = ATOMIC_VAR_INIT(0);
251 atomic_fetch_add(&bar, 2);
252 return atomic_load(&foo);
256 # Add definitions, compiler switches, etc.
257 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
258 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
259 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
260 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
261 ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
265 IF(NOT CMAKE_BUILD_TYPE)
266 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
267 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
270 IF(NOT CMAKE_DEBUG_POSTFIX)
271 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
272 "Library postfix for debug builds. Normally left blank."
278 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
279 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
280 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} /wd4098")
283 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
285 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
288 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
291 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
292 IF(FORCE_STATIC_VCRT)
294 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
295 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
296 IF(${flag_var} MATCHES "/MD")
297 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
302 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Winline -Wall")
303 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
305 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wextra")
309 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
312 # Force enable -fPIC for CMake versions before 2.8.9 (later versions have
313 # the POSITION_INDEPENDENT_CODE target property). The static common library
314 # will be linked into the dynamic openal library, which requires all its
315 # code to be position-independent.
316 IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
317 CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
319 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC")
323 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
325 FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
326 IF(${flag_var} MATCHES "-DNDEBUG")
327 STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
331 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
332 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
334 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
335 if(ALSOFT_STATIC_LIBGCC)
336 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
337 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
338 check_c_source_compiles(
344 HAVE_STATIC_LIBGCC_SWITCH
346 if(HAVE_STATIC_LIBGCC_SWITCH)
347 set(EXTRA_LIBS ${EXTRA_LIBS} -static-libgcc)
349 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
350 unset(OLD_REQUIRED_LIBRARIES)
354 # Set visibility/export options if available
357 SET(EXPORT_DECL "__declspec(dllexport)")
359 SET(ALIGN_DECL "__declspec(align(x))")
361 SET(ALIGN_DECL "__declspec(aligned(x))")
364 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
365 # Yes GCC, really don't accept visibility modes you don't support
366 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
368 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
369 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
370 IF(HAVE_GCC_PROTECTED_VISIBILITY)
371 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
373 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
374 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
375 IF(HAVE_GCC_DEFAULT_VISIBILITY)
376 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
380 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
381 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
382 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
383 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
384 SET(HIDDEN_DECL "__attribute__((visibility(\"hidden\")))")
388 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
389 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
390 IF(HAVE_ATTRIBUTE_ALIGNED)
391 SET(ALIGN_DECL "__attribute__((aligned(x)))")
394 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
400 SET(SSE4_1_SWITCH "")
401 SET(FPU_NEON_SWITCH "")
403 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
405 SET(SSE_SWITCH "-msse")
407 CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
408 IF(HAVE_MSSE2_SWITCH)
409 SET(SSE2_SWITCH "-msse2")
411 CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
412 IF(HAVE_MSSE3_SWITCH)
413 SET(SSE3_SWITCH "-msse3")
415 CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
416 IF(HAVE_MSSE4_1_SWITCH)
417 SET(SSE4_1_SWITCH "-msse4.1")
419 CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_MFPU_NEON_SWITCH)
420 IF(HAVE_MFPU_NEON_SWITCH)
421 SET(FPU_NEON_SWITCH "-mfpu=neon")
425 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
426 int main() {return 0;}" HAVE_GCC_FORMAT)
428 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
429 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
430 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
431 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
432 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
433 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
434 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
435 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
436 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
437 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
438 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
439 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
440 IF(NOT HAVE_GUIDDEF_H)
441 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
444 # Some systems need libm for some of the following math functions to work
445 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
447 SET(EXTRA_LIBS m ${EXTRA_LIBS})
448 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
451 # Check for the dlopen API (for dynamicly loading backend libs)
453 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
455 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
456 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
459 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
462 # Check for a cpuid intrinsic
464 CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
467 unsigned int eax, ebx, ecx, edx;
468 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
469 }" HAVE_GCC_GET_CPUID)
472 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
478 }" HAVE_CPUID_INTRINSIC)
481 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
482 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
483 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
484 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
485 CHECK_SYMBOL_EXISTS(modff math.h HAVE_MODFF)
487 CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
489 MESSAGE(FATAL_ERROR "No alloca function found, please report!")
494 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
495 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
498 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
499 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
500 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
501 IF(NOT HAVE_STRCASECMP)
502 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
503 IF(NOT HAVE__STRICMP)
504 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
507 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
510 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
511 IF(NOT HAVE_STRNCASECMP)
512 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
513 IF(NOT HAVE__STRNICMP)
514 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
517 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
520 CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
521 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
522 IF(NOT HAVE_SNPRINTF)
523 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
524 IF(NOT HAVE__SNPRINTF)
525 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
528 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
531 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
532 IF(NOT HAVE_ISFINITE)
533 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
535 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
537 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
539 ADD_DEFINITIONS(-Disfinite=_finite)
541 ADD_DEFINITIONS(-Disfinite=finite)
545 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
547 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
549 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
552 ADD_DEFINITIONS(-Disnan=_isnan)
556 # Check if we have Windows headers
557 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
558 IF(NOT HAVE_WINDOWS_H)
559 CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
560 IF(NOT HAVE_GETTIMEOFDAY)
561 MESSAGE(FATAL_ERROR "No timing function found!")
564 CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
565 IF(NOT HAVE_NANOSLEEP)
566 MESSAGE(FATAL_ERROR "No sleep function found!")
569 # We need pthreads outside of Windows
570 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
571 IF(NOT HAVE_PTHREAD_H)
572 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
574 # Some systems need pthread_np.h to get recursive mutexes
575 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
577 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
579 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread")
580 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
581 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
584 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
586 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
589 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
591 IF(HAVE_PTHREAD_NP_H)
592 CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
593 IF(NOT HAVE_PTHREAD_SETNAME_NP)
594 CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
596 CHECK_C_SOURCE_COMPILES("
598 #include <pthread_np.h>
601 pthread_setname_np(\"testname\");
604 PTHREAD_SETNAME_NP_ONE_PARAM
607 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
609 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
610 IF(NOT HAVE_PTHREAD_SETNAME_NP)
611 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
613 CHECK_C_SOURCE_COMPILES("
617 pthread_setname_np(\"testname\");
620 PTHREAD_SETNAME_NP_ONE_PARAM
623 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
626 CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
628 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
630 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
634 # Check for a 64-bit type
635 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
636 IF(NOT HAVE_STDINT_H)
638 CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
641 int main() {return 0;}" HAVE___INT64)
644 IF(NOT SIZEOF_LONG MATCHES "8")
645 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
646 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
653 SET(COMMON_OBJS common/almalloc.c
659 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
663 OpenAL32/alExtension.c
665 OpenAL32/alListener.c
669 OpenAL32/sample_cvt.c
671 SET(ALC_OBJS Alc/ALc.c
677 Alc/effects/compressor.c
678 Alc/effects/dedicated.c
679 Alc/effects/distortion.c
681 Alc/effects/equalizer.c
682 Alc/effects/flanger.c
683 Alc/effects/modulator.c
698 SET(CPU_EXTS "Default")
713 SET(HAVE_PORTAUDIO 0)
714 SET(HAVE_PULSEAUDIO 0)
715 SET(HAVE_COREAUDIO 0)
719 # Check for SSE support
720 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
721 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
723 OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
724 IF(ALSOFT_CPUEXT_SSE)
725 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
727 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
729 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
730 COMPILE_FLAGS "${SSE_SWITCH}")
732 SET(CPU_EXTS "${CPU_EXTS}, SSE")
736 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
737 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
740 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
741 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
743 OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
744 IF(HAVE_SSE AND ALSOFT_CPUEXT_SSE2)
745 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
747 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse2.c)
749 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse2.c PROPERTIES
750 COMPILE_FLAGS "${SSE2_SWITCH}")
752 SET(CPU_EXTS "${CPU_EXTS}, SSE2")
756 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
757 MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
760 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE3 support" OFF)
761 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
763 OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
764 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
765 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
767 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse3.c)
769 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse3.c PROPERTIES
770 COMPILE_FLAGS "${SSE3_SWITCH}")
772 SET(CPU_EXTS "${CPU_EXTS}, SSE3")
776 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
777 MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
780 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
781 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
783 OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
784 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE4_1)
785 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
787 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse41.c)
789 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse41.c PROPERTIES
790 COMPILE_FLAGS "${SSE4_1_SWITCH}")
792 SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
796 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
797 MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
800 # Check for ARM Neon support
801 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
802 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
804 OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
805 IF(ALSOFT_CPUEXT_NEON)
807 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
809 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_neon.c PROPERTIES
810 COMPILE_FLAGS "${FPU_NEON_SWITCH}")
812 SET(CPU_EXTS "${CPU_EXTS}, Neon")
815 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
816 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
820 IF(WIN32 OR HAVE_DLFCN_H)
822 MACRO(ADD_BACKEND_LIBS _LIBS)
825 SET(IS_LINKED " (linked)")
826 MACRO(ADD_BACKEND_LIBS _LIBS)
827 SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
832 SET(ALC_OBJS ${ALC_OBJS}
834 # Default backends, always available
835 Alc/backends/loopback.c
840 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
843 OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
844 IF(ALSOFT_BACKEND_ALSA)
846 SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
847 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
848 ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
849 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
850 INCLUDE_DIRECTORIES(${ALSA_INCLUDE_DIRS})
854 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
855 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
859 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
862 OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
863 IF(ALSOFT_BACKEND_OSS)
865 SET(BACKENDS "${BACKENDS} OSS,")
866 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
867 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
868 INCLUDE_DIRECTORIES(${OSS_INCLUDE_DIRS})
872 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
873 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
876 # Check Solaris backend
877 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
878 FIND_PACKAGE(AudioIO)
880 OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
881 IF(ALSOFT_BACKEND_SOLARIS)
883 SET(BACKENDS "${BACKENDS} Solaris,")
884 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
885 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
886 INCLUDE_DIRECTORIES(${AUDIOIO_INCLUDE_DIRS})
890 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
891 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
894 # Check SndIO backend
895 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
896 FIND_PACKAGE(SoundIO)
898 OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
899 IF(ALSOFT_BACKEND_SNDIO)
901 SET(BACKENDS "${BACKENDS} SndIO (linked),")
902 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
903 SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
904 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
905 INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
909 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
910 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
914 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
917 OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
918 IF(ALSOFT_BACKEND_QSA)
920 SET(BACKENDS "${BACKENDS} QSA (linked),")
921 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
922 SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
923 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
924 INCLUDE_DIRECTORIES(${QSA_INCLUDE_DIRS})
928 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
929 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
932 # Check Windows-only backends
933 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
934 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
935 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
937 # Check MMSystem backend
938 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
940 CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
942 OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
943 IF(ALSOFT_BACKEND_WINMM)
945 SET(BACKENDS "${BACKENDS} WinMM,")
946 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
947 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
952 # Check DSound backend
955 OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
956 IF(ALSOFT_BACKEND_DSOUND)
958 SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
959 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
960 ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
961 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
962 INCLUDE_DIRECTORIES(${DSOUND_INCLUDE_DIRS})
967 # Check for MMDevApi backend
968 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
969 IF(HAVE_MMDEVICEAPI_H)
970 OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
971 IF(ALSOFT_BACKEND_MMDEVAPI)
973 SET(BACKENDS "${BACKENDS} MMDevApi,")
974 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
978 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
979 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
981 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
982 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
984 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
985 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
988 # Check PortAudio backend
989 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
990 FIND_PACKAGE(PortAudio)
992 OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
993 IF(ALSOFT_BACKEND_PORTAUDIO)
994 SET(HAVE_PORTAUDIO 1)
995 SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
996 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
997 ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
998 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
999 INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
1003 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
1004 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
1007 # Check PulseAudio backend
1008 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
1009 FIND_PACKAGE(PulseAudio)
1010 IF(PULSEAUDIO_FOUND)
1011 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
1012 IF(ALSOFT_BACKEND_PULSEAUDIO)
1013 SET(HAVE_PULSEAUDIO 1)
1014 SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
1015 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
1016 ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
1017 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
1018 INCLUDE_DIRECTORIES(${PULSEAUDIO_INCLUDE_DIRS})
1022 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
1023 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
1026 # Check JACK backend
1027 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
1030 OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
1031 IF(ALSOFT_BACKEND_JACK)
1033 SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
1034 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/jack.c)
1035 ADD_BACKEND_LIBS(${JACK_LIBRARIES})
1036 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
1037 INCLUDE_DIRECTORIES(${JACK_INCLUDE_DIRS})
1041 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1042 MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
1045 # Check CoreAudio backend
1046 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1047 FIND_LIBRARY(COREAUDIO_FRAMEWORK
1049 PATHS /System/Library/Frameworks
1051 IF(COREAUDIO_FRAMEWORK)
1052 OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1053 IF(ALSOFT_BACKEND_COREAUDIO)
1054 SET(HAVE_COREAUDIO 1)
1055 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
1056 SET(BACKENDS "${BACKENDS} CoreAudio,")
1057 SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1058 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1059 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1061 # Some versions of OSX may need the AudioToolbox framework. Add it if
1063 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1065 PATHS ~/Library/Frameworks
1067 /System/Library/Frameworks
1069 IF(AUDIOTOOLBOX_LIBRARY)
1070 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1074 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1075 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1078 # Check for OpenSL (Android) backend
1079 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1080 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
1081 IF(HAVE_SLES_OPENSLES_ANDROID_H)
1082 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
1083 IF(HAVE_LIBOPENSLES)
1084 OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1085 IF(ALSOFT_BACKEND_OPENSL)
1087 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
1088 SET(BACKENDS "${BACKENDS} OpenSL,")
1089 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
1093 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1094 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1097 # Optionally enable the Wave Writer backend
1098 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1099 IF(ALSOFT_BACKEND_WAVE)
1101 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
1102 SET(BACKENDS "${BACKENDS} WaveFile,")
1105 # This is always available
1106 SET(BACKENDS "${BACKENDS} Null")
1108 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" OFF)
1109 if(ALSOFT_EMBED_HRTF_DATA)
1111 set(ALC_OBJS ${ALC_OBJS} Alc/hrtf_res.rc)
1113 set(FILENAMES default-44100.mhr default-48000.mhr)
1114 foreach(FILENAME ${FILENAMES})
1115 set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
1116 add_custom_command(OUTPUT ${outfile}
1117 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
1118 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
1119 COMMAND "${CMAKE_LINKER}" -r -b binary -o "${outfile}" ${FILENAME}
1120 COMMAND "${CMAKE_OBJCOPY}" --rename-section .data=.rodata,alloc,load,readonly,data,contents "${outfile}" "${outfile}"
1121 COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
1124 set(ALC_OBJS ${ALC_OBJS} ${outfile})
1132 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1133 add_subdirectory(utils/alsoft-config)
1138 FIND_PACKAGE(SDL_sound)
1139 IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1140 INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1142 FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1143 IF(FFMPEG_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1144 INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
1149 IF(LIBTYPE STREQUAL "STATIC")
1150 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
1151 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
1154 # Needed for openal.pc.in
1155 SET(prefix ${CMAKE_INSTALL_PREFIX})
1156 SET(exec_prefix "\${prefix}")
1157 SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
1158 SET(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}")
1159 SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
1160 SET(PACKAGE_VERSION "${LIB_VERSION}")
1164 "${OpenAL_SOURCE_DIR}/config.h.in"
1165 "${OpenAL_BINARY_DIR}/config.h")
1167 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1168 "${OpenAL_BINARY_DIR}/openal.pc"
1171 # Build a common library with reusable helpers
1172 ADD_LIBRARY(common STATIC ${COMMON_OBJS})
1173 SET_PROPERTY(TARGET common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1174 IF(NOT LIBTYPE STREQUAL "STATIC")
1175 SET_PROPERTY(TARGET common PROPERTY POSITION_INDEPENDENT_CODE TRUE)
1178 # Build main library
1179 IF(LIBTYPE STREQUAL "STATIC")
1180 ADD_LIBRARY(${LIBNAME} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1182 ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
1184 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1185 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
1186 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1187 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
1189 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
1191 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
1194 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
1197 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
1200 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
1203 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
1206 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
1209 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
1212 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
1215 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
1217 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
1218 SOVERSION ${LIB_MAJOR_VERSION})
1219 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
1220 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
1222 IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
1223 FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1224 FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1225 IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1227 IF(NOT SED_EXECUTABLE)
1228 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1230 IF(NOT DLLTOOL_EXECUTABLE)
1231 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1234 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--output-def,${LIBNAME}.def")
1235 ADD_CUSTOM_COMMAND(TARGET ${LIBNAME} POST_BUILD
1236 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" ${LIBNAME}.def
1237 COMMAND "${DLLTOOL_EXECUTABLE}" -d ${LIBNAME}.def -l ${LIBNAME}.lib -D ${LIBNAME}.dll
1238 COMMENT "Stripping ordinals from ${LIBNAME}.def and generating ${LIBNAME}.lib..."
1245 TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
1248 # Add an install target here
1249 INSTALL(TARGETS ${LIBNAME}
1250 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1251 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1252 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1254 INSTALL(FILES include/AL/al.h
1258 include/AL/efx-creative.h
1259 include/AL/efx-presets.h
1260 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/AL
1262 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1263 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
1268 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1269 MESSAGE(STATUS " ${BACKENDS}")
1271 MESSAGE(STATUS "Building with support for CPU extensions:")
1272 MESSAGE(STATUS " ${CPU_EXTS}")
1277 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1278 MESSAGE(STATUS " This is probably NOT what you want!")
1283 if(ALSOFT_EMBED_HRTF_DATA)
1284 message(STATUS "Embedding HRTF datasets")
1288 # Install alsoft.conf configuration file
1290 INSTALL(FILES alsoftrc.sample
1291 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal
1293 MESSAGE(STATUS "Installing sample configuration")
1297 # Install HRTF definitions
1298 IF(ALSOFT_HRTF_DEFS)
1299 INSTALL(FILES hrtf/default-44100.mhr
1300 hrtf/default-48000.mhr
1301 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/hrtf
1303 MESSAGE(STATUS "Installing HRTF definitions")
1307 # Install AmbDec presets
1308 IF(ALSOFT_AMBDEC_PRESETS)
1309 INSTALL(FILES presets/3D7.1.ambdec
1310 presets/hexagon.ambdec
1311 presets/itu5.1.ambdec
1312 presets/rectangle.ambdec
1313 presets/square.ambdec
1315 DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/presets
1317 MESSAGE(STATUS "Installing AmbDec presets")
1322 ADD_EXECUTABLE(openal-info utils/openal-info.c)
1323 SET_PROPERTY(TARGET openal-info APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1324 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
1326 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1327 SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1329 TARGET_LINK_LIBRARIES(makehrtf m)
1332 ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
1333 SET_PROPERTY(TARGET bsincgen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1335 TARGET_LINK_LIBRARIES(bsincgen m)
1339 INSTALL(TARGETS openal-info makehrtf bsincgen
1340 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1341 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1342 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1346 MESSAGE(STATUS "Building utility programs")
1347 IF(TARGET alsoft-config)
1348 MESSAGE(STATUS "Building configuration program")
1354 ADD_LIBRARY(test-common STATIC examples/common/alhelpers.c)
1355 SET_PROPERTY(TARGET test-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1357 ADD_EXECUTABLE(altonegen examples/altonegen.c)
1358 TARGET_LINK_LIBRARIES(altonegen test-common ${LIBNAME})
1359 SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1362 INSTALL(TARGETS altonegen
1363 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1364 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1365 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1369 MESSAGE(STATUS "Building test programs")
1374 IF(SDL2_FOUND AND SDL_SOUND_FOUND)
1375 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1376 examples/common/sdl_sound.c)
1377 SET_PROPERTY(TARGET ex-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1378 SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1379 ${SDL_SOUND_INCLUDE_DIR})
1381 ADD_EXECUTABLE(alstream examples/alstream.c)
1382 TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1384 SET_PROPERTY(TARGET alstream APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1385 SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1386 ${SDL_SOUND_INCLUDE_DIR})
1388 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1389 TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1391 SET_PROPERTY(TARGET alreverb APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1392 SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1393 ${SDL_SOUND_INCLUDE_DIR})
1395 ADD_EXECUTABLE(allatency examples/allatency.c)
1396 TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1398 SET_PROPERTY(TARGET allatency APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1399 SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1400 ${SDL_SOUND_INCLUDE_DIR})
1402 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1403 TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1405 SET_PROPERTY(TARGET alloopback APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1406 SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1407 ${SDL_SOUND_INCLUDE_DIR})
1409 ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1410 TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1412 SET_PROPERTY(TARGET alhrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1413 SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1414 ${SDL_SOUND_INCLUDE_DIR})
1417 INSTALL(TARGETS alstream alreverb allatency alloopback alhrtf
1418 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1419 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1420 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1427 IF(AVFORMAT_VERSION VERSION_LESS "55.33.100")
1428 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 55.33.100)")
1431 IF(AVCODEC_VERSION VERSION_LESS "55.52.102")
1432 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 55.52.102)")
1435 IF(AVUTIL_VERSION VERSION_LESS "52.66.100")
1436 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 52.66.100)")
1439 IF(SWSCALE_VERSION VERSION_LESS "2.5.102")
1440 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 2.5.102)")
1443 IF(SWRESAMPLE_VERSION VERSION_LESS "0.18.100")
1444 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 0.18.100)")
1448 IF(FFVER_OK AND NOT MSVC)
1449 ADD_EXECUTABLE(alffplay examples/alffplay.c)
1450 TARGET_LINK_LIBRARIES(alffplay common ex-common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
1451 SET_PROPERTY(TARGET alffplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1452 SET_PROPERTY(TARGET alffplay APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1453 ${FFMPEG_INCLUDE_DIRS})
1456 INSTALL(TARGETS alffplay
1457 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
1458 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1459 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1462 MESSAGE(STATUS "Building SDL and FFmpeg example programs")
1464 MESSAGE(STATUS "Building SDL example programs")