1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
7 IF(COMMAND CMAKE_POLICY)
8 CMAKE_POLICY(SET CMP0003 NEW)
9 CMAKE_POLICY(SET CMP0005 NEW)
11 CMAKE_POLICY(SET CMP0042 NEW)
13 ENDIF(COMMAND CMAKE_POLICY)
15 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
17 INCLUDE(CheckFunctionExists)
18 INCLUDE(CheckLibraryExists)
19 INCLUDE(CheckSharedFunctionExists)
20 INCLUDE(CheckIncludeFile)
21 INCLUDE(CheckIncludeFiles)
22 INCLUDE(CheckSymbolExists)
23 INCLUDE(CheckCCompilerFlag)
24 INCLUDE(CheckCSourceCompiles)
25 INCLUDE(CheckTypeSize)
26 include(CheckFileOffsetBits)
29 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
32 OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
34 OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
36 OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
37 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
39 OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
40 OPTION(ALSOFT_TESTS "Build and install test programs" ON)
42 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
43 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
44 OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
45 OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
48 set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "The share install dir")
55 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
57 # This option is mainly for static linking OpenAL Soft into another project
58 # that already defines the IDs. It is up to that project to ensure all
59 # required IDs are defined.
60 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
63 OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
66 SET(DLLTOOL "${HOST}-dlltool")
68 SET(DLLTOOL "dlltool")
75 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
76 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
77 ADD_DEFINITIONS("-I/usr/include")
78 SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
85 SET(LIB_MAJOR_VERSION "1")
86 SET(LIB_MINOR_VERSION "17")
88 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
94 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
95 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
98 CHECK_C_COMPILER_FLAG(-std=c11 HAVE_STD_C11)
100 SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
102 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
104 SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
109 # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
110 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
111 IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
112 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
113 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500")
114 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
115 IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
116 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
118 ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500)
121 UNSET(OLD_REQUIRED_FLAGS)
124 # Set defines for large file support
125 CHECK_FILE_OFFSET_BITS()
126 IF(_FILE_OFFSET_BITS)
127 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
128 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
130 ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES)
131 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
133 # MSVC may need workarounds for C99 restrict and inline
135 # TODO: Once we truly require C99, these restrict and inline checks should go
137 CHECK_C_SOURCE_COMPILES("int *restrict foo;
138 int main() {return 0;}" HAVE_RESTRICT)
139 IF(NOT HAVE_RESTRICT)
140 ADD_DEFINITIONS("-Drestrict=")
141 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
144 CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
145 int main() {return 0;}" HAVE_INLINE)
147 CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
148 int main() {return 0;}" HAVE___INLINE)
149 IF(NOT HAVE___INLINE)
150 MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
153 ADD_DEFINITIONS(-Dinline=__inline)
154 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
158 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
159 IF(CMAKE_COMPILER_IS_GNUCC)
160 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
161 # Force no inlining for the next test.
162 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
164 CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
165 int main() {return foo();}" INLINE_IS_C99)
166 IF(NOT INLINE_IS_C99)
167 MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
168 Please update your compiler for better C99 compliance.")
171 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
174 # Check if we have C99 variable length arrays
175 CHECK_C_SOURCE_COMPILES(
176 "int main(int argc, char *argv[])
178 volatile int tmp[argc];
184 # Check if we have C99 bool
185 CHECK_C_SOURCE_COMPILES(
186 "int main(int argc, char *argv[])
189 ret = (argc > 1) ? 1 : 0;
194 # Check if we have C11 static_assert
195 CHECK_C_SOURCE_COMPILES(
198 _Static_assert(sizeof(int) == sizeof(int), \"What\");
201 HAVE_C11_STATIC_ASSERT)
203 # Check if we have C11 alignas
204 CHECK_C_SOURCE_COMPILES(
205 "_Alignas(16) int foo;
212 # Check if we have C11 _Atomic
213 CHECK_C_SOURCE_COMPILES(
214 "#include <stdatomic.h>
215 const int _Atomic foo = ATOMIC_VAR_INIT(~0);
218 return atomic_load(&foo);
222 # Add definitions, compiler switches, etc.
223 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
224 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
225 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
226 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
227 ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
231 IF(NOT CMAKE_BUILD_TYPE)
232 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
233 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
236 IF(NOT CMAKE_DEBUG_POSTFIX)
237 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
238 "Library postfix for debug builds. Normally left blank."
244 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
245 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
246 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} /wd4098")
249 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
251 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
254 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
257 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
258 IF(FORCE_STATIC_VCRT)
260 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
261 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
262 IF(${flag_var} MATCHES "/MD")
263 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
268 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Winline -Wall")
269 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
271 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wextra")
275 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
278 # Force enable -fPIC for CMake versions before 2.8.9 (later versions have
279 # the POSITION_INDEPENDENT_CODE target property). The static common library
280 # will be linked into the dynamic openal library, which requires all its
281 # code to be position-independent.
282 IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
283 CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
285 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC")
289 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
291 FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
292 IF(${flag_var} MATCHES "-DNDEBUG")
293 STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
297 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
298 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
300 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
301 if(ALSOFT_STATIC_LIBGCC)
302 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
303 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
304 check_c_source_compiles(
310 HAVE_STATIC_LIBGCC_SWITCH
312 if(HAVE_STATIC_LIBGCC_SWITCH)
313 set(EXTRA_LIBS ${EXTRA_LIBS} -static-libgcc)
315 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
316 unset(OLD_REQUIRED_LIBRARIES)
320 # Set visibility/export options if available
323 SET(EXPORT_DECL "__declspec(dllexport)")
325 SET(ALIGN_DECL "__declspec(align(x))")
327 SET(ALIGN_DECL "__declspec(aligned(x))")
330 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
331 # Yes GCC, really don't accept visibility modes you don't support
332 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
334 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
335 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
336 IF(HAVE_GCC_PROTECTED_VISIBILITY)
337 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
339 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
340 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
341 IF(HAVE_GCC_DEFAULT_VISIBILITY)
342 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
346 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
347 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
348 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
349 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
350 SET(HIDDEN_DECL "__attribute__((visibility(\"hidden\")))")
354 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
355 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
356 IF(HAVE_ATTRIBUTE_ALIGNED)
357 SET(ALIGN_DECL "__attribute__((aligned(x)))")
360 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
366 SET(SSE4_1_SWITCH "")
368 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
370 SET(SSE_SWITCH "-msse")
372 CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
373 IF(HAVE_MSSE2_SWITCH)
374 SET(SSE2_SWITCH "-msse2")
376 CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
377 IF(HAVE_MSSE3_SWITCH)
378 SET(SSE3_SWITCH "-msse3")
380 CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
381 IF(HAVE_MSSE4_1_SWITCH)
382 SET(SSE4_1_SWITCH "-msse4.1")
386 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
387 int main() {return 0;}" HAVE_GCC_FORMAT)
389 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
390 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
391 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
392 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
393 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
394 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
395 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
396 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
397 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
398 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
399 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
400 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
401 IF(NOT HAVE_GUIDDEF_H)
402 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
405 # Some systems need libm for some of the following math functions to work
406 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
408 SET(EXTRA_LIBS m ${EXTRA_LIBS})
409 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
412 # Check for the dlopen API (for dynamicly loading backend libs)
414 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
416 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
417 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
420 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
423 # Check for a cpuid intrinsic
425 CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
428 unsigned int eax, ebx, ecx, edx;
429 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
430 }" HAVE_GCC_GET_CPUID)
433 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
439 }" HAVE_CPUID_INTRINSIC)
442 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
443 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
444 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
445 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
446 CHECK_SYMBOL_EXISTS(modff math.h HAVE_MODFF)
448 CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
450 MESSAGE(FATAL_ERROR "No alloca function found, please report!")
455 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
456 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
459 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
460 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
461 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
462 IF(NOT HAVE_STRCASECMP)
463 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
464 IF(NOT HAVE__STRICMP)
465 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
468 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
471 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
472 IF(NOT HAVE_STRNCASECMP)
473 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
474 IF(NOT HAVE__STRNICMP)
475 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
478 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
481 CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
482 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
483 IF(NOT HAVE_SNPRINTF)
484 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
485 IF(NOT HAVE__SNPRINTF)
486 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
489 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
492 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
493 IF(NOT HAVE_ISFINITE)
494 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
496 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
498 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
500 ADD_DEFINITIONS(-Disfinite=_finite)
502 ADD_DEFINITIONS(-Disfinite=finite)
506 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
508 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
510 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
513 ADD_DEFINITIONS(-Disnan=_isnan)
517 # Check if we have Windows headers
518 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
519 IF(NOT HAVE_WINDOWS_H)
520 CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
521 IF(NOT HAVE_GETTIMEOFDAY)
522 MESSAGE(FATAL_ERROR "No timing function found!")
525 CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
526 IF(NOT HAVE_NANOSLEEP)
527 MESSAGE(FATAL_ERROR "No sleep function found!")
530 # We need pthreads outside of Windows
531 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
532 IF(NOT HAVE_PTHREAD_H)
533 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
535 # Some systems need pthread_np.h to get recursive mutexes
536 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
538 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
540 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread")
541 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
542 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
545 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
547 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
550 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
552 IF(HAVE_PTHREAD_NP_H)
553 CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
554 IF(NOT HAVE_PTHREAD_SETNAME_NP)
555 CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
557 CHECK_C_SOURCE_COMPILES("
559 #include <pthread_np.h>
562 pthread_setname_np(\"testname\");
565 PTHREAD_SETNAME_NP_ONE_PARAM
568 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
570 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
571 IF(NOT HAVE_PTHREAD_SETNAME_NP)
572 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
574 CHECK_C_SOURCE_COMPILES("
578 pthread_setname_np(\"testname\");
581 PTHREAD_SETNAME_NP_ONE_PARAM
584 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
587 CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
589 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
591 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
595 # Check for a 64-bit type
596 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
597 IF(NOT HAVE_STDINT_H)
599 CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
602 int main() {return 0;}" HAVE___INT64)
605 IF(NOT SIZEOF_LONG MATCHES "8")
606 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
607 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
614 SET(COMMON_OBJS common/almalloc.c
620 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
624 OpenAL32/alExtension.c
626 OpenAL32/alListener.c
630 OpenAL32/sample_cvt.c
632 SET(ALC_OBJS Alc/ALc.c
637 Alc/effects/autowah.c
639 Alc/effects/compressor.c
640 Alc/effects/dedicated.c
641 Alc/effects/distortion.c
643 Alc/effects/equalizer.c
644 Alc/effects/flanger.c
645 Alc/effects/modulator.c
660 SET(CPU_EXTS "Default")
675 SET(HAVE_PORTAUDIO 0)
676 SET(HAVE_PULSEAUDIO 0)
677 SET(HAVE_COREAUDIO 0)
681 # Check for SSE support
682 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
683 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
685 OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
686 IF(ALSOFT_CPUEXT_SSE)
687 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
689 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
691 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
692 COMPILE_FLAGS "${SSE_SWITCH}")
694 SET(CPU_EXTS "${CPU_EXTS}, SSE")
698 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
699 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
702 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
703 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
705 OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
706 IF(HAVE_SSE AND ALSOFT_CPUEXT_SSE2)
707 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
709 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse2.c)
711 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse2.c PROPERTIES
712 COMPILE_FLAGS "${SSE2_SWITCH}")
714 SET(CPU_EXTS "${CPU_EXTS}, SSE2")
718 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
719 MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
722 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE3 support" OFF)
723 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
725 OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
726 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
727 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
729 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse3.c)
731 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse3.c PROPERTIES
732 COMPILE_FLAGS "${SSE3_SWITCH}")
734 SET(CPU_EXTS "${CPU_EXTS}, SSE3")
738 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
739 MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
742 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
743 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
745 OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
746 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE4_1)
747 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
749 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse41.c)
751 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse41.c PROPERTIES
752 COMPILE_FLAGS "${SSE4_1_SWITCH}")
754 SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
758 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
759 MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
762 # Check for ARM Neon support
763 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
764 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
766 OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
767 IF(ALSOFT_CPUEXT_NEON)
769 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
770 SET(CPU_EXTS "${CPU_EXTS}, Neon")
773 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
774 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
778 IF(WIN32 OR HAVE_DLFCN_H)
780 MACRO(ADD_BACKEND_LIBS _LIBS)
783 SET(IS_LINKED " (linked)")
784 MACRO(ADD_BACKEND_LIBS _LIBS)
785 SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
790 SET(ALC_OBJS ${ALC_OBJS}
792 # Default backends, always available
793 Alc/backends/loopback.c
798 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
801 OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
802 IF(ALSOFT_BACKEND_ALSA)
804 SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
805 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
806 ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
807 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
808 INCLUDE_DIRECTORIES(${ALSA_INCLUDE_DIRS})
812 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
813 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
817 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
820 OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
821 IF(ALSOFT_BACKEND_OSS)
823 SET(BACKENDS "${BACKENDS} OSS,")
824 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
825 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
826 INCLUDE_DIRECTORIES(${OSS_INCLUDE_DIRS})
830 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
831 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
834 # Check Solaris backend
835 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
836 FIND_PACKAGE(AudioIO)
838 OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
839 IF(ALSOFT_BACKEND_SOLARIS)
841 SET(BACKENDS "${BACKENDS} Solaris,")
842 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
843 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
844 INCLUDE_DIRECTORIES(${AUDIOIO_INCLUDE_DIRS})
848 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
849 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
852 # Check SndIO backend
853 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
854 FIND_PACKAGE(SoundIO)
856 OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
857 IF(ALSOFT_BACKEND_SNDIO)
859 SET(BACKENDS "${BACKENDS} SndIO (linked),")
860 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
861 SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
862 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
863 INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
867 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
868 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
872 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
875 OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
876 IF(ALSOFT_BACKEND_QSA)
878 SET(BACKENDS "${BACKENDS} QSA (linked),")
879 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
880 SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
881 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
882 INCLUDE_DIRECTORIES(${QSA_INCLUDE_DIRS})
886 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
887 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
890 # Check Windows-only backends
891 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
892 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
893 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
895 # Check MMSystem backend
896 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
898 CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
900 OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
901 IF(ALSOFT_BACKEND_WINMM)
903 SET(BACKENDS "${BACKENDS} WinMM,")
904 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
905 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
910 # Check DSound backend
913 OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
914 IF(ALSOFT_BACKEND_DSOUND)
916 SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
917 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
918 ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
919 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
920 INCLUDE_DIRECTORIES(${DSOUND_INCLUDE_DIRS})
925 # Check for MMDevApi backend
926 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
927 IF(HAVE_MMDEVICEAPI_H)
928 OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
929 IF(ALSOFT_BACKEND_MMDEVAPI)
931 SET(BACKENDS "${BACKENDS} MMDevApi,")
932 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
936 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
937 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
939 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
940 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
942 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
943 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
946 # Check PortAudio backend
947 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
948 FIND_PACKAGE(PortAudio)
950 OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
951 IF(ALSOFT_BACKEND_PORTAUDIO)
952 SET(HAVE_PORTAUDIO 1)
953 SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
954 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
955 ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
956 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
957 INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
961 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
962 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
965 # Check PulseAudio backend
966 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
967 FIND_PACKAGE(PulseAudio)
969 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
970 IF(ALSOFT_BACKEND_PULSEAUDIO)
971 SET(HAVE_PULSEAUDIO 1)
972 SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
973 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
974 ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
975 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
976 INCLUDE_DIRECTORIES(${PULSEAUDIO_INCLUDE_DIRS})
980 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
981 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
985 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
988 OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
989 IF(ALSOFT_BACKEND_JACK)
991 SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
992 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/jack.c)
993 ADD_BACKEND_LIBS(${JACK_LIBRARIES})
994 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
995 INCLUDE_DIRECTORIES(${JACK_INCLUDE_DIRS})
999 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
1000 MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
1003 # Check CoreAudio backend
1004 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
1005 FIND_LIBRARY(COREAUDIO_FRAMEWORK
1007 PATHS /System/Library/Frameworks
1009 IF(COREAUDIO_FRAMEWORK)
1010 OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1011 IF(ALSOFT_BACKEND_COREAUDIO)
1012 SET(HAVE_COREAUDIO 1)
1013 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
1014 SET(BACKENDS "${BACKENDS} CoreAudio,")
1015 SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1016 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1017 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1019 # Some versions of OSX may need the AudioToolbox framework. Add it if
1021 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1023 PATHS ~/Library/Frameworks
1025 /System/Library/Frameworks
1027 IF(AUDIOTOOLBOX_LIBRARY)
1028 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1032 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1033 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1036 # Check for OpenSL (Android) backend
1037 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1038 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
1039 IF(HAVE_SLES_OPENSLES_ANDROID_H)
1040 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
1041 IF(HAVE_LIBOPENSLES)
1042 OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1043 IF(ALSOFT_BACKEND_OPENSL)
1045 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
1046 SET(BACKENDS "${BACKENDS} OpenSL,")
1047 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
1051 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1052 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1055 # Optionally enable the Wave Writer backend
1056 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1057 IF(ALSOFT_BACKEND_WAVE)
1059 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
1060 SET(BACKENDS "${BACKENDS} WaveFile,")
1063 # This is always available
1064 SET(BACKENDS "${BACKENDS} Null")
1066 option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" OFF)
1067 if(ALSOFT_EMBED_HRTF_DATA)
1069 set(ALC_OBJS ${ALC_OBJS} Alc/hrtf_res.rc)
1071 set(FILENAMES default-44100.mhr default-48000.mhr)
1072 foreach(FILENAME ${FILENAMES})
1073 set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
1074 add_custom_command(OUTPUT ${outfile}
1075 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
1076 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
1077 COMMAND "${CMAKE_LINKER}" -r -b binary -o "${outfile}" ${FILENAME}
1078 COMMAND "${CMAKE_OBJCOPY}" --rename-section .data=.rodata,alloc,load,readonly,data,contents "${outfile}" "${outfile}"
1079 COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
1082 set(ALC_OBJS ${ALC_OBJS} ${outfile})
1090 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1091 add_subdirectory(utils/alsoft-config)
1096 FIND_PACKAGE(SDL_sound)
1097 IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1098 INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1100 FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1101 IF(FFMPEG_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1102 INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
1107 IF(LIBTYPE STREQUAL "STATIC")
1108 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
1109 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
1112 # Needed for openal.pc.in
1113 SET(prefix ${CMAKE_INSTALL_PREFIX})
1114 SET(exec_prefix "\${prefix}")
1115 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
1116 SET(bindir "\${exec_prefix}/bin")
1117 SET(includedir "\${prefix}/include")
1118 SET(PACKAGE_VERSION "${LIB_VERSION}")
1122 "${OpenAL_SOURCE_DIR}/config.h.in"
1123 "${OpenAL_BINARY_DIR}/config.h")
1125 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1126 "${OpenAL_BINARY_DIR}/openal.pc"
1129 # Build a common library with reusable helpers
1130 ADD_LIBRARY(common STATIC ${COMMON_OBJS})
1131 SET_PROPERTY(TARGET common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1132 IF(NOT LIBTYPE STREQUAL "STATIC")
1133 SET_PROPERTY(TARGET common PROPERTY POSITION_INDEPENDENT_CODE TRUE)
1136 # Build main library
1137 IF(LIBTYPE STREQUAL "STATIC")
1138 ADD_LIBRARY(${LIBNAME} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1140 ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
1142 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1143 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
1144 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1145 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
1147 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
1149 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
1152 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
1155 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
1158 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
1161 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
1164 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
1167 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
1170 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
1173 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
1175 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
1176 SOVERSION ${LIB_MAJOR_VERSION})
1177 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
1178 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
1180 IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
1181 FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1182 FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1183 IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1185 IF(NOT SED_EXECUTABLE)
1186 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1188 IF(NOT DLLTOOL_EXECUTABLE)
1189 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1192 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--output-def,${LIBNAME}.def")
1193 ADD_CUSTOM_COMMAND(TARGET ${LIBNAME} POST_BUILD
1194 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" ${LIBNAME}.def
1195 COMMAND "${DLLTOOL_EXECUTABLE}" -d ${LIBNAME}.def -l ${LIBNAME}.lib -D ${LIBNAME}.dll
1196 COMMENT "Stripping ordinals from ${LIBNAME}.def and generating ${LIBNAME}.lib..."
1203 TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
1206 # Add an install target here
1207 INSTALL(TARGETS ${LIBNAME}
1208 RUNTIME DESTINATION bin
1209 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1210 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1212 INSTALL(FILES include/AL/al.h
1216 include/AL/efx-creative.h
1217 include/AL/efx-presets.h
1218 DESTINATION include/AL
1220 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1221 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
1226 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1227 MESSAGE(STATUS " ${BACKENDS}")
1229 MESSAGE(STATUS "Building with support for CPU extensions:")
1230 MESSAGE(STATUS " ${CPU_EXTS}")
1235 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1236 MESSAGE(STATUS " This is probably NOT what you want!")
1241 if(ALSOFT_EMBED_HRTF_DATA)
1242 message(STATUS "Embedding HRTF datasets")
1246 # Install alsoft.conf configuration file
1248 INSTALL(FILES alsoftrc.sample
1249 DESTINATION ${SHARE_INSTALL_DIR}/openal
1251 MESSAGE(STATUS "Installing sample configuration")
1255 # Install HRTF definitions
1256 IF(ALSOFT_HRTF_DEFS)
1257 INSTALL(FILES hrtf/default-44100.mhr
1258 hrtf/default-48000.mhr
1259 DESTINATION ${SHARE_INSTALL_DIR}/openal/hrtf
1261 MESSAGE(STATUS "Installing HRTF definitions")
1265 # Install AmbDec presets
1266 IF(ALSOFT_AMBDEC_PRESETS)
1267 INSTALL(FILES presets/3D7.1.ambdec
1268 presets/hexagon.ambdec
1269 presets/itu5.1.ambdec
1270 presets/rectangle.ambdec
1271 presets/square.ambdec
1273 DESTINATION ${SHARE_INSTALL_DIR}/openal/presets
1275 MESSAGE(STATUS "Installing AmbDec presets")
1280 ADD_EXECUTABLE(openal-info utils/openal-info.c)
1281 SET_PROPERTY(TARGET openal-info APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1282 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
1284 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1285 SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1287 TARGET_LINK_LIBRARIES(makehrtf m)
1290 ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
1291 SET_PROPERTY(TARGET bsincgen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1293 TARGET_LINK_LIBRARIES(bsincgen m)
1297 INSTALL(TARGETS openal-info makehrtf bsincgen
1298 RUNTIME DESTINATION bin
1299 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1300 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1304 MESSAGE(STATUS "Building utility programs")
1305 IF(TARGET alsoft-config)
1306 MESSAGE(STATUS "Building configuration program")
1312 ADD_LIBRARY(test-common STATIC examples/common/alhelpers.c)
1313 SET_PROPERTY(TARGET test-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1315 ADD_EXECUTABLE(altonegen examples/altonegen.c)
1316 TARGET_LINK_LIBRARIES(altonegen test-common ${LIBNAME})
1317 SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1320 INSTALL(TARGETS altonegen
1321 RUNTIME DESTINATION bin
1322 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1323 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1327 MESSAGE(STATUS "Building test programs")
1332 IF(SDL2_FOUND AND SDL_SOUND_FOUND)
1333 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1334 examples/common/sdl_sound.c)
1335 SET_PROPERTY(TARGET ex-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1336 SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1337 ${SDL_SOUND_INCLUDE_DIR})
1339 ADD_EXECUTABLE(alstream examples/alstream.c)
1340 TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1342 SET_PROPERTY(TARGET alstream APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1343 SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1344 ${SDL_SOUND_INCLUDE_DIR})
1346 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1347 TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1349 SET_PROPERTY(TARGET alreverb APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1350 SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1351 ${SDL_SOUND_INCLUDE_DIR})
1353 ADD_EXECUTABLE(allatency examples/allatency.c)
1354 TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1356 SET_PROPERTY(TARGET allatency APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1357 SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1358 ${SDL_SOUND_INCLUDE_DIR})
1360 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1361 TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1363 SET_PROPERTY(TARGET alloopback APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1364 SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1365 ${SDL_SOUND_INCLUDE_DIR})
1367 ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1368 TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1370 SET_PROPERTY(TARGET alhrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1371 SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1372 ${SDL_SOUND_INCLUDE_DIR})
1375 INSTALL(TARGETS alstream alreverb allatency alloopback alhrtf
1376 RUNTIME DESTINATION bin
1377 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1378 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1385 IF(AVFORMAT_VERSION VERSION_LESS "55.33.100")
1386 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 55.33.100)")
1389 IF(AVCODEC_VERSION VERSION_LESS "55.52.102")
1390 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 55.52.102)")
1393 IF(AVUTIL_VERSION VERSION_LESS "52.66.100")
1394 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 52.66.100)")
1397 IF(SWSCALE_VERSION VERSION_LESS "2.5.102")
1398 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 2.5.102)")
1401 IF(SWRESAMPLE_VERSION VERSION_LESS "0.18.100")
1402 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 0.18.100)")
1406 IF(FFVER_OK AND NOT MSVC)
1407 ADD_EXECUTABLE(alffplay examples/alffplay.c)
1408 TARGET_LINK_LIBRARIES(alffplay common ex-common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
1409 SET_PROPERTY(TARGET alffplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
1410 SET_PROPERTY(TARGET alffplay APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1411 ${FFMPEG_INCLUDE_DIRS})
1414 INSTALL(TARGETS alffplay
1415 RUNTIME DESTINATION bin
1416 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1417 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1420 MESSAGE(STATUS "Building SDL and FFmpeg example programs")
1422 MESSAGE(STATUS "Building SDL example programs")