forked from kcat/openal-soft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1665 lines (1486 loc) · 55.7 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# CMake build file list for OpenAL
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)
PROJECT(OpenAL)
IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0005 NEW)
IF(POLICY CMP0020)
CMAKE_POLICY(SET CMP0020 NEW)
ENDIF(POLICY CMP0020)
IF(POLICY CMP0042)
CMAKE_POLICY(SET CMP0042 NEW)
ENDIF(POLICY CMP0042)
IF(POLICY CMP0054)
CMAKE_POLICY(SET CMP0054 NEW)
ENDIF(POLICY CMP0054)
IF(POLICY CMP0075)
CMAKE_POLICY(SET CMP0075 NEW)
ENDIF(POLICY CMP0075)
ENDIF(COMMAND CMAKE_POLICY)
SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
INCLUDE(CheckFunctionExists)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckCCompilerFlag)
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckTypeSize)
include(CheckStructHasMember)
include(CheckFileOffsetBits)
include(GNUInstallDirs)
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
OPTION(ALSOFT_TESTS "Build and install test programs" ON)
OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
if(DEFINED SHARE_INSTALL_DIR)
message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
endif()
if(DEFINED LIB_SUFFIX)
message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
endif()
SET(CPP_DEFS ) # C pre-process, not C++
SET(INC_PATHS )
SET(C_FLAGS )
SET(LINKER_FLAGS )
SET(EXTRA_LIBS )
IF(WIN32)
SET(CPP_DEFS ${CPP_DEFS} _WIN32 _WIN32_WINNT=0x0502)
OPTION(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
# This option is mainly for static linking OpenAL Soft into another project
# that already defines the IDs. It is up to that project to ensure all
# required IDs are defined.
OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
IF(MINGW)
OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
IF(NOT DLLTOOL)
IF(HOST)
SET(DLLTOOL "${HOST}-dlltool")
ELSE()
SET(DLLTOOL "dlltool")
ENDIF()
ENDIF()
ENDIF()
ENDIF()
# QNX's gcc do not uses /usr/include and /usr/lib pathes by default
IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
SET(INC_PATHS ${INC_PATHS} /usr/include)
SET(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
ENDIF()
IF(NOT LIBTYPE)
SET(LIBTYPE SHARED)
ENDIF()
SET(LIB_MAJOR_VERSION "1")
SET(LIB_MINOR_VERSION "19")
SET(LIB_REVISION "1")
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
SET(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0)
SET(EXPORT_DECL "")
CHECK_TYPE_SIZE("long" SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
# Require C++11
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Prefer C11, but support C99 and C90 too.
SET(CMAKE_C_STANDARD 11)
if(NOT WIN32)
# Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600")
CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
ELSE()
SET(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600)
ENDIF()
ENDIF()
UNSET(OLD_REQUIRED_FLAGS)
ENDIF()
# Set defines for large file support. Don't set this for Android targets. See:
# https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
IF(NOT ANDROID)
CHECK_FILE_OFFSET_BITS()
IF(_FILE_OFFSET_BITS)
SET(CPP_DEFS ${CPP_DEFS} "_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
ENDIF()
SET(CPP_DEFS ${CPP_DEFS} _LARGEFILE_SOURCE _LARGE_FILES)
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
ENDIF()
# C99 has restrict, but C++ does not, so we can only utilize __restrict.
SET(RESTRICT_DECL )
CHECK_C_SOURCE_COMPILES("int *__restrict foo;
int main() {return 0;}" HAVE___RESTRICT)
IF(HAVE___RESTRICT)
SET(RESTRICT_DECL "__restrict")
ENDIF()
# Some systems may need libatomic for C11 atomic functions to work
SET(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
SET(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
CHECK_C_SOURCE_COMPILES("#include <stdatomic.h>
int _Atomic foo = ATOMIC_VAR_INIT(0);
int main()
{
return atomic_fetch_add(&foo, 2);
}"
HAVE_LIBATOMIC)
IF(NOT HAVE_LIBATOMIC)
SET(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
ELSE()
SET(EXTRA_LIBS atomic ${EXTRA_LIBS})
ENDIF()
UNSET(OLD_REQUIRED_LIBRARIES)
# Include liblog for Android logging
CHECK_LIBRARY_EXISTS(log __android_log_print "" HAVE_LIBLOG)
IF(HAVE_LIBLOG)
SET(EXTRA_LIBS log ${EXTRA_LIBS})
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
ENDIF()
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF()
IF(NOT CMAKE_DEBUG_POSTFIX)
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
"Library postfix for debug builds. Normally left blank."
FORCE)
ENDIF()
IF(MSVC)
SET(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS NOMINMAX)
SET(C_FLAGS ${C_FLAGS} /wd4065 /wd4200)
IF(NOT DXSDK_DIR)
STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
ELSE()
STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
ENDIF()
IF(DXSDK_DIR)
MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
ENDIF()
OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
IF(FORCE_STATIC_VCRT)
FOREACH(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF()
ENDFOREACH(flag_var)
ENDIF()
ELSE()
SET(C_FLAGS ${C_FLAGS} -Winline -Wall)
CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
IF(HAVE_W_EXTRA)
SET(C_FLAGS ${C_FLAGS} -Wextra)
ENDIF()
IF(ALSOFT_WERROR)
SET(C_FLAGS ${C_FLAGS} -Werror)
ENDIF()
# We want RelWithDebInfo to actually include debug stuff (define _DEBUG
# instead of NDEBUG)
FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
IF(${flag_var} MATCHES "-DNDEBUG")
STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
ENDIF()
ENDFOREACH()
CHECK_C_COMPILER_FLAG(-fno-math-errno HAVE_FNO_MATH_ERRNO)
IF(HAVE_FNO_MATH_ERRNO)
SET(C_FLAGS ${C_FLAGS} -fno-math-errno)
ENDIF()
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
if(ALSOFT_STATIC_LIBGCC)
set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
check_c_source_compiles(
"#include <stdlib.h>
int main()
{
return 0;
}"
HAVE_STATIC_LIBGCC_SWITCH
)
set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
unset(OLD_REQUIRED_LIBRARIES)
if(NOT HAVE_STATIC_LIBGCC_SWITCH)
message(FATAL_ERROR "Cannot static link libgcc")
endif()
set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
endif()
option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF)
if(ALSOFT_STATIC_STDCXX)
set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
check_cxx_source_compiles(
"#include <cstdlib>
int main()
{
return 0;
}"
HAVE_STATIC_LIBSTDCXX_SWITCH
)
set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
unset(OLD_REQUIRED_LIBRARIES)
if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH)
message(FATAL_ERROR "Cannot static link libstdc++")
endif()
set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
endif()
if(WIN32)
option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
if(ALSOFT_STATIC_WINPTHREAD)
set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
check_cxx_source_compiles(
"#include <cstdlib>
int main()
{
return 0;
}"
HAVE_STATIC_LIBWINPTHREAD_SWITCH
)
set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
unset(OLD_REQUIRED_LIBRARIES)
if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
message(FATAL_ERROR "Cannot static link libwinpthread")
endif()
set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
endif()
endif()
ENDIF()
# Set visibility/export options if available
IF(WIN32)
SET(EXPORT_DECL "__declspec(dllexport)")
ELSE()
SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
# Yes GCC, really don't accept visibility modes you don't support
SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
IF(HAVE_GCC_PROTECTED_VISIBILITY)
SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
ELSE()
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
IF(HAVE_GCC_DEFAULT_VISIBILITY)
SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
ENDIF()
ENDIF()
IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
SET(C_FLAGS ${C_FLAGS} -fvisibility=hidden)
ENDIF()
ENDIF()
SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
ENDIF()
SET(SSE2_SWITCH "")
SET(SSE3_SWITCH "")
SET(SSE4_1_SWITCH "")
SET(FPU_NEON_SWITCH "")
CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
IF(HAVE_MSSE2_SWITCH)
SET(SSE2_SWITCH "-msse2")
ENDIF()
CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
IF(HAVE_MSSE3_SWITCH)
SET(SSE3_SWITCH "-msse3")
ENDIF()
CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
IF(HAVE_MSSE4_1_SWITCH)
SET(SSE4_1_SWITCH "-msse4.1")
ENDIF()
CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_MFPU_NEON_SWITCH)
IF(HAVE_MFPU_NEON_SWITCH)
SET(FPU_NEON_SWITCH "-mfpu=neon")
ENDIF()
CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}")
CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}")
SET(SSE_FLAGS )
SET(FPMATH_SET "0")
IF(CMAKE_SIZEOF_VOID_P MATCHES "4")
IF(SSE2_SWITCH OR MSVC)
OPTION(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
ENDIF()
IF(ALSOFT_ENABLE_SSE2_CODEGEN)
IF(SSE2_SWITCH)
CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
IF(HAVE_MFPMATH_SSE_2)
SET(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
SET(FPMATH_SET 2)
ENDIF()
ELSEIF(MSVC)
CHECK_C_COMPILER_FLAG("/arch:SSE2" HAVE_ARCH_SSE2)
IF(HAVE_ARCH_SSE2)
SET(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
SET(FPMATH_SET 2)
ENDIF()
ENDIF()
ENDIF()
ENDIF()
IF(HAVE_EMMINTRIN_H)
SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
FOREACH(flag_var ${SSE_FLAGS})
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
ENDFOREACH()
CHECK_C_SOURCE_COMPILES("#include <emmintrin.h>
int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
ENDIF()
CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
int main() {return 0;}" HAVE_GCC_FORMAT)
CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
IF(NOT HAVE_GUIDDEF_H)
CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
ENDIF()
# Some systems need libm for some of the following math functions to work
SET(MATH_LIB )
CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
IF(HAVE_LIBM)
SET(MATH_LIB ${MATH_LIB} m)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
ENDIF()
# Check for the dlopen API (for dynamicly loading backend libs)
IF(ALSOFT_DLOPEN)
CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
IF(HAVE_LIBDL)
SET(EXTRA_LIBS dl ${EXTRA_LIBS})
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
ENDIF()
CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
ENDIF()
# Check for a cpuid intrinsic
IF(HAVE_CPUID_H)
CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
int main()
{
unsigned int eax, ebx, ecx, edx;
return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
}" HAVE_GCC_GET_CPUID)
ENDIF()
IF(HAVE_INTRIN_H)
CHECK_C_SOURCE_COMPILES("#include <intrin.h>
int main()
{
int regs[4];
__cpuid(regs, 0);
return regs[0];
}" HAVE_CPUID_INTRINSIC)
CHECK_C_SOURCE_COMPILES("#include <intrin.h>
int main()
{
unsigned long idx = 0;
_BitScanForward64(&idx, 1);
return idx;
}" HAVE_BITSCANFORWARD64_INTRINSIC)
CHECK_C_SOURCE_COMPILES("#include <intrin.h>
int main()
{
unsigned long idx = 0;
_BitScanForward(&idx, 1);
return idx;
}" HAVE_BITSCANFORWARD_INTRINSIC)
ENDIF()
CHECK_SYMBOL_EXISTS(sysconf unistd.h HAVE_SYSCONF)
CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
CHECK_SYMBOL_EXISTS(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
IF(NOT HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
IF(NOT HAVE__STRICMP)
MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
ENDIF()
SET(CPP_DEFS ${CPP_DEFS} strcasecmp=_stricmp)
ENDIF()
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
IF(NOT HAVE_STRNCASECMP)
CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
IF(NOT HAVE__STRNICMP)
MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
ENDIF()
SET(CPP_DEFS ${CPP_DEFS} strncasecmp=_strnicmp)
ENDIF()
# Check if we have Windows headers
SET(OLD_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0502)
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_REQUIRED_DEFINITIONS})
UNSET(OLD_REQUIRED_DEFINITIONS)
IF(NOT HAVE_WINDOWS_H)
CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
IF(NOT HAVE_GETTIMEOFDAY)
MESSAGE(FATAL_ERROR "No timing function found!")
ENDIF()
CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
IF(NOT HAVE_NANOSLEEP)
MESSAGE(FATAL_ERROR "No sleep function found!")
ENDIF()
# We need pthreads outside of Windows
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
IF(NOT HAVE_PTHREAD_H)
MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
ENDIF()
# Some systems need pthread_np.h to get recursive mutexes
CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
IF(HAVE_PTHREAD)
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
SET(C_FLAGS ${C_FLAGS} -pthread)
SET(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
ENDIF()
CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
IF(HAVE_LIBPTHREAD)
SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
ENDIF()
CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
IF(HAVE_PTHREAD_NP_H)
CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
IF(NOT HAVE_PTHREAD_SETNAME_NP)
CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
ELSE()
CHECK_C_SOURCE_COMPILES("
#include <pthread.h>
#include <pthread_np.h>
int main()
{
pthread_setname_np(\"testname\");
return 0;
}"
PTHREAD_SETNAME_NP_ONE_PARAM
)
CHECK_C_SOURCE_COMPILES("
#include <pthread.h>
#include <pthread_np.h>
int main()
{
pthread_setname_np(pthread_self(), \"%s\", \"testname\");
return 0;
}"
PTHREAD_SETNAME_NP_THREE_PARAMS
)
ENDIF()
ELSE()
CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
IF(NOT HAVE_PTHREAD_SETNAME_NP)
CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
ELSE()
CHECK_C_SOURCE_COMPILES("
#include <pthread.h>
int main()
{
pthread_setname_np(\"testname\");
return 0;
}"
PTHREAD_SETNAME_NP_ONE_PARAM
)
CHECK_C_SOURCE_COMPILES("
#include <pthread.h>
int main()
{
pthread_setname_np(pthread_self(), \"%s\", \"testname\");
return 0;
}"
PTHREAD_SETNAME_NP_THREE_PARAMS
)
ENDIF()
ENDIF()
CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
IF(HAVE_LIBRT)
SET(EXTRA_LIBS rt ${EXTRA_LIBS})
ENDIF()
ENDIF()
CHECK_SYMBOL_EXISTS(getopt unistd.h HAVE_GETOPT)
# Check for a 64-bit type
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
IF(NOT HAVE_STDINT_H)
IF(NOT SIZEOF_LONG MATCHES "8")
IF(NOT SIZEOF_LONG_LONG MATCHES "8")
MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
ENDIF()
ENDIF()
ENDIF()
# Common sources used by both the OpenAL implementation library and potentially
# the OpenAL router.
SET(COMMON_OBJS
common/albyte.h
common/alcomplex.cpp
common/alcomplex.h
common/alexcpt.cpp
common/alexcpt.h
common/almalloc.cpp
common/almalloc.h
common/alnumeric.h
common/aloptional.h
common/alspan.h
common/atomic.h
common/math_defs.h
common/opthelpers.h
common/threads.cpp
common/threads.h
common/vecmat.h
)
SET(OPENAL_OBJS
OpenAL32/Include/alMain.h
OpenAL32/Include/alu.h
OpenAL32/Include/alAuxEffectSlot.h
OpenAL32/alAuxEffectSlot.cpp
OpenAL32/Include/alBuffer.h
OpenAL32/alBuffer.cpp
OpenAL32/Include/alEffect.h
OpenAL32/alEffect.cpp
OpenAL32/Include/alError.h
OpenAL32/alError.cpp
OpenAL32/alExtension.cpp
OpenAL32/Include/alFilter.h
OpenAL32/alFilter.cpp
OpenAL32/Include/alListener.h
OpenAL32/alListener.cpp
OpenAL32/Include/alSource.h
OpenAL32/alSource.cpp
OpenAL32/alState.cpp
OpenAL32/event.cpp
OpenAL32/Include/sample_cvt.h
OpenAL32/sample_cvt.cpp
)
SET(ALC_OBJS
Alc/alc.cpp
Alc/alu.cpp
Alc/alconfig.cpp
Alc/alconfig.h
Alc/alcontext.h
Alc/ambidefs.h
Alc/bs2b.cpp
Alc/bs2b.h
Alc/converter.cpp
Alc/converter.h
Alc/inprogext.h
Alc/mastering.cpp
Alc/mastering.h
Alc/ringbuffer.cpp
Alc/ringbuffer.h
Alc/effects/base.h
Alc/effects/autowah.cpp
Alc/effects/chorus.cpp
Alc/effects/compressor.cpp
Alc/effects/dedicated.cpp
Alc/effects/distortion.cpp
Alc/effects/echo.cpp
Alc/effects/equalizer.cpp
Alc/effects/fshifter.cpp
Alc/effects/modulator.cpp
Alc/effects/null.cpp
Alc/effects/pshifter.cpp
Alc/effects/reverb.cpp
Alc/effects/vmorpher.cpp
Alc/filters/biquad.h
Alc/filters/biquad.cpp
Alc/filters/nfc.cpp
Alc/filters/nfc.h
Alc/filters/splitter.cpp
Alc/filters/splitter.h
Alc/helpers.cpp
Alc/compat.h
Alc/cpu_caps.h
Alc/fpu_modes.h
Alc/logging.h
Alc/vector.h
Alc/hrtf.cpp
Alc/hrtf.h
Alc/uhjfilter.cpp
Alc/uhjfilter.h
Alc/ambdec.cpp
Alc/ambdec.h
Alc/bformatdec.cpp
Alc/bformatdec.h
Alc/panning.cpp
Alc/mixvoice.cpp
Alc/mixer/defs.h
Alc/mixer/hrtfbase.h
Alc/mixer/mixer_c.cpp
)
SET(CPU_EXTS "Default")
SET(HAVE_SSE 0)
SET(HAVE_SSE2 0)
SET(HAVE_SSE3 0)
SET(HAVE_SSE4_1 0)
SET(HAVE_NEON 0)
# Check for SSE+SSE2 support
OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
IF(HAVE_XMMINTRIN_H AND HAVE_EMMINTRIN_H)
OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
IF(ALSOFT_CPUEXT_SSE AND ALSOFT_CPUEXT_SSE2)
SET(HAVE_SSE 1)
SET(HAVE_SSE2 1)
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_sse.cpp Alc/mixer/mixer_sse2.cpp)
IF(SSE2_SWITCH)
SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_sse.cpp Alc/mixer/mixer_sse2.cpp
PROPERTIES COMPILE_FLAGS "${SSE2_SWITCH}")
ENDIF()
SET(CPU_EXTS "${CPU_EXTS}, SSE, SSE2")
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
ENDIF()
IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
ENDIF()
OPTION(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF)
IF(HAVE_EMMINTRIN_H)
OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
SET(HAVE_SSE3 1)
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_sse3.cpp)
IF(SSE2_SWITCH)
SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_sse3.cpp PROPERTIES
COMPILE_FLAGS "${SSE3_SWITCH}")
ENDIF()
SET(CPU_EXTS "${CPU_EXTS}, SSE3")
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
ENDIF()
OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
IF(HAVE_SMMINTRIN_H)
OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
IF(HAVE_SSE3 AND ALSOFT_CPUEXT_SSE4_1)
SET(HAVE_SSE4_1 1)
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_sse41.cpp)
IF(SSE4_1_SWITCH)
SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_sse41.cpp PROPERTIES
COMPILE_FLAGS "${SSE4_1_SWITCH}")
ENDIF()
SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
ENDIF()
# Check for ARM Neon support
OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
IF(HAVE_ARM_NEON_H)
OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
IF(ALSOFT_CPUEXT_NEON)
SET(HAVE_NEON 1)
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_neon.cpp)
IF(FPU_NEON_SWITCH)
SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_neon.cpp PROPERTIES
COMPILE_FLAGS "${FPU_NEON_SWITCH}")
ENDIF()
SET(CPU_EXTS "${CPU_EXTS}, Neon")
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
ENDIF()
SET(HAVE_ALSA 0)
SET(HAVE_OSS 0)
SET(HAVE_SOLARIS 0)
SET(HAVE_SNDIO 0)
SET(HAVE_QSA 0)
SET(HAVE_DSOUND 0)
SET(HAVE_WASAPI 0)
SET(HAVE_WINMM 0)
SET(HAVE_PORTAUDIO 0)
SET(HAVE_PULSEAUDIO 0)
SET(HAVE_COREAUDIO 0)
SET(HAVE_OPENSL 0)
SET(HAVE_WAVE 0)
SET(HAVE_SDL2 0)
IF(WIN32 OR HAVE_DLFCN_H)
SET(IS_LINKED "")
MACRO(ADD_BACKEND_LIBS _LIBS)
ENDMACRO()
ELSE()
SET(IS_LINKED " (linked)")
MACRO(ADD_BACKEND_LIBS _LIBS)
SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
ENDMACRO()
ENDIF()
SET(BACKENDS "")
SET(ALC_OBJS ${ALC_OBJS}
Alc/backends/base.cpp
Alc/backends/base.h
# Default backends, always available
Alc/backends/loopback.cpp
Alc/backends/loopback.h
Alc/backends/null.cpp
Alc/backends/null.h
)
# Check ALSA backend
OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
FIND_PACKAGE(ALSA)
IF(ALSA_FOUND)
OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
IF(ALSOFT_BACKEND_ALSA)
SET(HAVE_ALSA 1)
SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.cpp Alc/backends/alsa.h)
ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
SET(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
ENDIF()
# Check OSS backend
OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
FIND_PACKAGE(OSS)
IF(OSS_FOUND)
OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
IF(ALSOFT_BACKEND_OSS)
SET(HAVE_OSS 1)
SET(BACKENDS "${BACKENDS} OSS,")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.cpp Alc/backends/oss.h)
IF(OSS_LIBRARIES)
SET(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
ENDIF()
SET(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
ENDIF()
# Check Solaris backend
OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
FIND_PACKAGE(AudioIO)
IF(AUDIOIO_FOUND)
OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
IF(ALSOFT_BACKEND_SOLARIS)
SET(HAVE_SOLARIS 1)
SET(BACKENDS "${BACKENDS} Solaris,")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.cpp Alc/backends/solaris.h)
SET(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
ENDIF()
# Check SndIO backend
OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
FIND_PACKAGE(SoundIO)
IF(SOUNDIO_FOUND)
OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
IF(ALSOFT_BACKEND_SNDIO)
SET(HAVE_SNDIO 1)
SET(BACKENDS "${BACKENDS} SndIO (linked),")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.cpp Alc/backends/sndio.h)
SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
ENDIF()
# Check QSA backend
OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
FIND_PACKAGE(QSA)
IF(QSA_FOUND)
OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
IF(ALSOFT_BACKEND_QSA)
SET(HAVE_QSA 1)
SET(BACKENDS "${BACKENDS} QSA (linked),")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.cpp Alc/backends/qsa.h)
SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
SET(INC_PATHS ${INC_PATHS} ${QSA_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
ENDIF()
# Check Windows-only backends
OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
OPTION(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
IF(HAVE_WINDOWS_H)
SET(WINSDK_LIB_DIRS )
SET(WINSDK_INCLUDE_DIRS )
FIND_PACKAGE(WindowsSDK)
IF(WINDOWSSDK_FOUND)
get_windowssdk_library_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_LIB_DIRS)
get_windowssdk_include_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_INCLUDE_DIRS)
ENDIF()
SET(OLD_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0502)
# Check MMSystem backend
CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
FIND_LIBRARY(WINMM_LIBRARY NAMES winmm
PATHS ${WINSDK_LIB_DIRS}
PATH_SUFFIXES lib lib/x86 lib/x64)
IF(HAVE_MMSYSTEM_H AND WINMM_LIBRARY)
OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
IF(ALSOFT_BACKEND_WINMM)
SET(HAVE_WINMM 1)
SET(BACKENDS "${BACKENDS} WinMM,")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.cpp Alc/backends/winmm.h)
SET(EXTRA_LIBS ${WINMM_LIBRARY} ${EXTRA_LIBS})
ENDIF()
ENDIF()
# Check DSound backend
FIND_PACKAGE(DSound)
IF(DSOUND_FOUND)
OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
IF(ALSOFT_BACKEND_DSOUND)
SET(HAVE_DSOUND 1)
SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.cpp Alc/backends/dsound.h)
ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
SET(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIRS})
ENDIF()
ENDIF()
# Check for WASAPI backend
CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
IF(HAVE_MMDEVICEAPI_H)
OPTION(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
IF(ALSOFT_BACKEND_WASAPI)
SET(HAVE_WASAPI 1)
SET(BACKENDS "${BACKENDS} WASAPI,")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wasapi.cpp Alc/backends/wasapi.h)
ENDIF()
ENDIF()
SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_REQUIRED_DEFINITIONS})
UNSET(OLD_REQUIRED_DEFINITIONS)
ENDIF()
IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
ENDIF()
IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
ENDIF()
IF(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
MESSAGE(FATAL_ERROR "Failed to enabled required WASAPI backend")
ENDIF()
# Check PortAudio backend
OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
FIND_PACKAGE(PortAudio)
IF(PORTAUDIO_FOUND)
OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)