-
Notifications
You must be signed in to change notification settings - Fork 147
/
CMakeLists.txt
1246 lines (1146 loc) · 50.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_minimum_required(VERSION 3.16)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# See docs/release_checklist.md
set(MAJOR_VERSION 3)
set(MINOR_VERSION 0)
set(MICRO_VERSION 0)
set(SDL_REQUIRED_VERSION 3.0.0)
project(SDL3_mixer
LANGUAGES C
VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}"
)
include("${SDL3_mixer_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake")
include("${SDL3_mixer_SOURCE_DIR}/cmake/PrivateSdlFunctions.cmake")
include("${SDL3_mixer_SOURCE_DIR}/cmake/sdlcpu.cmake")
include("${SDL3_mixer_SOURCE_DIR}/cmake/sdlmanpages.cmake")
include("${SDL3_mixer_SOURCE_DIR}/cmake/sdlplatform.cmake")
sdl_calculate_derived_version_variables(${MAJOR_VERSION} ${MINOR_VERSION} ${MICRO_VERSION})
message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(SDLMIXER_ROOTPROJECT ON)
else()
set(SDLMIXER_ROOTPROJECT OFF)
endif()
set(SDLMIXER_SAMPLES_DEFAULT ${SDLMIXER_ROOTPROJECT})
if(ANDROID)
set(SDLMIXER_SAMPLES_DEFAULT OFF)
endif()
# option() honors normal variables.
cmake_policy(SET CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
if(POLICY CMP0112)
# Target file component generator expressions do not add target dependencies.
cmake_policy(SET CMP0112 NEW)
endif()
if(POLICY CMP0099)
# Make `INTERFACE_LINK_DIRECTORIES` a transitive usage requirement.
# This is needed for static dependencies which have transitive dependencies
# outside of compiler default search paths.
cmake_policy(SET CMP0099 NEW)
endif()
# Assume MSVC projects don't have a package manager and need vendored dependencies (by default).
# Most other platforms have some kind of package manager.
# FIXME: consider a package manager such as conan/vcpkg instead of vendoring
if(ANDROID OR MSVC)
set(vendored_default ON)
else()
set(vendored_default OFF)
endif()
set(sdl3mixer_install_enableable ON)
if((TARGET SDL3-shared OR TARGET SDL3-static) AND SDL_DISABLE_INSTALL)
# Cannot install SDL3_mixer when SDL3 is built in same built, and is not installed.
set(sdl3mixer_install_enableable OFF)
endif()
if(NOT DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
endif()
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(PkgConfigHelper)
set(PLATFORM_SUPPORTS_SHARED ON)
if(EMSCRIPTEN OR VITA OR PSP OR PS2 OR N3DS OR RISCOS)
set(PLATFORM_SUPPORTS_SHARED OFF)
endif()
option(CMAKE_POSITION_INDEPENDENT_CODE "Build static libraries with -fPIC" ${PLATFORM_SUPPORTS_SHARED})
cmake_dependent_option(BUILD_SHARED_LIBS "Build the library as a shared library" ON PLATFORM_SUPPORTS_SHARED OFF)
cmake_dependent_option(SDLMIXER_INSTALL "Enable SDL3mixer install target" ${SDLMIXER_ROOTPROJECT} "${sdl3mixer_install_enableable}" OFF)
cmake_dependent_option(SDLMIXER_INSTALL_CPACK "Create binary SDL3_mixer archive using CPack" ${SDLMIXER_ROOTPROJECT} "SDLMIXER_INSTALL" OFF)
cmake_dependent_option(SDLMIXER_INSTALL_MAN "Install man pages for SDL3_mixer" OFF "SDLMIXER_INSTALL" OFF)
cmake_dependent_option(SDLMIXER_DEPS_SHARED "Load dependencies dynamically" ON PLATFORM_SUPPORTS_SHARED OFF)
option(SDLMIXER_VENDORED "Use vendored third-party libraries" ${vendored_default})
option(SDLMIXER_WERROR "Treat warnings as errors" OFF)
option(SDLMIXER_STRICT "Fail when a dependency could not be found" OFF)
set(required "")
set(fatal_error "STATUS")
if(SDLMIXER_STRICT)
set(required "REQUIRED")
set(fatal_error "FATAL_ERROR")
endif()
option(SDLMIXER_SAMPLES "Build the SDL3_mixer sample program(s)" ${SDLMIXER_SAMPLES_DEFAULT})
cmake_dependent_option(SDLMIXER_SAMPLES_INSTALL "Install the SDL3_mixer sample program(s)" OFF "SDLMIXER_SAMPLES;SDLMIXER_INSTALL" OFF)
option(SDLMIXER_SNDFILE "Support loading sounds via libsndfile" OFF)
option(SDLMIXER_SNDFILE_SHARED "Dynamically load libsndfile" "${SDLMIXER_DEPS_SHARED}")
option(SDLMIXER_FLAC "Enable FLAC music" ON)
cmake_dependent_option(SDLMIXER_FLAC_LIBFLAC "Enable FLAC music using libFLAC" OFF SDLMIXER_FLAC OFF)
cmake_dependent_option(SDLMIXER_FLAC_LIBFLAC_SHARED "Dynamically load LIBFLAC" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_FLAC_LIBFLAC OFF)
cmake_dependent_option(SDLMIXER_FLAC_DRFLAC "Enable FLAC music using drflac" ON SDLMIXER_FLAC OFF)
option(SDLMIXER_GME "Support loading GME music via game-music-emu" ON)
option(SDLMIXER_GME_SHARED "Dynamically load libgme" "${SDLMIXER_DEPS_SHARED}")
option(SDLMIXER_MOD "Support loading MOD music" ON)
cmake_dependent_option(SDLMIXER_MOD_MODPLUG "Support loading MOD music via modplug" OFF SDLMIXER_MOD OFF)
cmake_dependent_option(SDLMIXER_MOD_MODPLUG_SHARED "Dynamically load modplug" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_MOD_MODPLUG OFF)
cmake_dependent_option(SDLMIXER_MOD_XMP "Support loading MOD music via libxmp" ON SDLMIXER_MOD OFF)
cmake_dependent_option(SDLMIXER_MOD_XMP_LITE "Use libxmp-lite instead of libxmp" OFF "SDLMIXER_MOD_XMP;NOT SDLMIXER_VENDORED" OFF)
cmake_dependent_option(SDLMIXER_MOD_XMP_SHARED "Dynamically load libxmp(-lite)" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_MOD_XMP OFF)
if(SDLMIXER_MOD AND NOT (SDLMIXER_MOD_MODPLUG OR SDLMIXER_MOD_XMP))
message(FATAL_ERROR "MOD support was enabled (SDLMIXER_MOD) but neither modplug (SDLMIXER_MOD_MODPLUG) or xmp (SDLMIXER_MOD_XMP) was enabled.")
endif()
option(SDLMIXER_MP3 "Enable MP3 music" ON)
cmake_dependent_option(SDLMIXER_MP3_MINIMP3 "Support loading MP3 music via minimp3" ON SDLMIXER_MP3 OFF)
cmake_dependent_option(SDLMIXER_MP3_MPG123 "Support loading MP3 music via MPG123" OFF SDLMIXER_MP3 OFF)
cmake_dependent_option(SDLMIXER_MP3_MPG123_SHARED "Dynamically load mpg123" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_MP3_MPG123 OFF)
if(SDLMIXER_MP3 AND NOT (SDLMIXER_MP3_MINIMP3 OR SDLMIXER_MP3_MPG123))
message(FATAL_ERROR "MP3 support was enabled (SDLMIXER_MP3) but neither minimp3 (SDLMIXER_MP3_MINIMP3) or mpg123 (SDLMIXER_MP3_MPG123) were enabled.")
endif()
option(SDLMIXER_MIDI "Enable MIDI music" ON)
cmake_dependent_option(SDLMIXER_MIDI_FLUIDSYNTH "Support FluidSynth MIDI output" ON "SDLMIXER_MIDI;NOT SDLMIXER_VENDORED" OFF)
cmake_dependent_option(SDLMIXER_MIDI_FLUIDSYNTH_SHARED "Dynamically load libfluidsynth" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_MIDI_FLUIDSYNTH OFF)
if(WIN32 OR APPLE OR HAIKU)
cmake_dependent_option(SDLMIXER_MIDI_NATIVE "Support native MIDI output" ON SDLMIXER_MIDI OFF)
else()
set(SDLMIXER_MIDI_NATIVE OFF)
endif()
cmake_dependent_option(SDLMIXER_MIDI_TIMIDITY "Support timidity MIDI output" ON SDLMIXER_MIDI OFF)
if(SDLMIXER_MIDI AND NOT (SDLMIXER_MIDI_TIMIDITY OR SDLMIXER_MIDI_NATIVE OR SDLMIXER_MIDI_FLUIDSYNTH))
message(FATAL_ERROR "MIDI support was enabled (SDLMIXER_MIDI) but neither FluidSynth (SDLMIXER_MIDI_FLUIDSYNTH), native (SDLMIXER_MIDI_NATIVE) or timidity (SDLMIXER_MIDI_TIMIDITY) was enabled")
endif()
option(SDLMIXER_OPUS "Enable Opus music" ON)
cmake_dependent_option(SDLMIXER_OPUS_SHARED "Dynamically load libopus" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_OPUS OFF)
set(sdl3mixer_vorbis_strings STB TREMOR VORBISFILE)
set(SDLMIXER_VORBIS "STB" CACHE STRING "Enable OGG Vorbis music")
set_property(CACHE SDLMIXER_VORBIS PROPERTY STRINGS "${sdl3mixer_vorbis_strings}")
if(SDLMIXER_VORBIS)
if(NOT SDLMIXER_VORBIS IN_LIST sdl3mixer_vorbis_strings)
message(FATAL_ERROR "SDLMIXER_VORBIS contains an invalid value (=${SDLMIXER_VORBIS}). It must be one of ${sdl3mixer_vorbis_strings}.")
endif()
endif()
set(SDLMIXER_VORBIS_STB OFF)
set(SDLMIXER_VORBIS_TREMOR OFF)
set(SDLMIXER_VORBIS_VORBISFILE OFF)
if(SDLMIXER_VORBIS STREQUAL "STB")
set(SDLMIXER_VORBIS_STB ON)
endif()
if(SDLMIXER_VORBIS STREQUAL "TREMOR")
set(SDLMIXER_VORBIS_TREMOR ON)
endif()
if(SDLMIXER_VORBIS STREQUAL "VORBISFILE")
set(SDLMIXER_VORBIS_VORBISFILE ON)
endif()
cmake_dependent_option(SDLMIXER_VORBIS_TREMOR_SHARED "Dynamically load tremor library" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_VORBIS_TREMOR OFF)
cmake_dependent_option(SDLMIXER_VORBIS_VORBISFILE_SHARED "Dynamically load vorbisfile library" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_VORBIS_VORBISFILE OFF)
option(SDLMIXER_WAVE "Enable streaming WAVE music" ON)
option(SDLMIXER_WAVPACK "Enable WavPack music" ON)
cmake_dependent_option(SDLMIXER_WAVPACK_DSD "Enable WavPack DSD music support" OFF SDLMIXER_WAVPACK OFF)
cmake_dependent_option(SDLMIXER_WAVPACK_SHARED "Dynamically load WavPack library" "${SDLMIXER_DEPS_SHARED}" SDLMIXER_WAVPACK OFF)
if(SDLMIXER_VORBIS_TREMOR OR SDLMIXER_VORBIS_VORBISFILE OR SDLMIXER_FLAC_LIBFLAC OR SDLMIXER_OPUS)
set(SDLMIXER_OGG TRUE)
set(SDLMIXER_OGG_install FALSE)
if(SDLMIXER_VORBIS_VORBISFILE_SHARED OR SDLMIXER_FLAC_SHARED OR SDLMIXER_OPUS_SHARED)
set(SDLMIXER_OGG_SHARED TRUE)
set(SDLMIXER_OGG_install TRUE)
else()
set(SDLMIXER_OGG_SHARED FALSE)
if(NOT SDLMIXER_BUILD_SHARED_LIBS)
set(SDLMIXER_OGG_install TRUE)
endif()
endif()
else()
set(SDLMIXER_OGG FALSE)
endif()
# Save BUILD_SHARED_LIBS variable
set(SDLMIXER_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(sdl_required_components Headers)
if(SDLMIXER_BUILD_SHARED_LIBS)
set(sdl3_mixer_target_name SDL3_mixer-shared)
set(sdl3_target_name SDL3::SDL3-shared)
list(APPEND sdl_required_components SDL3-shared)
else()
set(sdl3_mixer_target_name SDL3_mixer-static)
set(sdl3_target_name SDL3::SDL3)
endif()
if(NOT TARGET SDL3::Headers OR NOT TARGET ${sdl3_target_name})
find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED COMPONENTS ${sdl_required_components})
endif()
SDL_DetectTargetCPUArchitectures(SDL_CPU_NAMES)
SDL_DetectCMakePlatform()
set(BUILD_SHARED_LIBS ${SDLMIXER_BUILD_SHARED_LIBS})
add_library(${sdl3_mixer_target_name}
src/codecs/load_aiff.c
src/codecs/load_voc.c
src/codecs/load_sndfile.c
src/codecs/mp3utils.c
src/codecs/music_drflac.c
src/codecs/music_flac.c
src/codecs/music_fluidsynth.c
src/codecs/music_gme.c
src/codecs/music_minimp3.c
src/codecs/music_modplug.c
src/codecs/music_mpg123.c
src/codecs/music_nativemidi.c
src/codecs/music_ogg.c
src/codecs/music_ogg_stb.c
src/codecs/music_opus.c
src/codecs/music_timidity.c
src/codecs/music_wav.c
src/codecs/music_wavpack.c
src/codecs/music_xmp.c
src/effect_position.c
src/effect_stereoreverse.c
src/effects_internal.c
src/mixer.c
src/music.c
src/utils.c
)
add_library(SDL3_mixer::${sdl3_mixer_target_name} ALIAS ${sdl3_mixer_target_name})
if(NOT TARGET SDL3_mixer::SDL3_mixer)
add_library(SDL3_mixer::SDL3_mixer ALIAS ${sdl3_mixer_target_name})
endif()
target_include_directories(${sdl3_mixer_target_name}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
src
src/codecs
)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE
BUILD_SDL
SDL_BUILD_MAJOR_VERSION=${MAJOR_VERSION}
SDL_BUILD_MINOR_VERSION=${MINOR_VERSION}
SDL_BUILD_MICRO_VERSION=${MICRO_VERSION}
)
target_link_libraries(${sdl3_mixer_target_name} PUBLIC SDL3::Headers)
if(SDLMIXER_BUILD_SHARED_LIBS)
target_link_libraries(${sdl3_mixer_target_name} PRIVATE SDL3::SDL3-shared)
endif()
sdl_add_warning_options(${sdl3_mixer_target_name} WARNING_AS_ERROR ${SDLMIXER_WERROR})
if(WIN32 AND BUILD_SHARED_LIBS)
target_sources(${sdl3_mixer_target_name} PRIVATE
src/version.rc
)
endif()
set_target_properties(${sdl3_mixer_target_name} PROPERTIES
OUTPUT_NAME "SDL3_mixer"
DEFINE_SYMBOL DLL_EXPORT
EXPORT_NAME ${sdl3_mixer_target_name}
C_VISIBILITY_PRESET "hidden"
)
sdl_target_link_option_version_file(${sdl3_mixer_target_name} "${CMAKE_CURRENT_SOURCE_DIR}/src/SDL_mixer.sym")
if(NOT ANDROID)
set_target_properties(${sdl3_mixer_target_name} PROPERTIES
SOVERSION "${SO_VERSION_MAJOR}"
VERSION "${SO_VERSION}"
)
if(APPLE)
cmake_minimum_required(VERSION 3.17)
set_target_properties(${sdl3_mixer_target_name} PROPERTIES
MACHO_COMPATIBILITY_VERSION "${DYLIB_COMPAT_VERSION}"
MACHO_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}"
)
endif()
endif()
if(SDLMIXER_BUILD_SHARED_LIBS)
if(WIN32)
set_target_properties(${sdl3_mixer_target_name} PROPERTIES
PREFIX ""
DLL_NAME_WITH_SOVERSION FALSE
)
endif()
else()
if(MSVC)
set_target_properties(${sdl3_mixer_target_name} PROPERTIES
OUTPUT_NAME "SDL3_mixer-static"
)
endif()
endif()
# Use `Compatible Interface Properties` to ensure a shared SDL3_mixer is linked to a shared SDL3 library
if(SDLMIXER_BUILD_SHARED_LIBS)
set_property(TARGET ${sdl3_mixer_target_name} PROPERTY INTERFACE_SDL3_SHARED ${SDLMIXER_BUILD_SHARED_LIBS})
set_property(TARGET ${sdl3_mixer_target_name} APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL3_SHARED)
endif()
if(SDLMIXER_BUILD_SHARED_LIBS)
sdl_target_link_options_no_undefined(${sdl3_mixer_target_name})
endif()
if(SDLMIXER_BUILD_SHARED_LIBS)
# Make sure static library dependencies are built with -fPIC when building a shared SDL3_mixer
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
set(INSTALL_EXTRA_TARGETS)
set(PC_LIBS)
set(PC_REQUIRES)
set(SDLMIXER_BACKENDS)
list(APPEND SDLMIXER_BACKENDS SNDFILE)
set(SDLMIXER_SNDFILE_ENABLED FALSE)
if(SDLMIXER_SNDFILE)
if(SDLMIXER_VENDORED)
message(STATUS "Using vendored libsndfile")
message(${fatal_error} "libsndfile is not vendored.")
else()
find_package(SndFile ${required})
if(SndFile_FOUND)
set(SDLMIXER_SNDFILE_ENABLED TRUE)
message(STATUS "Using system libsndfile")
if(NOT SDLMIXER_SNDFILE_SHARED)
list(APPEND PC_REQUIRES sndfile)
endif()
else()
message(${fatal_error} "libsndfile NOT found")
endif()
endif()
if(SDLMIXER_SNDFILE_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE LOAD_SNDFILE)
if(SDLMIXER_SNDFILE_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:SndFile::sndfile,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:SndFile::sndfile,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:SndFile::sndfile,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_sndfile SndFile::sndfile)
message(STATUS "Dynamic libsndfile: ${dynamic_sndfile}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "SNDFILE_DYNAMIC=\"${dynamic_sndfile}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} SndFile::sndfile)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE SndFile::sndfile)
endif()
endif()
endif()
if(SDLMIXER_OGG)
# libogg is a requirement of libflac, libtremor and libvorbisfile, so only need this library when vendoring
if(SDLMIXER_VENDORED)
message(STATUS "Using vendored libogg")
set(BUILD_SHARED_LIBS ${SDLMIXER_OGG_SHARED})
set(INSTALL_CMAKE_PACKAGE_MODULE FALSE)
set(BUILD_TESTING OFF)
sdl_check_project_in_subfolder(external/ogg ogg SDLMIXER_VENDORED)
add_subdirectory(external/ogg EXCLUDE_FROM_ALL)
if(SDLMIXER_OGG_install)
list(APPEND INSTALL_EXTRA_TARGETS ogg)
endif()
endif()
endif()
list(APPEND SDLMIXER_BACKENDS OPUS)
set(SDLMIXER_OPUS_ENABLED FALSE)
if(SDLMIXER_OPUS)
if(SDLMIXER_VENDORED)
set(SDLMIXER_OPUS_ENABLED TRUE)
# vendored libogg already handled
if(NOT TARGET ogg)
message(FATAL_ERROR "ogg target not present")
endif()
message(STATUS "Using vendored opus")
set(BUILD_SHARED_LIBS ${SDLMIXER_OPUS_SHARED})
set(BUILD_PROGRAMS OFF)
sdl_check_project_in_subfolder(external/opus opus SDLMIXER_VENDORED)
add_subdirectory(external/opus EXCLUDE_FROM_ALL)
set(OP_DISABLE_DOCS TRUE)
set(OP_DISABLE_EXAMPLES TRUE)
set(OP_DISABLE_HTTP TRUE)
message(STATUS "Using vendored opusfile")
set(BUILD_SHARED_LIBS ${SDLMIXER_OPUS_SHARED})
sdl_check_project_in_subfolder(external/opusfile opusfile SDLMIXER_VENDORED)
add_subdirectory(external/opusfile EXCLUDE_FROM_ALL)
if(MSVC)
set_property(TARGET opusfile PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/opusfile.h" "#include \"${CMAKE_CURRENT_SOURCE_DIR}/external/opusfile/include/opusfile.h\"\n")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/opus"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/opusfile.h" "${CMAKE_CURRENT_BINARY_DIR}/opus/opusfile.h"
)
target_include_directories(${sdl3_mixer_target_name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
if(NOT TARGET OpusFile::opusfile)
add_library(OpusFile::opusfile ALIAS opusfile)
endif()
if(SDLMIXER_OPUS_SHARED OR NOT SDLMIXER_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS opus opusfile)
endif()
if(NOT SDLMIXER_OPUS_SHARED)
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:opusfile> -l$<TARGET_FILE_BASE_NAME:opus> -l$<TARGET_FILE_BASE_NAME:ogg>)
endif()
else()
find_package(OpusFile ${required})
if(OpusFile_FOUND AND Ogg_FOUND)
set(SDLMIXER_OPUS_ENABLED TRUE)
message(STATUS "Using system opusfile")
if(NOT SDLMIXER_OPUS_SHARED)
list(APPEND PC_REQUIRES opusfile)
endif()
else()
message(${fatal_error} "opusfile NOT found")
endif()
endif()
if(SDLMIXER_OPUS_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_OPUS)
if(SDLMIXER_OPUS_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:OpusFile::opusfile,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:OpusFile::opusfile,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:OpusFile::opusfile,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_opusfile OpusFile::opusfile)
message(STATUS "Dynamic opus (opusfile): ${dynamic_opusfile}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "OPUS_DYNAMIC=\"${dynamic_opusfile}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} OpusFile::opusfile)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE OpusFile::opusfile)
endif()
endif()
endif()
list(APPEND SDLMIXER_BACKENDS VORBIS_STB)
set(SDLMIXER_VORBIS_STB_ENABLED FALSE)
if(SDLMIXER_VORBIS_STB)
set(SDLMIXER_VORBIS_STB_ENABLED TRUE)
message(STATUS "Enabled ogg music: using stb_vorbis")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_OGG)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE OGG_USE_STB)
endif()
list(APPEND SDLMIXER_BACKENDS VORBIS_TREMOR)
set(SDLMIXER_VORBIS_TREMOR_ENABLED FALSE)
if(SDLMIXER_VORBIS_TREMOR)
if(SDLMIXER_VENDORED)
set(SDLMIXER_VORBIS_TREMOR_ENABLED TRUE)
# vendored libogg already handled
if(NOT TARGET ogg)
message(FATAL_ERROR "ogg target not present")
endif()
message(STATUS "Using vendored tremor")
set(BUILD_SHARED_LIBS ${SDLMIXER_VORBIS_TREMOR_SHARED})
sdl_check_project_in_subfolder(external/tremor tremor SDLMIXER_VENDORED)
add_subdirectory(external/tremor EXCLUDE_FROM_ALL)
if(NOT TARGET tremor::tremor)
add_library(tremor::tremor ALIAS vorbisidec)
endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ivorbisfile.h" "#include \"${CMAKE_CURRENT_SOURCE_DIR}/external/tremor/ivorbisfile.h\"\n")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/tremor"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/ivorbisfile.h" "${CMAKE_CURRENT_BINARY_DIR}/tremor/ivorbisfile.h"
)
target_include_directories(${sdl3_mixer_target_name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
if(SDLMIXER_VORBIS_TREMOR_SHARED OR NOT SDLMIXER_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS vorbisidec)
endif()
if(NOT SDLMIXER_VORBIS_TREMOR_SHARED)
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:vorbisidec> -l$<TARGET_FILE_BASE_NAME:ogg>)
endif()
else()
message(STATUS "Using system tremor")
find_package(tremor ${required})
if(tremor_FOUND)
if(NOT SDLMIXER_VORBIS_TREMOR_SHARED)
list(APPEND PC_REQUIRES tremor)
endif()
set(SDLMIXER_VORBIS_TREMOR_ENABLED TRUE)
else()
message(${fatal_error} "tremor NOT found")
endif()
endif()
if(SDLMIXER_VORBIS_TREMOR_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_OGG OGG_USE_TREMOR)
if(SDLMIXER_VORBIS_TREMOR_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:tremor::tremor,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:tremor::tremor,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:tremor::tremor,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_tremor tremor::tremor)
message(STATUS "Dynamic vorbis (tremor): ${dynamic_tremor}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "OGG_DYNAMIC=\"${dynamic_tremor}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} tremor::tremor)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE tremor::tremor)
endif()
endif()
endif()
list(APPEND SDLMIXER_BACKENDS VORBIS_VORBISFILE)
set(SDLMIXER_VORBIS_VORBISFILE_ENABLED FALSE)
if(SDLMIXER_VORBIS_VORBISFILE)
if(SDLMIXER_VENDORED)
set(SDLMIXER_VORBIS_VORBISFILE_ENABLED TRUE)
# vendored libogg already handled
if(NOT TARGET ogg)
message(FATAL_ERROR "ogg target not present")
endif()
message(STATUS "Using vendored vorbis + vorbisfile")
set(BUILD_SHARED_LIBS ${SDLMIXER_VORBIS_VORBISFILE_SHARED})
sdl_check_project_in_subfolder(external/vorbis vorbisfile SDLMIXER_VENDORED)
add_subdirectory(external/vorbis EXCLUDE_FROM_ALL)
if(NOT TARGET Vorbis::vorbisfile)
add_library(Vorbis::vorbisfile ALIAS vorbisfile)
endif()
if(SDLMIXER_VORBIS_VORBISFILE_SHARED OR NOT SDLMIXER_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS vorbis vorbisfile)
endif()
if(NOT SDLMIXER_VORBIS_VORBISFILE_SHARED)
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:vorbisfile>)
endif()
else()
find_package(Vorbis ${required})
if(Vorbis_FOUND)
set(SDLMIXER_VORBIS_VORBISFILE_ENABLED TRUE)
message(STATUS "Using system vorbisfile")
if(NOT SDLMIXER_VORBIS_VORBISFILE_SHARED)
list(APPEND PC_REQUIRES vorbisfile)
endif()
else()
message(${fatal_error} "vorbisfile NOT found")
endif()
endif()
if(SDLMIXER_VORBIS_VORBISFILE_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_OGG)
if(SDLMIXER_VORBIS_VORBISFILE_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:Vorbis::vorbisfile,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Vorbis::vorbisfile,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Vorbis::vorbisfile,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_vorbisfile Vorbis::vorbisfile)
message(STATUS "Dynamic vorbisfile: ${dynamic_vorbisfile}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "OGG_DYNAMIC=\"${dynamic_vorbisfile}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} Vorbis::vorbisfile)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE Vorbis::vorbisfile)
endif()
endif()
endif()
set(SDLMIXER_VORBIS_ENABLED FALSE)
if(SDLMIXER_VORBIS_STB_ENABLED OR SDLMIXER_VORBIS_TREMOR_ENABLED OR SDLMIXER_VORBIS_VORBISFILE_ENABLED)
set(SDLMIXER_VORBIS_ENABLED TRUE)
endif()
list(APPEND SDLMIXER_BACKENDS FLAC_LIBFLAC)
set(SDLMIXER_FLAC_LIBFLAC_ENABLED FALSE)
if(SDLMIXER_FLAC_LIBFLAC)
if(SDLMIXER_VENDORED)
set(SDLMIXER_FLAC_LIBFLAC_ENABLED TRUE)
# vendored libogg already handled
if(NOT TARGET ogg)
message(FATAL_ERROR "ogg target not present")
endif()
set(BUILD_SHARED_LIBS "${SDLMIXER_FLAC_LIBFLAC_SHARED}")
set(INSTALL_CMAKE_CONFIG_MODULE OFF)
set(WITH_OGG OFF)
set(BUILD_CXXLIBS OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_PROGRAMS OFF)
set(BUILD_TESTING OFF)
set(INSTALL_MANPAGES OFF)
message(STATUS "Using vendored libflac")
sdl_check_project_in_subfolder(external/flac libflac SDLMIXER_VENDORED)
add_subdirectory(external/flac EXCLUDE_FROM_ALL)
if(SDLMIXER_FLAC_LIBFLAC_SHARED OR NOT SDLMIXER_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS FLAC)
endif()
if(NOT SDLMIXER_FLAC_LIBFLAC_SHARED)
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:FLAC::FLAC> -l$<TARGET_FILE_BASE_NAME:ogg>)
endif()
else()
find_package(FLAC ${required})
if(FLAC_FOUND)
set(SDLMIXER_FLAC_LIBFLAC_ENABLED TRUE)
message(STATUS "Using system libflac")
if(NOT SDLMIXER_FLAC_LIBFLAC_SHARED)
list(APPEND PC_REQUIRES flac)
endif()
else()
message(${fatal_error} "libflac NOT found")
endif()
endif()
if(SDLMIXER_FLAC_LIBFLAC_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_FLAC_LIBFLAC)
if(SDLMIXER_FLAC_LIBFLAC_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:FLAC::FLAC,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:FLAC::FLAC,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:FLAC::FLAC,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_flac FLAC::FLAC)
message(STATUS "Dynamic libflac: ${dynamic_flac}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "FLAC_DYNAMIC=\"${dynamic_flac}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} FLAC)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE FLAC::FLAC)
endif()
endif()
endif()
list(APPEND SDLMIXER_BACKENDS FLAC_DRFLAC)
set(SDLMIXER_FLAC_DRFLAC_ENABLED FALSE)
if(SDLMIXER_FLAC_DRFLAC)
set(SDLMIXER_FLAC_DRFLAC_ENABLED TRUE)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_FLAC_DRFLAC)
endif()
set(SDLMIXER_FLAC_ENABLED FALSE)
if(SDLMIXER_FLAC_DRFLAC_ENABLED OR SDLMIXER_FLAC_LIBFLAC_ENABLED)
set(SDLMIXER_FLAC_ENABLED TRUE)
endif()
list(APPEND SDLMIXER_BACKENDS GME)
set(SDLMIXER_GME_ENABLED FALSE)
if(SDLMIXER_GME)
if(SDLMIXER_VENDORED)
set(SDLMIXER_GME_ENABLED TRUE)
set(BUILD_SHARED_LIBS "${SDLMIXER_GME_SHARED}")
set(ENABLE_UBSAN OFF)
set(BUILD_FRAMEWORK OFF)
option(GME_ZLIB "Enable GME to support compressed sound formats" OFF)
message(STATUS "Using vendored libgme")
sdl_check_project_in_subfolder(external/libgme libgme SDLMIXER_VENDORED)
enable_language(CXX)
add_subdirectory(external/libgme EXCLUDE_FROM_ALL)
add_library(gme::gme ALIAS gme)
if(SDLMIXER_GME_SHARED)
list(APPEND INSTALL_EXTRA_TARGETS gme)
endif()
if(NOT SDLMIXER_GME_SHARED)
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:gme>)
endif()
else()
find_package(gme ${required})
if(gme_FOUND)
set(SDLMIXER_GME_ENABLED TRUE)
message(STATUS "Using system libgme")
if(NOT SDLMIXER_GME_SHARED)
list(APPEND PC_REQUIRES libgme)
endif()
else()
message(${fatal_error} "libgme NOT found")
endif()
endif()
if(SDLMIXER_GME_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_GME)
if(SDLMIXER_GME_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:gme::gme,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gme::gme,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gme::gme,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_gme gme::gme)
message(STATUS "Dynamic libgme: ${dynamic_gme}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "GME_DYNAMIC=\"${dynamic_gme}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} gme::gme)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE gme::gme)
endif()
endif()
endif()
list(APPEND SDLMIXER_BACKENDS MOD_MODPLUG)
set(SDLMIXER_MOD_MODPLUG_ENABLED FALSE)
if(SDLMIXER_MOD_MODPLUG)
if(SDLMIXER_VENDORED)
message(STATUS "Using vendored libmodplug")
message(${fatal_error} "libmodplug is not vendored.")
else()
find_package(modplug ${required})
if(modplug_FOUND)
set(SDLMIXER_MOD_MODPLUG_ENABLED TRUE)
message(STATUS "Using system libmodplug")
if(NOT SDLMIXER_MOD_MODPLUG_SHARED)
list(APPEND PC_REQUIRES libmodplug)
endif()
else()
message(${fatal_error} "libmodplug NOT found")
endif()
endif()
if(SDLMIXER_MOD_MODPLUG_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_MOD_MODPLUG)
if(SDLMIXER_MOD_MODPLUG_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:modplug::modplug,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:modplug::modplug,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:modplug::modplug,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_modplug modplug::modplug)
message(STATUS "Dynamic modplug: ${dynamic_modplug}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "MODPLUG_DYNAMIC=\"${dynamic_modplug}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} modplug::modplug)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE modplug::modplug)
endif()
endif()
endif()
list(APPEND SDLMIXER_BACKENDS MOD_XMP)
set(SDLMIXER_MOD_XMP_ENABLED FALSE)
if(SDLMIXER_MOD_XMP)
if(SDLMIXER_VENDORED)
set(SDLMIXER_MOD_XMP_ENABLED TRUE)
message(STATUS "Using vendored libxmp")
sdl_check_project_in_subfolder(external/libxmp libxmp SDLMIXER_VENDORED)
set(LIBXMP_DISABLE_DEPACKERS ON CACHE BOOL "Disable archive depackers")
set(LIBXMP_DISABLE_PROWIZARD ON CACHE BOOL "Disable ProWizard format loaders")
if(SDLMIXER_MOD_XMP_SHARED)
set(BUILD_STATIC OFF)
set(BUILD_SHARED ON)
set(tgt_xmp xmp_shared)
else()
set(BUILD_STATIC ON)
set(BUILD_SHARED OFF)
set(tgt_xmp xmp_static)
endif()
set(xmp_name libxmp)
add_subdirectory(external/libxmp EXCLUDE_FROM_ALL)
if(SDLMIXER_MOD_XMP_SHARED OR NOT SDLMIXER_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS ${tgt_xmp})
endif()
if(NOT SDLMIXER_MOD_XMP_SHARED)
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:${tgt_xmp}>)
endif()
else()
if(SDLMIXER_MOD_XMP_LITE)
find_package(libxmp-lite ${required})
if(libxmp-lite_FOUND)
set(SDLMIXER_MOD_XMP_ENABLED TRUE)
message(STATUS "Using system libxmp-lite")
set(tgt_xmp libxmp-lite::libxmp-lite)
set(xmp_name libxmp-lite)
if(NOT SDLMIXER_MOD_XMP_SHARED)
list(APPEND PC_REQUIRES libxmp-lite)
endif()
else()
message(${fatal_error} "libxmp-lite NOT found")
endif()
else()
find_package(libxmp ${required})
if(libxmp_FOUND)
set(SDLMIXER_MOD_XMP_ENABLED TRUE)
message(STATUS "Using system libxmp")
if(TARGET libxmp::xmp_shared)
set(tgt_xmp libxmp::xmp_shared)
elseif(TARGET libxmp::xmp_static)
set(tgt_xmp libxmp::xmp_static)
else()
set(tgt_xmp libxmp::libxmp)
endif()
set(xmp_name libxmp)
if(NOT SDLMIXER_MOD_XMP_SHARED)
list(APPEND PC_REQUIRES libxmp)
endif()
else()
message(${fatal_error} "libxmp NOT found")
endif()
endif()
endif()
if(SDLMIXER_MOD_XMP_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_MOD_XMP)
if(SDLMIXER_MOD_XMP_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:${tgt_xmp},INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${tgt_xmp},INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${tgt_xmp},INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_xmp ${tgt_xmp})
message(STATUS "Dynamic ${xmp_name}: ${dynamic_xmp}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "XMP_DYNAMIC=\"${dynamic_xmp}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} ${tgt_xmp})
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE ${tgt_xmp})
endif()
endif()
endif()
set(SDLMIXER_MOD_ENABLED FALSE)
if(SDLMIXER_MOD_MODPLUG_ENABLED OR SDLMIXER_MOD_XMP_ENABLED OR SDLMIXER_MOD_XMP_ENABLED)
set(SDLMIXER_MOD_ENABLED TRUE)
endif()
list(APPEND SDLMIXER_BACKENDS MP3_MINIMP3)
set(SDLMIXER_MP3_MINIMP3_ENABLED FALSE)
if(SDLMIXER_MP3_MINIMP3)
set(SDLMIXER_MP3_MINIMP3_ENABLED TRUE)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_MP3_MINIMP3)
endif()
list(APPEND SDLMIXER_BACKENDS MP3_MPG123)
set(SDLMIXER_MP3_MPG123_ENABLED FALSE)
if(SDLMIXER_MP3_MPG123)
if(SDLMIXER_VENDORED)
set(SDLMIXER_MP3_MPG123_ENABLED TRUE)
message(STATUS "Using vendored mpg123")
sdl_check_project_in_subfolder(external/mpg123/ports/cmake mpg123 SDLMIXER_VENDORED)
set(BUILD_LIBOUT123 FALSE)
set(BUILD_PROGRAMS OFF)
set(BUILD_SHARED_LIBS "${SDLMIXER_MP3_MPG123_SHARED}")
add_subdirectory(external/mpg123/ports/cmake EXCLUDE_FROM_ALL)
if(NOT TARGET MPG123::libmpg123)
add_library(MPG123::libmpg123 ALIAS libmpg123)
endif()
if(SDLMIXER_MP3_MPG123_SHARED OR NOT SDLMIXER_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS libmpg123)
endif()
if(NOT SDLMIXER_MP3_MPG123_SHARED)
list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:MPG123::mpg123>)
endif()
else()
find_package(mpg123 ${required})
if(mpg123_FOUND)
set(SDLMIXER_MP3_MPG123_ENABLED TRUE)
message(STATUS "Using system mpg123")
if(NOT SDLMIXER_MP3_MPG123_SHARED)
list(APPEND PC_REQUIRES libmpg123)
endif()
else()
message(${fatal_error} "mpg123 NOT found")
endif()
endif()
if(SDLMIXER_MP3_MPG123_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_MP3_MPG123)
if(SDLMIXER_MP3_MPG123_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:MPG123::libmpg123,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:MPG123::libmpg123,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:MPG123::libmpg123,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_mpg123 MPG123::libmpg123)
message(STATUS "Dynamic mpg123}: ${dynamic_mpg123}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "MPG123_DYNAMIC=\"${dynamic_mpg123}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} MPG123::libmpg123)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE MPG123::libmpg123)
endif()
endif()
endif()
set(SDLMIXER_MP3_ENABLED FALSE)
if(SDLMIXER_MP3_MINIMP3_ENABLED OR SDLMIXER_MP3_MPG123_ENABLED)
set(SDLMIXER_MP3_ENABLED TRUE)
endif()
list(APPEND SDLMIXER_BACKENDS MIDI_FLUIDSYNTH)
set(SDLMIXER_MIDI_FLUIDSYNTH_ENABLED FALSE)
if(SDLMIXER_MIDI_FLUIDSYNTH)
if(SDLMIXER_VENDORED)
message(STATUS "Using vendored FluidSynth")
message(${fatal_error} "FluidSynth is not vendored.")
set(SDLMIXER_MIDI_FLUIDSYNTH_ENABLED FALSE)
else()
find_package(FluidSynth ${required})
if(FluidSynth_FOUND)
set(SDLMIXER_MIDI_FLUIDSYNTH_ENABLED TRUE)
message(STATUS "Using system FluidSynth")
if(NOT SDLMIXER_MIDI_FLUIDSYNTH_SHARED)
list(APPEND PC_REQUIRES fluidsynth)
endif()
else()
message(${fatal_error} "FluidSynth NOT found")
endif()
endif()
if(SDLMIXER_MIDI_FLUIDSYNTH_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_MID_FLUIDSYNTH)
if(SDLMIXER_MIDI_FLUIDSYNTH_SHARED)
target_include_directories(${sdl3_mixer_target_name} PRIVATE
$<TARGET_PROPERTY:FluidSynth::libfluidsynth,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:FluidSynth::libfluidsynth,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:FluidSynth::libfluidsynth,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
target_get_dynamic_library(dynamic_fluidsynth FluidSynth::libfluidsynth)
message(STATUS "Dynamic fluidsynth: ${dynamic_fluidsynth}")
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE "FLUIDSYNTH_DYNAMIC=\"${dynamic_fluidsynth}\"")
if(SDLMIXER_VENDORED)
add_dependencies(${sdl3_mixer_target_name} FluidSynth::libfluidsynth)
endif()
else()
target_link_libraries(${sdl3_mixer_target_name} PRIVATE FluidSynth::libfluidsynth)
endif()
endif()
endif()
list(APPEND SDLMIXER_BACKENDS MIDI_NATIVE)
list(APPEND SDLMIXER_MIDI_NATIVE_ENABLED FALSE)
if(SDLMIXER_MIDI_NATIVE)
set(midi_common_sources
src/codecs/native_midi/native_midi_common.c
src/codecs/native_midi/native_midi_common.h
)
if(WIN32)
list(APPEND SDLMIXER_MIDI_NATIVE_ENABLED TRUE)
target_sources(${sdl3_mixer_target_name} PRIVATE src/codecs/native_midi/native_midi_win32.c ${midi_common_sources})
target_link_libraries(${sdl3_mixer_target_name} PRIVATE winmm)
elseif(APPLE)
list(APPEND SDLMIXER_MIDI_NATIVE_ENABLED TRUE)
target_sources(${sdl3_mixer_target_name} PRIVATE src/codecs/native_midi/native_midi_macosx.c ${midi_common_sources})
target_link_libraries(${sdl3_mixer_target_name} PRIVATE -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices)
elseif(HAIKU)
list(APPEND SDLMIXER_MIDI_NATIVE_ENABLED TRUE)
enable_language(CXX)
target_sources(${sdl3_mixer_target_name} PRIVATE src/codecs/native_midi/native_midi_haiku.cpp ${midi_common_sources})
target_link_libraries(${sdl3_mixer_target_name} PRIVATE midi)
endif()
if(SDLMIXER_MIDI_NATIVE_ENABLED)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_MID_NATIVE)
else()
message(${fatal_error} "native mididi NOT available for current platform")
endif()
endif()
list(APPEND SDLMIXER_BACKENDS MIDI_TIMIDITY)
set(SDLMIXER_MIDI_TIMIDITY_ENABLED FALSE)
if(SDLMIXER_MIDI_TIMIDITY)
set(SDLMIXER_MIDI_TIMIDITY_ENABLED TRUE)
target_compile_definitions(${sdl3_mixer_target_name} PRIVATE MUSIC_MID_TIMIDITY)
target_sources(${sdl3_mixer_target_name} PRIVATE
src/codecs/timidity/common.c
src/codecs/timidity/instrum.c
src/codecs/timidity/mix.c
src/codecs/timidity/output.c
src/codecs/timidity/playmidi.c
src/codecs/timidity/readmidi.c
src/codecs/timidity/resample.c
src/codecs/timidity/tables.c
src/codecs/timidity/timidity.c
)
endif()
set(SDLMIXER_MIDI_ENABLED FALSE)
if(SDLMIXER_MIDI_FLUIDSYNTH_ENABLED OR SDLMIXER_MIDI_NATIVE_ENABLED OR SDLMIXER_MIDI_TIMIDITY_ENABLED)
set(SDLMIXER_MIDI_ENABLED TRUE)
endif()
list(APPEND SDLMIXER_BACKENDS WAVE)
set(SDLMIXER_WAVE_ENABLED FALSE)
if(SDLMIXER_WAVE)
set(SDLMIXER_WAVE_ENABLED TRUE)