Add an al_string type and use it for the device lists
[openal-soft.git] / CMakeLists.txt
blobcecb7e671599a82c2ed713f47644de1f3f34b56a
1 # CMake build file list for OpenAL
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
5 PROJECT(OpenAL)
7 IF(COMMAND CMAKE_POLICY)
8   CMAKE_POLICY(SET CMP0003 NEW)
9   CMAKE_POLICY(SET CMP0005 NEW)
10 ENDIF(COMMAND CMAKE_POLICY)
12 SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
14 INCLUDE(CheckFunctionExists)
15 INCLUDE(CheckLibraryExists)
16 INCLUDE(CheckSharedFunctionExists)
17 INCLUDE(CheckIncludeFile)
18 INCLUDE(CheckIncludeFiles)
19 INCLUDE(CheckSymbolExists)
20 INCLUDE(CheckCCompilerFlag)
21 INCLUDE(CheckCSourceCompiles)
22 INCLUDE(CheckTypeSize)
25 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
28 OPTION(ALSOFT_CPUEXT_SSE  "Check for SSE/SSE2 support" ON)
29 OPTION(ALSOFT_CPUEXT_NEON "Check for ARM Neon support" ON)
31 OPTION(ALSOFT_REQUIRE_SSE  "Require SSE/SSE2 support" OFF)
32 OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
34 IF(WIN32)
35     # This option is mainly for static linking OpenAL Soft into another project
36     # that already defines the IDs. It is up to that project to ensure all
37     # required IDs are defined.
38     OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
39 ENDIF()
42 OPTION(ALSOFT_BACKEND_ALSA    "Check for ALSA backend"                ON)
43 OPTION(ALSOFT_BACKEND_OSS     "Check for OSS backend"                 ON)
44 OPTION(ALSOFT_BACKEND_SOLARIS "Check for Solaris backend"             ON)
45 OPTION(ALSOFT_BACKEND_SNDIO   "Check for SndIO backend"               ON)
46 OPTION(ALSOFT_BACKEND_QSA     "Check for QSA backend"                 ON)
47 OPTION(ALSOFT_BACKEND_MMDEVAPI "Check for MMDevApi backend"           ON)
48 OPTION(ALSOFT_BACKEND_DSOUND   "Check for DirectSound backend"        ON)
49 OPTION(ALSOFT_BACKEND_WINMM    "Check for Windows Multimedia backend" ON)
50 OPTION(ALSOFT_BACKEND_PORTAUDIO  "Check for PortAudio backend"        ON)
51 OPTION(ALSOFT_BACKEND_PULSEAUDIO "Check for PulseAudio backend"       ON)
52 OPTION(ALSOFT_BACKEND_COREAUDIO  "Check for CoreAudio backend"        ON)
53 OPTION(ALSOFT_BACKEND_OPENSL     "Check for OpenSL backend"           ON)
54 OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend"               ON)
56 OPTION(ALSOFT_MIDI_FLUIDSYNTH "Check for FluidSynth MIDI"             ON)
58 OPTION(ALSOFT_REQUIRE_ALSA       "Require ALSA backend"               OFF)
59 OPTION(ALSOFT_REQUIRE_OSS        "Require OSS backend"                OFF)
60 OPTION(ALSOFT_REQUIRE_SOLARIS    "Require Solaris backend"            OFF)
61 OPTION(ALSOFT_REQUIRE_SNDIO      "Require SndIO backend"              OFF)
62 OPTION(ALSOFT_REQUIRE_QSA        "Require QSA backend"                OFF)
63 OPTION(ALSOFT_REQUIRE_MMDEVAPI   "Require MMDevApi"                   OFF)
64 OPTION(ALSOFT_REQUIRE_DSOUND     "Require DirectSound backend"        OFF)
65 OPTION(ALSOFT_REQUIRE_WINMM      "Require Windows Multimedia backend" OFF)
66 OPTION(ALSOFT_REQUIRE_PORTAUDIO  "Require PortAudio backend"          OFF)
67 OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend"         OFF)
68 OPTION(ALSOFT_REQUIRE_COREAUDIO  "Require CoreAudio backend"          OFF)
69 OPTION(ALSOFT_REQUIRE_OPENSL     "Require OpenSL backend"             OFF)
71 OPTION(ALSOFT_REQUIRE_FLUIDSYNTH "Require FluidSynth MIDI"            OFF)
73 OPTION(ALSOFT_DLOPEN  "Check for the dlopen API for loading optional libs"  ON)
75 OPTION(ALSOFT_WERROR  "Treat compile warnings as errors"      OFF)
77 OPTION(ALSOFT_UTILS          "Build and install utility programs"         ON)
78 OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
80 OPTION(ALSOFT_EXAMPLES  "Build and install example programs"  ON)
82 OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
83 OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
86 IF(WIN32)
87     SET(LIBNAME OpenAL32)
88     ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0501")
89 ELSE()
90     SET(LIBNAME openal)
91 ENDIF()
93 # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
94 IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
95     ADD_DEFINITIONS("-I/usr/include")
96     SET(EXTRA_LIBS ${EXTRA_LIBS} -L/usr/lib)
97 ENDIF()
99 IF(NOT LIBTYPE)
100     SET(LIBTYPE SHARED)
101 ENDIF()
103 SET(LIB_MAJOR_VERSION "1")
104 SET(LIB_MINOR_VERSION "15")
105 SET(LIB_REVISION "1")
106 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
108 SET(EXPORT_DECL "")
109 SET(ALIGN_DECL "")
112 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
113 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
116 CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
117 IF(HAVE_STD_C99)
118     SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
119 ENDIF()
121 # MSVC may need workarounds for C99 restrict and inline
122 IF(MSVC)
123     # TODO: Once we truly require C99, these restrict and inline checks should go
124     # away.
125     CHECK_C_SOURCE_COMPILES("int *restrict foo;
126                              int main() {return 0;}" HAVE_RESTRICT)
127     IF(NOT HAVE_RESTRICT)
128         ADD_DEFINITIONS("-Drestrict=")
129         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
130     ENDIF()
132     CHECK_C_SOURCE_COMPILES("inline void foo(void) { }
133                              int main() {return 0;}" HAVE_INLINE)
134     IF(NOT HAVE_INLINE)
135         CHECK_C_SOURCE_COMPILES("__inline void foo(void) { }
136                                  int main() {return 0;}" HAVE___INLINE)
137         IF(NOT HAVE___INLINE)
138             MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
139         ENDIF()
141         ADD_DEFINITIONS(-Dinline=__inline)
142         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
143     ENDIF()
144 ENDIF()
146 # Make sure we have C99-style inline semantics with GCC (4.3 or newer).
147 IF(CMAKE_COMPILER_IS_GNUCC)
148     SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
149     # Force no inlining for the next test.
150     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -fno-inline")
152     CHECK_C_SOURCE_COMPILES("extern inline int foo() { return 0; }
153                              int main() {return foo();}" INLINE_IS_C99)
154     IF(NOT INLINE_IS_C99)
155         MESSAGE(FATAL_ERROR "Your compiler does not seem to have C99 inline semantics!
156                              Please update your compiler for better C99 compliance.")
157     ENDIF()
159     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
160 ENDIF()
162 # Check if we have C99 variable length arrays
163 CHECK_C_SOURCE_COMPILES(
164 "int main(int argc, char *argv[])
166      volatile int tmp[argc];
167      tmp[0] = argv[0][0];
168      return tmp[0];
169  }"
170 HAVE_C99_VLA)
173 # Add definitions, compiler switches, etc.
174 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
175 IF(CMAKE_VERSION VERSION_LESS "2.8.8")
176     INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
177     IF(WIN32 AND ALSOFT_NO_UID_DEFS)
178         ADD_DEFINITIONS("-DAL_NO_UID_DEFS")
179     ENDIF()
180 ENDIF()
182 IF(NOT CMAKE_BUILD_TYPE)
183     SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
184         "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
185         FORCE)
186 ENDIF()
187 IF(NOT CMAKE_DEBUG_POSTFIX)
188     SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
189         "Library postfix for debug builds. Normally left blank."
190         FORCE)
191 ENDIF()
193 IF(MSVC)
194     # ???
195     SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
196     SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
197     SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
198     SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
199     ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
200     ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
201     ADD_DEFINITIONS("/wd4098")
203     IF(NOT DXSDK_DIR)
204         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
205     ELSE()
206         STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
207     ENDIF()
208     IF(DXSDK_DIR)
209         MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
210         SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
211         INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
212         LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
213     ENDIF()
215     OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
216     IF(FORCE_STATIC_VCRT)
217         FOREACH(flag_var
218                 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
219                 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
220             IF(${flag_var} MATCHES "/MD")
221                 STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
222             ENDIF()
223         ENDFOREACH(flag_var)
224     ENDIF()
225 ELSE()
226     ADD_DEFINITIONS(-Winline -Wall)
227     CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
228     IF(HAVE_W_EXTRA)
229         ADD_DEFINITIONS(-Wextra)
230     ENDIF()
232     IF(ALSOFT_WERROR)
233         ADD_DEFINITIONS(-Werror)
234     ENDIF()
236     SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
237         "Flags used by the compiler during Release with Debug Info builds."
238         FORCE)
239     SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
240         "Flags used by the compiler during release minsize builds."
241         FORCE)
242     SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
243         "Flags used by the compiler during release builds"
244         FORCE)
245     SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
246         "Flags used by the compiler during debug builds."
247         FORCE)
249     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
250                              int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
251 ENDIF()
253 # Set visibility/export options if available
254 IF(WIN32)
255     SET(EXPORT_DECL "__declspec(dllexport)")
256     IF(NOT MINGW)
257         SET(ALIGN_DECL "__declspec(align(x))")
258     ELSE()
259         SET(ALIGN_DECL "__declspec(aligned(x))")
260     ENDIF()
261 ELSE()
262     SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
263     # Yes GCC, really don't accept visibility modes you don't support
264     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
266     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
267                              int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
268     IF(HAVE_GCC_PROTECTED_VISIBILITY)
269         SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
270     ELSE()
271         CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
272                                  int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
273         IF(HAVE_GCC_DEFAULT_VISIBILITY)
274             SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
275         ENDIF()
276     ENDIF()
278     IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
279         CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
280         IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
281             ADD_DEFINITIONS(-fvisibility=internal)
282         ELSE()
283             CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
284             IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
285                 ADD_DEFINITIONS(-fvisibility=hidden)
286             ENDIF()
287         ENDIF()
288     ENDIF()
290     CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
291                              int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
292     IF(HAVE_ATTRIBUTE_ALIGNED)
293         SET(ALIGN_DECL "__attribute__((aligned(x)))")
294     ENDIF()
296     SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
297 ENDIF()
299 SET(SSE_SWITCH "")
300 IF(MSVC)
301     CHECK_C_COMPILER_FLAG(/arch:SSE HAVE_ARCHSSE_SWITCH)
302     IF(HAVE_ARCHSSE_SWITCH)
303         SET(SSE_SWITCH "/arch:SSE")
304     ENDIF()
305 ENDIF()
306 IF(NOT SSE_SWITCH)
307     CHECK_C_COMPILER_FLAG(-msse HAVE_MSSE_SWITCH)
308     IF(HAVE_MSSE_SWITCH)
309         SET(SSE_SWITCH "-msse")
310     ENDIF()
311 ENDIF()
313 CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
314                          int main() {return 0;}" HAVE_GCC_FORMAT)
316 IF(NOT HAVE_C99_VLA)
317     CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
318 ENDIF()
319 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
320 CHECK_INCLUDE_FILE(ftw.h HAVE_FTW_H)
321 CHECK_INCLUDE_FILE(io.h HAVE_IO_H)
322 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
323 CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
324 CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
325 CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
326 CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
327 CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
328 CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
329 IF(NOT HAVE_GUIDDEF_H)
330     CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
331 ENDIF()
333 # Some systems need libm for some of the following math functions to work
334 CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
335 IF(HAVE_LIBM)
336     SET(EXTRA_LIBS m ${EXTRA_LIBS})
337     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
338 ENDIF()
341 CHECK_SYMBOL_EXISTS(aligned_alloc    stdlib.h HAVE_ALIGNED_ALLOC)
342 CHECK_SYMBOL_EXISTS(posix_memalign   stdlib.h HAVE_POSIX_MEMALIGN)
343 CHECK_SYMBOL_EXISTS(_aligned_malloc  malloc.h HAVE__ALIGNED_MALLOC)
344 CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
345 IF(NOT HAVE_C99_VLA)
346     IF(HAVE_ALLOCA_H)
347         CHECK_SYMBOL_EXISTS(alloca alloca.h HAVE_ALLOCA)
348     ELSEIF(HAVE_MALLOC_H)
349         CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
350     ENDIF()
351     IF(NOT HAVE_ALLOCA)
352         CHECK_SYMBOL_EXISTS(_alloca malloc.h HAVE__ALLOCA)
353         IF(NOT HAVE__ALLOCA)
354             MESSAGE(FATAL_ERROR "No alloca function found, please report!")
355         ENDIF()
357         ADD_DEFINITIONS(-Dalloca=_alloca)
358     ENDIF()
359 ENDIF()
361 IF(HAVE_FLOAT_H)
362     CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
363     CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
364 ENDIF()
365 IF(HAVE_FTW_H)
366     CHECK_SYMBOL_EXISTS(ftw ftw.h HAVE_FTW)
367 ENDIF()
368 IF(HAVE_IO_H)
369     CHECK_SYMBOL_EXISTS(_wfindfirst io.h HAVE__WFINDFIRST)
370 ENDIF()
372 CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
373 CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
374 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
375 IF(NOT HAVE_STRCASECMP)
376     CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
377     IF(NOT HAVE__STRICMP)
378         MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
379     ENDIF()
381     ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
382 ENDIF()
384 CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
385 IF(NOT HAVE_STRNCASECMP)
386     CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
387     IF(NOT HAVE__STRNICMP)
388         MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
389     ENDIF()
391     ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
392 ENDIF()
394 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
395 IF(NOT HAVE_SNPRINTF)
396     CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
397     IF(NOT HAVE__SNPRINTF)
398         MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
399     ENDIF()
401     ADD_DEFINITIONS(-Dsnprintf=_snprintf)
402 ENDIF()
404 CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
405 IF(NOT HAVE_ISFINITE)
406     CHECK_FUNCTION_EXISTS(finite HAVE_FINITE)
407     IF(NOT HAVE_FINITE)
408         CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE)
409         IF(NOT HAVE__FINITE)
410             MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
411         ENDIF()
412         ADD_DEFINITIONS(-Disfinite=_finite)
413     ELSE()
414         ADD_DEFINITIONS(-Disfinite=finite)
415     ENDIF()
416 ENDIF()
418 CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
419 IF(NOT HAVE_ISNAN)
420     CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
421     IF(NOT HAVE__ISNAN)
422         MESSAGE(FATAL_ERROR "No isnan function found, please report!")
423     ENDIF()
425     ADD_DEFINITIONS(-Disnan=_isnan)
426 ENDIF()
429 # Check for the dlopen API (for dynamicly loading backend libs)
430 IF(ALSOFT_DLOPEN)
431     CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
432     IF(HAVE_DLFCN_H)
433         CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
434         IF(HAVE_LIBDL)
435             SET(EXTRA_LIBS dl ${EXTRA_LIBS})
436         ENDIF()
437     ENDIF()
438 ENDIF()
440 # Check if we have Windows headers
441 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501)
442 IF(NOT HAVE_WINDOWS_H)
443     # These are needed on some systems for extra features
444     ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700)
445     SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700")
447     CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
448     IF(NOT HAVE_GETTIMEOFDAY)
449         MESSAGE(FATAL_ERROR "No timing function found!")
450     ENDIF()
452     CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
453     IF(NOT HAVE_NANOSLEEP)
454         MESSAGE(FATAL_ERROR "No sleep function found!")
455     ENDIF()
457     # We need pthreads outside of Windows
458     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
459     IF(NOT HAVE_PTHREAD_H)
460         MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
461     ENDIF()
462     # Some systems need pthread_np.h to get recursive mutexes
463     CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
465     CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
466     IF(HAVE_PTHREAD)
467         ADD_DEFINITIONS(-pthread)
468         SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
469         SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
470     ENDIF()
472     CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
473     IF(HAVE_LIBPTHREAD)
474         SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
475     ENDIF()
477     CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
479     CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
480     IF(NOT HAVE_PTHREAD_SETNAME_NP)
481         CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
482     ENDIF()
484     CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
485     IF(HAVE_LIBRT)
486         SET(EXTRA_LIBS rt ${EXTRA_LIBS})
487     ENDIF()
488 ENDIF()
490 # Check for a 64-bit type
491 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
492 IF(NOT HAVE_STDINT_H)
493     IF(HAVE_WINDOWS_H)
494         CHECK_C_SOURCE_COMPILES("#define _WIN32_WINNT 0x0501
495                                  #include <windows.h>
496                                  __int64 foo;
497                                  int main() {return 0;}" HAVE___INT64)
498     ENDIF()
499     IF(NOT HAVE___INT64)
500         IF(NOT SIZEOF_LONG MATCHES "8")
501             IF(NOT SIZEOF_LONG_LONG MATCHES "8")
502                 MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
503             ENDIF()
504         ENDIF()
505     ENDIF()
506 ENDIF()
508 # Windows needs winmm for timeGetTime, even if the backend is disabled
509 CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
510 IF(HAVE_LIBWINMM)
511     SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
512     SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
513 ENDIF()
516 SET(OPENAL_OBJS  OpenAL32/alAuxEffectSlot.c
517                  OpenAL32/alBuffer.c
518                  OpenAL32/alEffect.c
519                  OpenAL32/alError.c
520                  OpenAL32/alExtension.c
521                  OpenAL32/alFilter.c
522                  OpenAL32/alFontsound.c
523                  OpenAL32/alListener.c
524                  OpenAL32/alMidi.c
525                  OpenAL32/alPreset.c
526                  OpenAL32/alSoundfont.c
527                  OpenAL32/alSource.c
528                  OpenAL32/alState.c
529                  OpenAL32/alThunk.c
530                  OpenAL32/sample_cvt.c
532 SET(ALC_OBJS  Alc/ALc.c
533               Alc/ALu.c
534               Alc/alcConfig.c
535               Alc/alcRing.c
536               Alc/bs2b.c
537               Alc/effects/autowah.c
538               Alc/effects/chorus.c
539               Alc/effects/compressor.c
540               Alc/effects/dedicated.c
541               Alc/effects/distortion.c
542               Alc/effects/echo.c
543               Alc/effects/equalizer.c
544               Alc/effects/flanger.c
545               Alc/effects/modulator.c
546               Alc/effects/null.c
547               Alc/effects/reverb.c
548               Alc/helpers.c
549               Alc/hrtf.c
550               Alc/panning.c
551               Alc/threads.c
552               Alc/mixer.c
553               Alc/mixer_c.c
557 SET(CPU_EXTS "Default")
558 SET(HAVE_SSE  0)
559 SET(HAVE_NEON 0)
561 # Check for SSE support
562 IF(ALSOFT_CPUEXT_SSE AND ALIGN_DECL)
563     CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE_SWITCH}")
564     IF(HAVE_XMMINTRIN_H)
565         SET(HAVE_SSE 1)
566         SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_sse.c)
567         IF(SSE_SWITCH)
568             SET_SOURCE_FILES_PROPERTIES(Alc/mixer_sse.c PROPERTIES
569                                         COMPILE_FLAGS "${SSE_SWITCH}")
570         ENDIF()
571         SET(CPU_EXTS "${CPU_EXTS}, SSE")
572     ENDIF()
573 ENDIF()
574 IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
575     MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
576 ENDIF()
578 # Check for ARM Neon support
579 IF(ALSOFT_CPUEXT_NEON)
580     CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
581     IF(HAVE_ARM_NEON_H)
582         SET(HAVE_NEON 1)
583         SET(ALC_OBJS  ${ALC_OBJS} Alc/mixer_neon.c)
584         SET(CPU_EXTS "${CPU_EXTS}, Neon")
585     ENDIF()
586 ENDIF()
587 IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
588     MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
589 ENDIF()
592 SET(ALC_OBJS  ${ALC_OBJS}
593               Alc/midi/base.c
594               Alc/midi/sf2load.c
595               Alc/midi/dummy.c
596               Alc/midi/fluidsynth.c
597               Alc/midi/soft.c
600 SET(HAVE_FLUIDSYNTH  0)
602 # Check for FluidSynth support
603 IF(ALSOFT_MIDI_FLUIDSYNTH)
604     FIND_PACKAGE(FluidSynth)
605     IF(FLUIDSYNTH_FOUND)
606         SET(HAVE_FLUIDSYNTH 1)
607         IF(CMAKE_VERSION VERSION_LESS "2.8.8")
608             INCLUDE_DIRECTORIES(${FLUIDSYNTH_INCLUDE_DIR})
609         ENDIF()
610         SET(EXTRA_LIBS ${FLUIDSYNTH_LIBRARIES} ${EXTRA_LIBS})
611     ENDIF()
612 ENDIF()
613 IF(ALSOFT_REQUIRE_FLUIDSYNTH AND NOT HAVE_FLUIDSYNTH)
614     MESSAGE(FATAL_ERROR "Failed to enabled required FluidSynth support")
615 ENDIF()
618 SET(ALC_OBJS  ${ALC_OBJS}
619               Alc/backends/base.c
620               # Default backends, always available
621               Alc/backends/loopback.c
622               Alc/backends/null.c
625 SET(BACKENDS "")
626 SET(HAVE_ALSA       0)
627 SET(HAVE_OSS        0)
628 SET(HAVE_SOLARIS    0)
629 SET(HAVE_SNDIO      0)
630 SET(HAVE_QSA        0)
631 SET(HAVE_DSOUND     0)
632 SET(HAVE_MMDEVAPI   0)
633 SET(HAVE_WINMM      0)
634 SET(HAVE_PORTAUDIO  0)
635 SET(HAVE_PULSEAUDIO 0)
636 SET(HAVE_COREAUDIO  0)
637 SET(HAVE_OPENSL     0)
638 SET(HAVE_WAVE       0)
640 # Check ALSA backend
641 IF(ALSOFT_BACKEND_ALSA)
642     CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
643     IF(HAVE_ALSA_ASOUNDLIB_H)
644         CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND)
645         IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
646             SET(HAVE_ALSA 1)
647             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/alsa.c)
648             IF(HAVE_DLFCN_H OR WIN32)
649                 SET(BACKENDS  "${BACKENDS} ALSA,")
650             ELSE()
651                 SET(BACKENDS  "${BACKENDS} ALSA \(linked\),")
652                 SET(EXTRA_LIBS asound ${EXTRA_LIBS})
653             ENDIF()
654         ENDIF()
655     ENDIF()
656 ENDIF()
657 IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
658     MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
659 ENDIF()
661 # Check OSS backend
662 IF(ALSOFT_BACKEND_OSS)
663     CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
664     IF(HAVE_SYS_SOUNDCARD_H)
665         SET(HAVE_OSS 1)
666         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/oss.c)
667         SET(BACKENDS  "${BACKENDS} OSS,")
668     ENDIF()
669 ENDIF()
670 IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
671     MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
672 ENDIF()
674 # Check Solaris backend
675 IF(ALSOFT_BACKEND_SOLARIS)
676     CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
677     IF(HAVE_SYS_AUDIOIO_H)
678         SET(HAVE_SOLARIS 1)
679         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/solaris.c)
680         SET(BACKENDS  "${BACKENDS} Solaris,")
681     ENDIF()
682 ENDIF()
683 IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
684     MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
685 ENDIF()
687 # Check SndIO backend
688 IF(ALSOFT_BACKEND_SNDIO)
689     CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H)
690     IF(HAVE_SNDIO_H)
691         CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO)
692         IF(HAVE_LIBSNDIO)
693             SET(HAVE_SNDIO 1)
694             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/sndio.c)
695             SET(BACKENDS  "${BACKENDS} SndIO \(linked\),")
696             SET(EXTRA_LIBS sndio ${EXTRA_LIBS})
697         ENDIF()
698     ENDIF()
699 ENDIF()
700 IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
701     MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
702 ENDIF()
704 # Check QSA backend
705 IF (ALSOFT_BACKEND_QSA AND "${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
706     CHECK_INCLUDE_FILE(sys/asoundlib.h HAVE_SYS_ASOUNDLIB_H)
707     IF(HAVE_SYS_ASOUNDLIB_H)
708         CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "sys/asoundlib.h" asound "" HAVE_LIBASOUND)
709         IF(HAVE_LIBASOUND)
710             SET(HAVE_QSA 1)
711             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/qsa.c)
712             SET(EXTRA_LIBS asound ${EXTRA_LIBS})
713             SET(BACKENDS  "${BACKENDS} QSA \(linked\),")
714         ENDIF()
715     ENDIF()
716 ENDIF()
717 IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
718     MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
719 ENDIF()
721 # Check for MMDevApi backend
722 IF(HAVE_WINDOWS_H)
723     IF(ALSOFT_BACKEND_MMDEVAPI)
724         CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
725         IF(HAVE_MMDEVICEAPI_H)
726             SET(HAVE_MMDEVAPI 1)
727             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/mmdevapi.c)
729             SET(BACKENDS  "${BACKENDS} MMDevApi,")
730         ENDIF()
731     ENDIF()
732 ENDIF()
733 IF(ALSOFT_REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI)
734     MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend")
735 ENDIF()
737 # Check DSound/MMSystem backend
738 IF(ALSOFT_BACKEND_DSOUND)
739     CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
740     IF(HAVE_DSOUND_H)
741         CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND)
742         IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
743             SET(HAVE_DSOUND 1)
744             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/dsound.c)
746             IF(HAVE_DLFCN_H OR WIN32)
747                 SET(BACKENDS  "${BACKENDS} DirectSound,")
748             ELSE()
749                 SET(BACKENDS  "${BACKENDS} DirectSound \(linked\),")
750                 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
751             ENDIF()
752         ENDIF()
753     ENDIF()
754 ENDIF()
755 IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
756     MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
757 ENDIF()
759 IF(HAVE_WINDOWS_H)
760     IF(ALSOFT_BACKEND_WINMM)
761         CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0501)
762         IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
763             SET(HAVE_WINMM 1)
764             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/winmm.c)
765             SET(BACKENDS  "${BACKENDS} WinMM,")
766         ENDIF()
767     ENDIF()
768 ENDIF()
769 IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
770     MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
771 ENDIF()
773 # Check PortAudio backend
774 IF(ALSOFT_BACKEND_PORTAUDIO)
775     CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
776     IF(HAVE_PORTAUDIO_H)
777         CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO)
778         IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
779             SET(HAVE_PORTAUDIO 1)
780             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/portaudio.c)
781             IF(HAVE_DLFCN_H OR WIN32)
782                 SET(BACKENDS  "${BACKENDS} PortAudio,")
783             ELSE()
784                 SET(BACKENDS  "${BACKENDS} PortAudio \(linked\),")
785                 SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
786             ENDIF()
787         ENDIF()
788     ENDIF()
789 ENDIF()
790 IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
791     MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
792 ENDIF()
794 # Check PulseAudio backend
795 IF(ALSOFT_BACKEND_PULSEAUDIO)
796     CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
797     IF(HAVE_PULSE_PULSEAUDIO_H)
798         CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE)
799         IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
800             SET(HAVE_PULSEAUDIO 1)
801             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/pulseaudio.c)
802             IF(HAVE_DLFCN_H OR WIN32)
803                 SET(BACKENDS  "${BACKENDS} PulseAudio,")
804             ELSE()
805                 SET(BACKENDS  "${BACKENDS} PulseAudio \(linked\),")
806                 SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
807             ENDIF()
808         ENDIF()
809     ENDIF()
810 ENDIF()
811 IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
812     MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
813 ENDIF()
815 # Check CoreAudio backend
816 IF(ALSOFT_BACKEND_COREAUDIO)
817     CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK)
818     IF(HAVE_COREAUDIO_FRAMEWORK)
819         SET(HAVE_COREAUDIO 1)
820         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/coreaudio.c)
821         SET(BACKENDS  "${BACKENDS} CoreAudio,")
822         SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS})
823         SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
824         SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
826         # Some versions of OSX may need the AudioToolbox framework. Add it if
827         # it's found.
828         FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
829                      NAMES AudioToolbox
830                      PATHS ~/Library/Frameworks
831                            /Library/Frameworks
832                            /System/Library/Frameworks
833                     )
834         IF(AUDIOTOOLBOX_LIBRARY)
835             SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
836         ENDIF()
837     ENDIF()
838 ENDIF()
839 IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
840     MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
841 ENDIF()
843 # Check for OpenSL (Android) backend
844 IF(ALSOFT_BACKEND_OPENSL)
845     CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
846     IF(HAVE_SLES_OPENSLES_ANDROID_H)
847         CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
848         IF(HAVE_LIBOPENSLES)
849             SET(HAVE_OPENSL 1)
850             SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/opensl.c)
851             SET(BACKENDS  "${BACKENDS} OpenSL,")
852             SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
853         ENDIF()
854     ENDIF()
855 ENDIF()
856 IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
857     MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
858 ENDIF()
860 # Optionally enable the Wave Writer backend
861 IF(ALSOFT_BACKEND_WAVE)
862     SET(HAVE_WAVE 1)
863     SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/wave.c)
864     SET(BACKENDS  "${BACKENDS} WaveFile,")
865 ENDIF()
867 # This is always available
868 SET(BACKENDS  "${BACKENDS} Null")
870 IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
871     add_subdirectory(utils/alsoft-config)
872 ENDIF()
873 IF(ALSOFT_EXAMPLES)
874     FIND_PACKAGE(SDL)
875     IF(SDL_FOUND)
876         FIND_PACKAGE(SDL_sound)
877         IF(SDL_SOUND_FOUND AND CMAKE_VERSION VERSION_LESS "2.8.8")
878             INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
879         ENDIF()
880     ENDIF()
881 ENDIF()
883 IF(LIBTYPE STREQUAL "STATIC")
884     ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
885     SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
886 ENDIF()
888 # Needed for openal.pc.in
889 SET(prefix ${CMAKE_INSTALL_PREFIX})
890 SET(exec_prefix "\${prefix}")
891 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
892 SET(bindir "\${exec_prefix}/bin")
893 SET(includedir "\${prefix}/include")
894 SET(PACKAGE_VERSION "${LIB_VERSION}")
896 # End configuration
897 CONFIGURE_FILE(
898     "${OpenAL_SOURCE_DIR}/config.h.in"
899     "${OpenAL_BINARY_DIR}/config.h")
900 CONFIGURE_FILE(
901     "${OpenAL_SOURCE_DIR}/openal.pc.in"
902     "${OpenAL_BINARY_DIR}/openal.pc"
903     @ONLY)
905 # Build a library
906 ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
907 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
908 IF(WIN32 AND ALSOFT_NO_UID_DEFS)
909     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
910 ENDIF()
911 SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
912 IF(FLUIDSYNTH_FOUND)
913     SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${FLUIDSYNTH_INCLUDE_DIR})
914 ENDIF()
915 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
916                                             SOVERSION ${LIB_MAJOR_VERSION})
917 IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
918     SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
919 ENDIF()
921 TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
923 # Add an install target here
924 INSTALL(TARGETS ${LIBNAME}
925         RUNTIME DESTINATION bin
926         LIBRARY DESTINATION "lib${LIB_SUFFIX}"
927         ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
929 INSTALL(FILES include/AL/al.h
930               include/AL/alc.h
931               include/AL/alext.h
932               include/AL/efx.h
933               include/AL/efx-creative.h
934               include/AL/efx-presets.h
935         DESTINATION include/AL
937 INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
938         DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
941 MESSAGE(STATUS "")
942 MESSAGE(STATUS "Building OpenAL with support for the following backends:")
943 MESSAGE(STATUS "    ${BACKENDS}")
944 MESSAGE(STATUS "")
945 MESSAGE(STATUS "Building with support for CPU extensions:")
946 MESSAGE(STATUS "    ${CPU_EXTS}")
947 MESSAGE(STATUS "")
948 IF(HAVE_FLUIDSYNTH)
949     MESSAGE(STATUS "FluidSynth support for ALC_SOFT_midi_interface enabled")
950     MESSAGE(STATUS "")
951 ENDIF()
953 IF(WIN32)
954     IF(NOT HAVE_DSOUND)
955         MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
956         MESSAGE(STATUS "         This is probably NOT what you want!")
957         MESSAGE(STATUS "")
958     ENDIF()
959 ENDIF()
961 # Install alsoft.conf configuration file
962 IF(ALSOFT_CONFIG)
963     INSTALL(FILES alsoftrc.sample
964             DESTINATION share/openal
965     )
966     MESSAGE(STATUS "Installing sample configuration")
967     MESSAGE(STATUS "")
968 ENDIF()
970 # Install HRTF definitions
971 IF(ALSOFT_HRTF_DEFS)
972     INSTALL(FILES hrtf/default-44100.mhr
973             DESTINATION share/openal/hrtf
974     )
975     MESSAGE(STATUS "Installing HRTF definitions")
976     MESSAGE(STATUS "")
977 ENDIF()
979 IF(ALSOFT_UTILS)
980     ADD_EXECUTABLE(openal-info utils/openal-info.c)
981     TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
983     ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
984     IF(HAVE_LIBM)
985         TARGET_LINK_LIBRARIES(makehrtf m)
986     ENDIF()
988     INSTALL(TARGETS openal-info makehrtf
989             RUNTIME DESTINATION bin
990             LIBRARY DESTINATION "lib${LIB_SUFFIX}"
991             ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
992     )
994     MESSAGE(STATUS "Building utility programs")
995     IF(TARGET alsoft-config)
996         MESSAGE(STATUS "Building configuration program")
997     ENDIF()
998     MESSAGE(STATUS "")
999 ENDIF()
1001 IF(ALSOFT_EXAMPLES)
1002     IF(SDL_FOUND AND SDL_SOUND_FOUND)
1003         ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
1004                                      examples/common/sdl_sound.c)
1005         SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1007         ADD_EXECUTABLE(alstream examples/alstream.c)
1008         TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1009         SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1011         ADD_EXECUTABLE(alreverb examples/alreverb.c)
1012         TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1013         SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1015         ADD_EXECUTABLE(allatency examples/allatency.c)
1016         TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${LIBNAME})
1017         SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_SOUND_INCLUDE_DIR})
1019         ADD_EXECUTABLE(alloopback examples/alloopback.c)
1020         TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL_LIBRARY} ${LIBNAME})
1021         SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL_INCLUDE_DIR}
1022                                                                            ${SDL_SOUND_INCLUDE_DIR})
1024         INSTALL(TARGETS alstream alreverb allatency alloopback
1025                 RUNTIME DESTINATION bin
1026                 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
1027                 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
1028         )
1030         MESSAGE(STATUS "Building example programs")
1031         MESSAGE(STATUS "")
1032     ENDIF()
1033 ENDIF()