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_INSTALL "Install headers and libraries" ON)
47 set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "The share install dir")
54 ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
56 # This option is mainly for static linking OpenAL Soft into another project
57 # that already defines the IDs. It is up to that project to ensure all
58 # required IDs are defined.
59 OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
62 OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
65 SET(DLLTOOL "${HOST}-dlltool")
67 SET(DLLTOOL "dlltool")
74 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
75 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
76 ADD_DEFINITIONS("-I/usr/include")
77 SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
84 SET(LIB_MAJOR_VERSION "1")
85 SET(LIB_MINOR_VERSION "17")
87 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
93 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
94 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
97 CHECK_C_COMPILER_FLAG(-std=c11 HAVE_STD_C11)
99 SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
101 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
103 SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
108 # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
109 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
110 IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
111 SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
112 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500")
113 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
114 IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
115 SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
117 ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500)
120 UNSET(OLD_REQUIRED_FLAGS)
123 # Set defines for large file support
124 CHECK_FILE_OFFSET_BITS()
125 IF(_FILE_OFFSET_BITS)
126 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
127 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
129 ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES)
130 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
132 # MSVC may need workarounds for C99 restrict and inline
134 # TODO: Once we truly require C99, these restrict and inline checks should go
136 CHECK_C_SOURCE_COMPILES("int *restrict foo;
137 int main() {return 0;}" HAVE_RESTRICT)
138 IF(NOT HAVE_RESTRICT)
139 ADD_DEFINITIONS("-Drestrict=")
140 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
143 CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
144 int main() {return 0;}" HAVE_INLINE)
146 CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
147 int main() {return 0;}" HAVE___INLINE)
148 IF(NOT HAVE___INLINE)
149 MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
152 ADD_DEFINITIONS(-Dinline=__inline)
153 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
157 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
158 IF(CMAKE_COMPILER_IS_GNUCC)
159 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
160 # Force no inlining for the next test.
161 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
163 CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
164 int main() {return foo();}" INLINE_IS_C99)
165 IF(NOT INLINE_IS_C99)
166 MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
167 Please update your compiler for better C99 compliance.")
170 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
173 # Check if we have C99 variable length arrays
174 CHECK_C_SOURCE_COMPILES(
175 "int main(int argc, char *argv[])
177 volatile int tmp[argc];
183 # Check if we have C99 bool
184 CHECK_C_SOURCE_COMPILES(
185 "int main(int argc, char *argv[])
188 ret = (argc > 1) ? 1 : 0;
193 # Check if we have C11 static_assert
194 CHECK_C_SOURCE_COMPILES(
197 _Static_assert(sizeof(int) == sizeof(int), \"What\");
200 HAVE_C11_STATIC_ASSERT)
202 # Check if we have C11 alignas
203 CHECK_C_SOURCE_COMPILES(
204 "_Alignas(16) int foo;
211 # Check if we have C11 _Atomic
212 CHECK_C_SOURCE_COMPILES(
213 "#include <stdatomic.h>
214 const int _Atomic foo = ATOMIC_VAR_INIT(~0);
217 return atomic_load(&foo);
221 # Add definitions, compiler switches, etc.
222 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
223 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
224 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
225 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
226 ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
230 IF(NOT CMAKE_BUILD_TYPE)
231 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
232 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
235 IF(NOT CMAKE_DEBUG_POSTFIX)
236 SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
237 "Library postfix for debug builds. Normally left blank."
242 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
243 ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
244 ADD_DEFINITIONS("/wd4098")
247 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
249 STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
252 MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
255 OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
256 IF(FORCE_STATIC_VCRT)
258 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
259 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
260 IF(${flag_var} MATCHES "/MD")
261 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
266 ADD_DEFINITIONS(-Winline -Wall)
267 CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
269 ADD_DEFINITIONS(-Wextra)
273 ADD_DEFINITIONS(-Werror)
276 # Force enable -fPIC for CMake versions before 2.8.9 (later versions have
277 # the POSITION_INDEPENDENT_CODE target property). The static common library
278 # will be linked into the dynamic openal library, which requires all its
279 # code to be position-independent.
280 IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
281 CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
283 ADD_DEFINITIONS(-fPIC)
287 # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
289 FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
290 IF(${flag_var} MATCHES "-DNDEBUG")
291 STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
295 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
296 int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
298 option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
299 if(ALSOFT_STATIC_LIBGCC)
300 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
301 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
302 check_c_source_compiles(
308 HAVE_STATIC_LIBGCC_SWITCH
310 if(HAVE_STATIC_LIBGCC_SWITCH)
311 set(EXTRA_LIBS ${EXTRA_LIBS} -static-libgcc)
313 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
314 unset(OLD_REQUIRED_LIBRARIES)
318 # Set visibility/export options if available
320 SET(EXPORT_DECL "__declspec(dllexport)")
322 SET(ALIGN_DECL "__declspec(align(x))")
324 SET(ALIGN_DECL "__declspec(aligned(x))")
327 SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
328 # Yes GCC, really don't accept visibility modes you don't support
329 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
331 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
332 int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
333 IF(HAVE_GCC_PROTECTED_VISIBILITY)
334 SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
336 CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
337 int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
338 IF(HAVE_GCC_DEFAULT_VISIBILITY)
339 SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
343 IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
344 CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
345 IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
346 ADD_DEFINITIONS(-fvisibility=hidden)
350 CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
351 int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
352 IF(HAVE_ATTRIBUTE_ALIGNED)
353 SET(ALIGN_DECL "__attribute__((aligned(x)))")
356 SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
362 SET(SSE4_1_SWITCH "")
364 CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
366 SET(SSE_SWITCH "-msse")
368 CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
369 IF(HAVE_MSSE2_SWITCH)
370 SET(SSE2_SWITCH "-msse2")
372 CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
373 IF(HAVE_MSSE3_SWITCH)
374 SET(SSE3_SWITCH "-msse3")
376 CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
377 IF(HAVE_MSSE4_1_SWITCH)
378 SET(SSE4_1_SWITCH "-msse4.1")
382 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
383 int main() {return 0;}" HAVE_GCC_FORMAT)
385 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
386 CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
387 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
388 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
389 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
390 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
391 CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
392 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
393 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
394 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
395 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
396 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
397 IF(NOT HAVE_GUIDDEF_H)
398 CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
401 # Some systems need libm for some of the following math functions to work
402 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
404 SET(EXTRA_LIBS m ${EXTRA_LIBS})
405 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
408 # Check for the dlopen API (for dynamicly loading backend libs)
410 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
412 SET(EXTRA_LIBS dl ${EXTRA_LIBS})
413 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
416 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
419 # Check for a cpuid intrinsic
421 CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
424 unsigned int eax, ebx, ecx, edx;
425 return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
426 }" HAVE_GCC_GET_CPUID)
429 CHECK_C_SOURCE_COMPILES("#include <intrin.h>
435 }" HAVE_CPUID_INTRINSIC)
438 CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
439 CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
440 CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
441 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
442 CHECK_SYMBOL_EXISTS(modff math.h HAVE_MODFF)
444 CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
446 MESSAGE(FATAL_ERROR "No alloca function found, please report!")
451 CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
452 CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
455 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
456 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
457 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
458 IF(NOT HAVE_STRCASECMP)
459 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
460 IF(NOT HAVE__STRICMP)
461 MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
464 ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
467 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
468 IF(NOT HAVE_STRNCASECMP)
469 CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
470 IF(NOT HAVE__STRNICMP)
471 MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
474 ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
477 CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
478 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
479 IF(NOT HAVE_SNPRINTF)
480 CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
481 IF(NOT HAVE__SNPRINTF)
482 MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
485 ADD_DEFINITIONS(-Dsnprintf=_snprintf)
488 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
489 IF(NOT HAVE_ISFINITE)
490 CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
492 CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
494 MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
496 ADD_DEFINITIONS(-Disfinite=_finite)
498 ADD_DEFINITIONS(-Disfinite=finite)
502 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
504 CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
506 MESSAGE(FATAL_ERROR "No isnan function found, please report!")
509 ADD_DEFINITIONS(-Disnan=_isnan)
513 # Check if we have Windows headers
514 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502)
515 IF(NOT HAVE_WINDOWS_H)
516 CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
517 IF(NOT HAVE_GETTIMEOFDAY)
518 MESSAGE(FATAL_ERROR "No timing function found!")
521 CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
522 IF(NOT HAVE_NANOSLEEP)
523 MESSAGE(FATAL_ERROR "No sleep function found!")
526 # We need pthreads outside of Windows
527 CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
528 IF(NOT HAVE_PTHREAD_H)
529 MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
531 # Some systems need pthread_np.h to get recursive mutexes
532 CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
534 CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
536 ADD_DEFINITIONS(-pthread)
537 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
538 SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
541 CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
543 SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
546 CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
548 IF(HAVE_PTHREAD_NP_H)
549 CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
550 IF(NOT HAVE_PTHREAD_SETNAME_NP)
551 CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
553 CHECK_C_SOURCE_COMPILES("
555 #include <pthread_np.h>
558 pthread_setname_np(\"testname\");
561 PTHREAD_SETNAME_NP_ONE_PARAM
564 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
566 CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
567 IF(NOT HAVE_PTHREAD_SETNAME_NP)
568 CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
570 CHECK_C_SOURCE_COMPILES("
574 pthread_setname_np(\"testname\");
577 PTHREAD_SETNAME_NP_ONE_PARAM
580 CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
583 CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK)
585 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
587 SET(EXTRA_LIBS rt ${EXTRA_LIBS})
591 # Check for a 64-bit type
592 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
593 IF(NOT HAVE_STDINT_H)
595 CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0502
598 int main() {return 0;}" HAVE___INT64)
601 IF(NOT SIZEOF_LONG MATCHES "8")
602 IF(NOT SIZEOF_LONG_LONG MATCHES "8")
603 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
610 SET(COMMON_OBJS common/atomic.c
615 SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
619 OpenAL32/alExtension.c
621 OpenAL32/alListener.c
625 OpenAL32/sample_cvt.c
627 SET(ALC_OBJS Alc/ALc.c
632 Alc/effects/autowah.c
634 Alc/effects/compressor.c
635 Alc/effects/dedicated.c
636 Alc/effects/distortion.c
638 Alc/effects/equalizer.c
639 Alc/effects/flanger.c
640 Alc/effects/modulator.c
652 SET(CPU_EXTS "Default")
667 SET(HAVE_PORTAUDIO 0)
668 SET(HAVE_PULSEAUDIO 0)
669 SET(HAVE_COREAUDIO 0)
673 # Check for SSE support
674 OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
675 CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
677 OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
678 IF(ALSOFT_CPUEXT_SSE)
679 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
681 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
683 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
684 COMPILE_FLAGS "${SSE_SWITCH}")
686 SET(CPU_EXTS "${CPU_EXTS}, SSE")
690 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
691 MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
694 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
695 CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
697 OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
698 IF(HAVE_SSE AND ALSOFT_CPUEXT_SSE2)
699 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
701 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse2.c)
703 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse2.c PROPERTIES
704 COMPILE_FLAGS "${SSE2_SWITCH}")
706 SET(CPU_EXTS "${CPU_EXTS}, SSE2")
710 IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
711 MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
714 OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE3 support" OFF)
715 CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
717 OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
718 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
719 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
721 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse3.c)
723 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse3.c PROPERTIES
724 COMPILE_FLAGS "${SSE3_SWITCH}")
726 SET(CPU_EXTS "${CPU_EXTS}, SSE3")
730 IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
731 MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
734 OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
735 CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
737 OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
738 IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE4_1)
739 IF(ALIGN_DECL OR HAVE_C11_ALIGNAS)
741 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse41.c)
743 SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse41.c PROPERTIES
744 COMPILE_FLAGS "${SSE4_1_SWITCH}")
746 SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
750 IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
751 MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
754 # Check for ARM Neon support
755 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
756 CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
758 OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
759 IF(ALSOFT_CPUEXT_NEON)
761 SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
762 SET(CPU_EXTS "${CPU_EXTS}, Neon")
765 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
766 MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
770 IF(WIN32 OR HAVE_DLFCN_H)
772 MACRO(ADD_BACKEND_LIBS _LIBS)
775 SET(IS_LINKED " (linked)")
776 MACRO(ADD_BACKEND_LIBS _LIBS)
777 SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
782 SET(ALC_OBJS ${ALC_OBJS}
784 # Default backends, always available
785 Alc/backends/loopback.c
790 OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
793 OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
794 IF(ALSOFT_BACKEND_ALSA)
796 SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
797 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
798 ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
799 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
800 INCLUDE_DIRECTORIES(${ALSA_INCLUDE_DIRS})
804 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
805 MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
809 OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
812 OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
813 IF(ALSOFT_BACKEND_OSS)
815 SET(BACKENDS "${BACKENDS} OSS,")
816 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c)
817 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
818 INCLUDE_DIRECTORIES(${OSS_INCLUDE_DIRS})
822 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
823 MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
826 # Check Solaris backend
827 OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
828 FIND_PACKAGE(AudioIO)
830 OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
831 IF(ALSOFT_BACKEND_SOLARIS)
833 SET(BACKENDS "${BACKENDS} Solaris,")
834 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
835 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
836 INCLUDE_DIRECTORIES(${AUDIOIO_INCLUDE_DIRS})
840 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
841 MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
844 # Check SndIO backend
845 OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
846 FIND_PACKAGE(SoundIO)
848 OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
849 IF(ALSOFT_BACKEND_SNDIO)
851 SET(BACKENDS "${BACKENDS} SndIO (linked),")
852 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
853 SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
854 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
855 INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
859 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
860 MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
864 OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
867 OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
868 IF(ALSOFT_BACKEND_QSA)
870 SET(BACKENDS "${BACKENDS} QSA (linked),")
871 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
872 SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
873 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
874 INCLUDE_DIRECTORIES(${QSA_INCLUDE_DIRS})
878 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
879 MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
882 # Check Windows-only backends
883 OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
884 OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
885 OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
887 # Check MMSystem backend
888 CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
890 CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
892 OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
893 IF(ALSOFT_BACKEND_WINMM)
895 SET(BACKENDS "${BACKENDS} WinMM,")
896 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c)
897 SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
902 # Check DSound backend
905 OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
906 IF(ALSOFT_BACKEND_DSOUND)
908 SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
909 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
910 ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
911 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
912 INCLUDE_DIRECTORIES(${DSOUND_INCLUDE_DIRS})
917 # Check for MMDevApi backend
918 CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
919 IF(HAVE_MMDEVICEAPI_H)
920 OPTION(ALSOFT_BACKEND_MMDEVAPI "Enable MMDevApi backend" ON)
921 IF(ALSOFT_BACKEND_MMDEVAPI)
923 SET(BACKENDS "${BACKENDS} MMDevApi,")
924 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c)
928 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
929 MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
931 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
932 MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
934 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
935 MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
938 # Check PortAudio backend
939 OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
940 FIND_PACKAGE(PortAudio)
942 OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
943 IF(ALSOFT_BACKEND_PORTAUDIO)
944 SET(HAVE_PORTAUDIO 1)
945 SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
946 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
947 ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
948 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
949 INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
953 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
954 MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
957 # Check PulseAudio backend
958 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
959 FIND_PACKAGE(PulseAudio)
961 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
962 IF(ALSOFT_BACKEND_PULSEAUDIO)
963 SET(HAVE_PULSEAUDIO 1)
964 SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
965 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
966 ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
967 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
968 INCLUDE_DIRECTORIES(${PULSEAUDIO_INCLUDE_DIRS})
972 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
973 MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
977 OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
980 OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
981 IF(ALSOFT_BACKEND_JACK)
983 SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
984 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/jack.c)
985 ADD_BACKEND_LIBS(${JACK_LIBRARIES})
986 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
987 INCLUDE_DIRECTORIES(${JACK_INCLUDE_DIRS})
991 IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
992 MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
995 # Check CoreAudio backend
996 OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
997 FIND_LIBRARY(COREAUDIO_FRAMEWORK
999 PATHS /System/Library/Frameworks
1001 IF(COREAUDIO_FRAMEWORK)
1002 OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
1003 IF(ALSOFT_BACKEND_COREAUDIO)
1004 SET(HAVE_COREAUDIO 1)
1005 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c)
1006 SET(BACKENDS "${BACKENDS} CoreAudio,")
1007 SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
1008 SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
1009 SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
1011 # Some versions of OSX may need the AudioToolbox framework. Add it if
1013 FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
1015 PATHS ~/Library/Frameworks
1017 /System/Library/Frameworks
1019 IF(AUDIOTOOLBOX_LIBRARY)
1020 SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
1024 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
1025 MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
1028 # Check for OpenSL (Android) backend
1029 OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
1030 CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
1031 IF(HAVE_SLES_OPENSLES_ANDROID_H)
1032 CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
1033 IF(HAVE_LIBOPENSLES)
1034 OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
1035 IF(ALSOFT_BACKEND_OPENSL)
1037 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
1038 SET(BACKENDS "${BACKENDS} OpenSL,")
1039 SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
1043 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
1044 MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
1047 # Optionally enable the Wave Writer backend
1048 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
1049 IF(ALSOFT_BACKEND_WAVE)
1051 SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c)
1052 SET(BACKENDS "${BACKENDS} WaveFile,")
1055 # This is always available
1056 SET(BACKENDS "${BACKENDS} Null")
1058 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
1059 add_subdirectory(utils/alsoft-config)
1064 FIND_PACKAGE(SDL_sound)
1065 IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1066 INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
1068 FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
1069 IF(FFMPEG_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
1070 INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
1075 IF(LIBTYPE STREQUAL "STATIC")
1076 ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
1077 SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
1080 # Needed for openal.pc.in
1081 SET(prefix ${CMAKE_INSTALL_PREFIX})
1082 SET(exec_prefix "\${prefix}")
1083 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
1084 SET(bindir "\${exec_prefix}/bin")
1085 SET(includedir "\${prefix}/include")
1086 SET(PACKAGE_VERSION "${LIB_VERSION}")
1090 "${OpenAL_SOURCE_DIR}/config.h.in"
1091 "${OpenAL_BINARY_DIR}/config.h")
1093 "${OpenAL_SOURCE_DIR}/openal.pc.in"
1094 "${OpenAL_BINARY_DIR}/openal.pc"
1097 # Build a common library with reusable helpers
1098 ADD_LIBRARY(common STATIC ${COMMON_OBJS})
1099 IF(NOT LIBTYPE STREQUAL "STATIC")
1100 SET_PROPERTY(TARGET common PROPERTY POSITION_INDEPENDENT_CODE TRUE)
1103 # Build main library
1104 IF(LIBTYPE STREQUAL "STATIC")
1105 ADD_LIBRARY(${LIBNAME} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
1107 ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
1109 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
1110 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
1111 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
1113 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
1115 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
1118 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
1121 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
1124 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
1127 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
1130 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
1133 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
1136 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
1139 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
1141 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
1142 SOVERSION ${LIB_MAJOR_VERSION})
1143 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
1144 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
1146 IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
1147 FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
1148 FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
1149 IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
1151 IF(NOT SED_EXECUTABLE)
1152 MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
1154 IF(NOT DLLTOOL_EXECUTABLE)
1155 MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
1158 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--output-def,${LIBNAME}.def")
1159 ADD_CUSTOM_COMMAND(TARGET ${LIBNAME} POST_BUILD
1160 COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" ${LIBNAME}.def
1161 COMMAND "${DLLTOOL_EXECUTABLE}" -d ${LIBNAME}.def -l ${LIBNAME}.lib -D ${LIBNAME}.dll
1162 COMMENT "Stripping ordinals from ${LIBNAME}.def and generating ${LIBNAME}.lib..."
1169 TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
1172 # Add an install target here
1173 INSTALL(TARGETS ${LIBNAME}
1174 RUNTIME DESTINATION bin
1175 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1176 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1178 INSTALL(FILES include/AL/al.h
1182 include/AL/efx-creative.h
1183 include/AL/efx-presets.h
1184 DESTINATION include/AL
1186 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
1187 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
1192 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
1193 MESSAGE(STATUS " ${BACKENDS}")
1195 MESSAGE(STATUS "Building with support for CPU extensions:")
1196 MESSAGE(STATUS " ${CPU_EXTS}")
1201 MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
1202 MESSAGE(STATUS " This is probably NOT what you want!")
1207 # Install alsoft.conf configuration file
1209 INSTALL(FILES alsoftrc.sample
1210 DESTINATION ${SHARE_INSTALL_DIR}/openal
1212 MESSAGE(STATUS "Installing sample configuration")
1216 # Install HRTF definitions
1217 IF(ALSOFT_HRTF_DEFS)
1218 INSTALL(FILES hrtf/default-44100.mhr
1219 hrtf/default-48000.mhr
1220 DESTINATION ${SHARE_INSTALL_DIR}/openal/hrtf
1222 MESSAGE(STATUS "Installing HRTF definitions")
1227 ADD_EXECUTABLE(openal-info utils/openal-info.c)
1228 TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
1230 ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
1232 TARGET_LINK_LIBRARIES(makehrtf m)
1235 ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
1237 TARGET_LINK_LIBRARIES(bsincgen m)
1241 INSTALL(TARGETS openal-info makehrtf bsincgen
1242 RUNTIME DESTINATION bin
1243 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1244 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1248 MESSAGE(STATUS "Building utility programs")
1249 IF(TARGET alsoft-config)
1250 MESSAGE(STATUS "Building configuration program")
1256 ADD_LIBRARY(test-common STATIC examples/common/alhelpers.c)
1258 ADD_EXECUTABLE(altonegen examples/altonegen.c)
1259 TARGET_LINK_LIBRARIES(altonegen test-common ${LIBNAME})
1262 INSTALL(TARGETS altonegen
1263 RUNTIME DESTINATION bin
1264 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1265 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1269 MESSAGE(STATUS "Building test programs")
1274 IF(SDL2_FOUND AND SDL_SOUND_FOUND)
1275 ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1276 examples/common/sdl_sound.c)
1277 SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1278 ${SDL_SOUND_INCLUDE_DIR})
1280 ADD_EXECUTABLE(alstream examples/alstream.c)
1281 TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1283 SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1284 ${SDL_SOUND_INCLUDE_DIR})
1286 ADD_EXECUTABLE(alreverb examples/alreverb.c)
1287 TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1289 SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1290 ${SDL_SOUND_INCLUDE_DIR})
1292 ADD_EXECUTABLE(allatency examples/allatency.c)
1293 TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1295 SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1296 ${SDL_SOUND_INCLUDE_DIR})
1298 ADD_EXECUTABLE(alloopback examples/alloopback.c)
1299 TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1301 SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1302 ${SDL_SOUND_INCLUDE_DIR})
1304 ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
1305 TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
1307 SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1308 ${SDL_SOUND_INCLUDE_DIR})
1311 INSTALL(TARGETS alstream alreverb allatency alloopback alhrtf
1312 RUNTIME DESTINATION bin
1313 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1314 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1321 IF(AVFORMAT_VERSION VERSION_LESS "55.33.100")
1322 MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 55.33.100)")
1325 IF(AVCODEC_VERSION VERSION_LESS "55.52.102")
1326 MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 55.52.102)")
1329 IF(AVUTIL_VERSION VERSION_LESS "52.66.100")
1330 MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 52.66.100)")
1333 IF(SWSCALE_VERSION VERSION_LESS "2.5.102")
1334 MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 2.5.102)")
1337 IF(SWRESAMPLE_VERSION VERSION_LESS "0.18.100")
1338 MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 0.18.100)")
1342 IF(FFVER_OK AND NOT MSVC)
1343 ADD_EXECUTABLE(alffplay examples/alffplay.c)
1344 TARGET_LINK_LIBRARIES(alffplay common ex-common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
1345 SET_PROPERTY(TARGET alffplay APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
1346 ${FFMPEG_INCLUDE_DIRS})
1349 INSTALL(TARGETS alffplay
1350 RUNTIME DESTINATION bin
1351 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1352 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1355 MESSAGE(STATUS "Building SDL and FFmpeg example programs")
1357 MESSAGE(STATUS "Building SDL example programs")