Commit 7850d0cf6fa1b2e7d8999d0506bb907ae071f497

Ryan C. Gordon 2021-10-05T10:43:35

cmake: Prefix all options with "SDL_" This makes it clear which options came from SDL's CMake project when building SDL as a subdirectory of a parent CMake project. Fixes #4139.

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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7cc87d..60f6ad6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -212,8 +212,8 @@ if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA)
 endif()
 
 if(MSVC)
-  option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
-  if(FORCE_STATIC_VCRT)
+  option(SDL_FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
+  if(SDL_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)
@@ -324,82 +324,82 @@ foreach(_SUB ${SDL_SUBSYSTEMS})
   option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ${SDL_${_OPT}_ENABLED_BY_DEFAULT})
 endforeach()
 
-option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
-#set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
-set_option(LIBC                "Use the system C library" ${OPT_DEF_LIBC})
-set_option(GCC_ATOMICS         "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
-set_option(ASSEMBLY            "Enable assembly routines" ${OPT_DEF_ASM})
-set_option(SSEMATH             "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
-set_option(MMX                 "Use MMX assembly routines" ${OPT_DEF_ASM})
-set_option(3DNOW               "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
-set_option(SSE                 "Use SSE assembly routines" ${OPT_DEF_ASM})
-set_option(SSE2                "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
-set_option(SSE3                "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
-set_option(ALTIVEC             "Use Altivec assembly routines" ${OPT_DEF_ASM})
-set_option(ARMSIMD             "use SIMD assembly blitters on ARM" OFF)
-set_option(ARMNEON             "use NEON assembly blitters on ARM" OFF)
-set_option(DISKAUDIO           "Support the disk writer audio driver" ON)
-set_option(DUMMYAUDIO          "Support the dummy audio driver" ON)
-set_option(VIDEO_DIRECTFB      "Use DirectFB video driver" OFF)
-dep_option(DIRECTFB_SHARED     "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
-set_option(VIDEO_DUMMY         "Use dummy video driver" ON)
-set_option(VIDEO_OPENGL        "Include OpenGL support" ON)
-set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
-set_option(PTHREADS            "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
-dep_option(PTHREADS_SEM        "Use pthread semaphores" ON "PTHREADS" OFF)
-dep_option(OSS                 "Support the OSS audio API" ON "UNIX_SYS OR RISCOS" OFF)
-set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
-dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
-set_option(JACK                "Support the JACK audio API" ${UNIX_SYS})
-dep_option(JACK_SHARED         "Dynamically load JACK audio support" ON "JACK" OFF)
-set_option(ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
-dep_option(ESD_SHARED          "Dynamically load ESD audio support" ON "ESD" OFF)
-set_option(PIPEWIRE            "Use Pipewire audio" ${UNIX_SYS})
-dep_option(PIPEWIRE_SHARED     "Dynamically load Pipewire support" ON "PIPEWIRE" OFF)
-set_option(PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
-dep_option(PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "PULSEAUDIO" OFF)
-set_option(ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
-dep_option(ARTS_SHARED         "Dynamically load aRts audio support" ON "ARTS" OFF)
-set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
-set_option(NAS_SHARED          "Dynamically load NAS audio API" ${UNIX_SYS})
-set_option(SNDIO               "Support the sndio audio API" ${UNIX_SYS})
-dep_option(SNDIO_SHARED        "Dynamically load the sndio audio API" ${UNIX_SYS} ON "SNDIO" OFF)
-set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
-dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
-set_option(LIBSAMPLERATE       "Use libsamplerate for audio rate conversion" ${UNIX_SYS})
-dep_option(LIBSAMPLERATE_SHARED "Dynamically load libsamplerate" ON "LIBSAMPLERATE" OFF)
-set_option(RPATH               "Use an rpath when linking SDL" ${UNIX_SYS})
-set_option(CLOCK_GETTIME       "Use clock_gettime() instead of gettimeofday()" OFF)
-set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
-set_option(VIDEO_WAYLAND       "Use Wayland video driver" ${UNIX_SYS})
-dep_option(WAYLAND_SHARED      "Dynamically load Wayland support" ON "VIDEO_WAYLAND" OFF)
-dep_option(WAYLAND_LIBDECOR    "Use client-side window decorations on Wayland" ON "VIDEO_WAYLAND" ON)
-dep_option(LIBDECOR_SHARED     "Dynamically load libdecor support" ON "WAYLAND_LIBDECOR" OFF)
-dep_option(VIDEO_WAYLAND_QT_TOUCH  "QtWayland server support for Wayland video driver" ON "VIDEO_WAYLAND" OFF)
-set_option(VIDEO_RPI           "Use Raspberry Pi video driver" ${UNIX_SYS})
-dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
+option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
+#set_option(SDL_DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
+set_option(SDL_LIBC                "Use the system C library" ${OPT_DEF_LIBC})
+set_option(SDL_GCC_ATOMICS         "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
+set_option(SDL_ASSEMBLY            "Enable assembly routines" ${OPT_DEF_ASM})
+set_option(SDL_SSEMATH             "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
+set_option(SDL_MMX                 "Use MMX assembly routines" ${OPT_DEF_ASM})
+set_option(SDL_3DNOW               "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
+set_option(SDL_SSE                 "Use SSE assembly routines" ${OPT_DEF_ASM})
+set_option(SDL_SSE2                "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
+set_option(SDL_SSE3                "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
+set_option(SDL_ALTIVEC             "Use Altivec assembly routines" ${OPT_DEF_ASM})
+set_option(SDL_ARMSIMD             "use SIMD assembly blitters on ARM" OFF)
+set_option(SDL_ARMNEON             "use NEON assembly blitters on ARM" OFF)
+set_option(SDL_DISKAUDIO           "Support the disk writer audio driver" ON)
+set_option(SDL_DUMMYAUDIO          "Support the dummy audio driver" ON)
+set_option(SDL_DIRECTFB            "Use DirectFB video driver" OFF)
+dep_option(SDL_DIRECTFB_SHARED     "Dynamically load directfb support" ON "SDL_DIRECTFB" OFF)
+set_option(SDL_DUMMYVIDEO          "Use dummy video driver" ON)
+set_option(SDL_OPENGL              "Include OpenGL support" ON)
+set_option(SDL_OPENGLES            "Include OpenGL ES support" ON)
+set_option(SDL_PTHREADS            "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
+dep_option(SDL_PTHREADS_SEM        "Use pthread semaphores" ON "SDL_PTHREADS" OFF)
+dep_option(SDL_OSS                 "Support the OSS audio API" ON "UNIX_SYS OR RISCOS" OFF)
+set_option(SDL_ALSA                "Support the ALSA audio API" ${UNIX_SYS})
+dep_option(SDL_ALSA_SHARED         "Dynamically load ALSA audio support" ON "SDL_ALSA" OFF)
+set_option(SDL_JACK                "Support the JACK audio API" ${UNIX_SYS})
+dep_option(SDL_JACK_SHARED         "Dynamically load JACK audio support" ON "SDL_JACK" OFF)
+set_option(SDL_ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
+dep_option(SDL_ESD_SHARED          "Dynamically load ESD audio support" ON "SDL_ESD" OFF)
+set_option(SDL_PIPEWIRE            "Use Pipewire audio" ${UNIX_SYS})
+dep_option(SDL_PIPEWIRE_SHARED     "Dynamically load Pipewire support" ON "SDL_PIPEWIRE" OFF)
+set_option(SDL_PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
+dep_option(SDL_PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "SDL_PULSEAUDIO" OFF)
+set_option(SDL_ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
+dep_option(SDL_ARTS_SHARED         "Dynamically load aRts audio support" ON "SDL_ARTS" OFF)
+set_option(SDL_NAS                 "Support the NAS audio API" ${UNIX_SYS})
+dep_option(SDL_NAS_SHARED          "Dynamically load NAS audio support" ON "SDL_NAS" OFF)
+set_option(SDL_SNDIO               "Support the sndio audio API" ${UNIX_SYS})
+dep_option(SDL_SNDIO_SHARED        "Dynamically load the sndio audio API" ${UNIX_SYS} ON "SDL_SNDIO" OFF)
+set_option(SDL_FUSIONSOUND         "Use FusionSound audio driver" OFF)
+dep_option(SDL_FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "SDL_FUSIONSOUND" OFF)
+set_option(SDL_LIBSAMPLERATE       "Use libsamplerate for audio rate conversion" ${UNIX_SYS})
+dep_option(SDL_LIBSAMPLERATE_SHARED "Dynamically load libsamplerate" ON "SDL_LIBSAMPLERATE" OFF)
+set_option(SDL_RPATH               "Use an rpath when linking SDL" ${UNIX_SYS})
+set_option(SDL_CLOCK_GETTIME       "Use clock_gettime() instead of gettimeofday()" OFF)
+set_option(SDL_X11                 "Use X11 video driver" ${UNIX_SYS})
+dep_option(SDL_X11_SHARED          "Dynamically load X11 support" ON "SDL_X11" OFF)
 set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
 foreach(_SUB ${SDL_X11_OPTIONS})
-  string(TOUPPER "VIDEO_X11_${_SUB}" _OPT)
-  dep_option(${_OPT}           "Enable ${_SUB} support" ON "VIDEO_X11" OFF)
+  string(TOUPPER "SDL_X11_${_SUB}" _OPT)
+  dep_option(${_OPT}               "Enable ${_SUB} support" ON "SDL_X11" OFF)
 endforeach()
-set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
-set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
-set_option(XINPUT              "Use Xinput for Windows" ${WINDOWS})
-set_option(WASAPI              "Use the Windows WASAPI audio driver" ${WINDOWS})
-set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
-set_option(RENDER_METAL        "Enable the Metal render driver" ${APPLE})
-set_option(VIDEO_VIVANTE       "Use Vivante EGL video driver" ${UNIX_SYS})
-dep_option(VIDEO_VULKAN        "Enable Vulkan support" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
-set_option(VIDEO_METAL         "Enable Metal support" ${APPLE})
-set_option(VIDEO_KMSDRM        "Use KMS DRM video driver" ${UNIX_SYS})
-dep_option(KMSDRM_SHARED       "Dynamically load KMS DRM support" ON "VIDEO_KMSDRM" OFF)
-set_option(VIDEO_OFFSCREEN     "Use offscreen video driver" OFF)
-option_string(BACKGROUNDING_SIGNAL "number to use for magic backgrounding signal or 'OFF'" "OFF")
-option_string(FOREGROUNDING_SIGNAL "number to use for magic foregrounding signal or 'OFF'" "OFF")
-set_option(HIDAPI              "Use HIDAPI for low level joystick drivers" ${OPT_DEF_HIDAPI})
-set_option(JOYSTICK_VIRTUAL    "Enable the virtual-joystick driver" ON)
-set_option(ASAN                "Use AddressSanitizer to detect memory errors" OFF)
+set_option(SDL_WAYLAND             "Use Wayland video driver" ${UNIX_SYS})
+dep_option(SDL_WAYLAND_SHARED      "Dynamically load Wayland support" ON "SDL_WAYLAND" OFF)
+dep_option(SDL_WAYLAND_LIBDECOR    "Use client-side window decorations on Wayland" ON "SDL_WAYLAND" ON)
+dep_option(SDL_WAYLAND_LIBDECOR_SHARED     "Dynamically load libdecor support" ON "SDL_WAYLAND_LIBDECOR" OFF)
+dep_option(SDL_WAYLAND_QT_TOUCH    "QtWayland server support for Wayland video driver" ON "SDL_WAYLAND" OFF)
+set_option(SDL_RPI                 "Use Raspberry Pi video driver" ${UNIX_SYS})
+set_option(SDL_COCOA               "Use Cocoa video driver" ${APPLE})
+set_option(SDL_DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
+set_option(SDL_XINPUT              "Use Xinput for Windows" ${WINDOWS})
+set_option(SDL_WASAPI              "Use the Windows WASAPI audio driver" ${WINDOWS})
+set_option(SDL_RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
+set_option(SDL_RENDER_METAL        "Enable the Metal render driver" ${APPLE})
+set_option(SDL_VIVANTE             "Use Vivante EGL video driver" ${UNIX_SYS})
+dep_option(SDL_VULKAN              "Enable Vulkan support" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
+set_option(SDL_METAL               "Enable Metal support" ${APPLE})
+set_option(SDL_KMSDRM              "Use KMS DRM video driver" ${UNIX_SYS})
+dep_option(SDL_KMSDRM_SHARED       "Dynamically load KMS DRM support" ON "SDL_KMSDRM" OFF)
+set_option(SDL_OFFSCREEN           "Use offscreen video driver" OFF)
+option_string(SDL_BACKGROUNDING_SIGNAL "number to use for magic backgrounding signal or 'OFF'" "OFF")
+option_string(SDL_FOREGROUNDING_SIGNAL "number to use for magic foregrounding signal or 'OFF'" "OFF")
+set_option(SDL_HIDAPI              "Use HIDAPI for low level joystick drivers" ${OPT_DEF_HIDAPI})
+set_option(SDL_VIRTUAL_JOYSTICK    "Enable the virtual-joystick driver" ON)
+set_option(SDL_ASAN                "Use AddressSanitizer to detect memory errors" OFF)
 
 set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
 set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static version of the library")
@@ -436,27 +436,27 @@ file(GLOB SOURCE_FILES
   ${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c)
 
 
-if(ASSERTIONS STREQUAL "auto")
+if(SDL_ASSERTIONS STREQUAL "auto")
   # Do nada - use optimization settings to determine the assertion level
-elseif(ASSERTIONS STREQUAL "disabled")
+elseif(SDL_ASSERTIONS STREQUAL "disabled")
   set(SDL_DEFAULT_ASSERT_LEVEL 0)
-elseif(ASSERTIONS STREQUAL "release")
+elseif(SDL_ASSERTIONS STREQUAL "release")
   set(SDL_DEFAULT_ASSERT_LEVEL 1)
-elseif(ASSERTIONS STREQUAL "enabled")
+elseif(SDL_ASSERTIONS STREQUAL "enabled")
   set(SDL_DEFAULT_ASSERT_LEVEL 2)
-elseif(ASSERTIONS STREQUAL "paranoid")
+elseif(SDL_ASSERTIONS STREQUAL "paranoid")
   set(SDL_DEFAULT_ASSERT_LEVEL 3)
 else()
   message_error("unknown assertion level")
 endif()
-set(HAVE_ASSERTIONS ${ASSERTIONS})
+set(HAVE_ASSERTIONS ${SDL_ASSERTIONS})
 
-if(NOT BACKGROUNDING_SIGNAL STREQUAL "OFF")
-  add_definitions("-DSDL_BACKGROUNDING_SIGNAL=${BACKGROUNDING_SIGNAL}")
+if(NOT SDL_BACKGROUNDING_SIGNAL STREQUAL "OFF")
+  add_definitions("-DSDL_BACKGROUNDING_SIGNAL=${SDL_BACKGROUNDING_SIGNAL}")
 endif()
 
-if(NOT FOREGROUNDING_SIGNAL STREQUAL "OFF")
-  add_definitions("-DSDL_FOREGROUNDING_SIGNAL=${FOREGROUNDING_SIGNAL}")
+if(NOT SDL_FOREGROUNDING_SIGNAL STREQUAL "OFF")
+  add_definitions("-DSDL_FOREGROUNDING_SIGNAL=${SDL_FOREGROUNDING_SIGNAL}")
 endif()
 
 # Compiler option evaluation
@@ -492,7 +492,7 @@ if(USE_GCC OR USE_CLANG)
         int main(int argc, char **argv) { }" HAVE_DEPENDENCY_TRACKING)
   endif()
 
-  if(GCC_ATOMICS)
+  if(SDL_GCC_ATOMICS)
     check_c_source_compiles("int main(int argc, char **argv) {
         int a;
         void *x, *y, *z;
@@ -553,7 +553,7 @@ if(USE_GCC OR USE_CLANG)
   endif()
 endif()
 
-if(ASSEMBLY)
+if(SDL_ASSEMBLY)
   if(USE_GCC OR USE_CLANG)
     set(SDL_ASSEMBLY_ROUTINES 1)
     # TODO: Those all seem to be quite GCC specific - needs to be
@@ -582,7 +582,7 @@ if(ASSEMBLY)
       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
     endif()
 
-    if(3DNOW)
+    if(SDL_3DNOW)
       set(CMAKE_REQUIRED_FLAGS "-m3dnow")
       check_c_source_compiles("
           #include <mm3dnow.h>
@@ -599,7 +599,7 @@ if(ASSEMBLY)
       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
     endif()
 
-    if(SSE)
+    if(SDL_SSE)
       set(CMAKE_REQUIRED_FLAGS "-msse")
       check_c_source_compiles("
           #ifdef __MINGW32__
@@ -622,7 +622,7 @@ if(ASSEMBLY)
       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
     endif()
 
-    if(SSE2)
+    if(SDL_SSE2)
       set(CMAKE_REQUIRED_FLAGS "-msse2")
       check_c_source_compiles("
           #ifdef __MINGW32__
@@ -645,7 +645,7 @@ if(ASSEMBLY)
       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
     endif()
 
-    if(SSE3)
+    if(SDL_SSE3)
       set(CMAKE_REQUIRED_FLAGS "-msse3")
       check_c_source_compiles("
           #ifdef __MINGW32__
@@ -668,8 +668,8 @@ if(ASSEMBLY)
       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
     endif()
 
-    if(NOT SSEMATH)
-      if(SSE OR SSE2 OR SSE3)
+    if(NOT SDL_SSEMATH)
+      if(SDL_SSE OR SDL_SSE2 OR SDL_SSE3)
         if(USE_GCC)
           check_c_compiler_flag(-mfpmath=387 HAVE_FP_387)
           if(HAVE_FP_387)
@@ -682,7 +682,7 @@ if(ASSEMBLY)
 
     check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
 
-    if(ALTIVEC)
+    if(SDL_ALTIVEC)
       set(CMAKE_REQUIRED_FLAGS "-maltivec")
       check_c_source_compiles("
           #include <altivec.h>
@@ -706,7 +706,7 @@ if(ASSEMBLY)
       endif()
     endif()
 
-    if(ARMSIMD)
+    if(SDL_ARMSIMD)
       set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
       set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
       check_c_source_compiles("
@@ -732,7 +732,7 @@ if(ASSEMBLY)
       endif()
     endif()
 
-    if(ARMNEON)
+    if(SDL_ARMNEON)
       set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
       set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
       check_c_source_compiles("
@@ -777,7 +777,7 @@ endif()
 
 # TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
 # anything.
-if(LIBC)
+if(SDL_LIBC)
   if(WINDOWS AND NOT MINGW)
     set(HAVE_LIBC TRUE)
     foreach(_HEADER stdio.h string.h wchar.h ctype.h math.h limits.h)
@@ -920,13 +920,13 @@ endif()
 # General SDL subsystem options, valid for all platforms
 if(SDL_AUDIO)
   # CheckDummyAudio/CheckDiskAudio - valid for all platforms
-  if(DUMMYAUDIO)
+  if(SDL_DUMMYAUDIO)
     set(SDL_AUDIO_DRIVER_DUMMY 1)
     file(GLOB DUMMYAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dummy/*.c)
     set(SOURCE_FILES ${SOURCE_FILES} ${DUMMYAUDIO_SOURCES})
     set(HAVE_DUMMYAUDIO TRUE)
   endif()
-  if(DISKAUDIO)
+  if(SDL_DISKAUDIO)
     set(SDL_AUDIO_DRIVER_DISK 1)
     file(GLOB DISKAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/disk/*.c)
     set(SOURCE_FILES ${SOURCE_FILES} ${DISKAUDIO_SOURCES})
@@ -947,7 +947,8 @@ if(UNIX OR APPLE)
 endif()
 
 if(SDL_JOYSTICK)
-  if(JOYSTICK_VIRTUAL)
+  if(SDL_VIRTUAL_JOYSTICK)
+    set(HAVE_VIRTUAL_JOYSTICK TRUE)
     set(SDL_JOYSTICK_VIRTUAL 1)
     file(GLOB JOYSTICK_VIRTUAL_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/virtual/*.c)
     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_VIRTUAL_SOURCES})
@@ -955,18 +956,18 @@ if(SDL_JOYSTICK)
 endif()
 
 if(SDL_VIDEO)
-  if(VIDEO_DUMMY)
+  if(SDL_DUMMYVIDEO)
     set(SDL_VIDEO_DRIVER_DUMMY 1)
     file(GLOB VIDEO_DUMMY_SOURCES ${SDL2_SOURCE_DIR}/src/video/dummy/*.c)
     set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_DUMMY_SOURCES})
-    set(HAVE_VIDEO_DUMMY TRUE)
+    set(HAVE_DUMMY TRUE)
     set(HAVE_SDL_VIDEO TRUE)
   endif()
-  if(VIDEO_OFFSCREEN)
+  if(SDL_OFFSCREEN)
     set(SDL_VIDEO_DRIVER_OFFSCREEN 1)
     file(GLOB VIDEO_OFFSCREEN_SOURCES ${SDL2_SOURCE_DIR}/src/video/offscreen/*.c)
     set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_OFFSCREEN_SOURCES})
-    set(HAVE_VIDEO_OFFSCREEN TRUE)
+    set(HAVE_OFFSCREEN TRUE)
     set(HAVE_SDL_VIDEO TRUE)
   endif()
 endif()
@@ -1078,9 +1079,9 @@ if(ANDROID)
     endif()
 
     #enable gles
-    if(VIDEO_OPENGLES)
+    if(SDL_OPENGLES)
       set(SDL_VIDEO_OPENGL_EGL 1)
-      set(HAVE_VIDEO_OPENGLES TRUE)
+      set(HAVE_OPENGLES TRUE)
       set(SDL_VIDEO_OPENGL_ES 1)
       set(SDL_VIDEO_RENDER_OGL_ES 1)
       set(SDL_VIDEO_OPENGL_ES2 1)
@@ -1101,7 +1102,7 @@ if(ANDROID)
     }
     " VULKAN_PASSED_ANDROID_CHECKS)
     if(NOT VULKAN_PASSED_ANDROID_CHECKS)
-      set(VIDEO_VULKAN OFF)
+      set(SDL_VULKAN OFF)
       message(STATUS "Vulkan doesn't work on this configuration")
     endif()
   endif()
@@ -1147,7 +1148,7 @@ elseif(EMSCRIPTEN)
     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
     set(HAVE_SDL_TIMERS TRUE)
 
-    if(CLOCK_GETTIME)
+    if(SDL_CLOCK_GETTIME)
       set(HAVE_CLOCK_GETTIME 1)
     endif()
   endif()
@@ -1158,9 +1159,9 @@ elseif(EMSCRIPTEN)
     set(HAVE_SDL_VIDEO TRUE)
 
     #enable gles
-    if(VIDEO_OPENGLES)
+    if(SDL_OPENGLES)
       set(SDL_VIDEO_OPENGL_EGL 1)
-      set(HAVE_VIDEO_OPENGLES TRUE)
+      set(HAVE_OPENGLES TRUE)
       set(SDL_VIDEO_OPENGL_ES2 1)
       set(SDL_VIDEO_RENDER_OGL_ES2 1)
     endif()
@@ -1366,7 +1367,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS AND NOT HAIKU)
 
   CheckPTHREAD()
 
-  if(CLOCK_GETTIME)
+  if(SDL_CLOCK_GETTIME)
     check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME)
     if(FOUND_CLOCK_GETTIME)
       list(APPEND EXTRA_LIBS rt)
@@ -1418,7 +1419,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS AND NOT HAIKU)
   endif()
 
   set(SDL_RLD_FLAGS "")
-  if(RPATH AND SDL_SHARED)
+  if(SDL_RPATH AND SDL_SHARED)
     if(BSDI OR FREEBSD OR LINUX OR NETBSD)
       set(CMAKE_REQUIRED_FLAGS "-Wl,--enable-new-dtags")
       check_c_compiler_flag("" HAVE_ENABLE_NEW_DTAGS)
@@ -1468,7 +1469,7 @@ elseif(WINDOWS)
   set(HAVE_SDL_MISC TRUE)
 
   # Check for DirectX
-  if(DIRECTX)
+  if(SDL_DIRECTX)
     if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
         set(USE_WINSDK_DIRECTX TRUE)
     endif()
@@ -1499,7 +1500,7 @@ elseif(WINDOWS)
     set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   endif()
 
-  if(XINPUT)
+  if(SDL_XINPUT)
     # xinput.h may need windows.h, but does not include it itself.
     check_c_source_compiles("
       #include <windows.h>
@@ -1536,7 +1537,7 @@ elseif(WINDOWS)
       set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
     endif()
 
-    if(WASAPI AND HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
+    if(SDL_WASAPI AND HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
       set(SDL_AUDIO_DRIVER_WASAPI 1)
       file(GLOB WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/*.c)
       if(WINDOWS_STORE)
@@ -1564,11 +1565,11 @@ elseif(WINDOWS)
     endif()
     set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES})
 
-    if(RENDER_D3D AND HAVE_D3D_H AND NOT WINDOWS_STORE)
+    if(SDL_RENDER_D3D AND HAVE_D3D_H AND NOT WINDOWS_STORE)
       set(SDL_VIDEO_RENDER_D3D 1)
       set(HAVE_RENDER_D3D TRUE)
     endif()
-    if(RENDER_D3D AND HAVE_D3D11_H)
+    if(SDL_RENDER_D3D AND HAVE_D3D11_H)
       set(SDL_VIDEO_RENDER_D3D11 1)
       set(HAVE_RENDER_D3D TRUE)
     endif()
@@ -1661,18 +1662,18 @@ elseif(WINDOWS)
   set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
 
   if(SDL_VIDEO)
-    if(VIDEO_OPENGL AND NOT WINDOWS_STORE)
+    if(SDL_OPENGL AND NOT WINDOWS_STORE)
       set(SDL_VIDEO_OPENGL 1)
       set(SDL_VIDEO_OPENGL_WGL 1)
       set(SDL_VIDEO_RENDER_OGL 1)
-      set(HAVE_VIDEO_OPENGL TRUE)
+      set(HAVE_OPENGL TRUE)
     endif()
 
-    if(VIDEO_OPENGLES)
+    if(SDL_OPENGLES)
       set(SDL_VIDEO_OPENGL_EGL 1)
       set(SDL_VIDEO_OPENGL_ES2 1)
       set(SDL_VIDEO_RENDER_OGL_ES2 1)
-      set(HAVE_VIDEO_OPENGLES TRUE)
+      set(HAVE_OPENGLES TRUE)
     endif()
   endif()
 
@@ -1875,15 +1876,15 @@ elseif(APPLE)
       set(SOURCE_FILES ${SOURCE_FILES} ${UIKITVIDEO_SOURCES})
     else()
       CheckCOCOA()
-      if(VIDEO_OPENGL)
+      if(SDL_OPENGL)
         set(SDL_VIDEO_OPENGL 1)
         set(SDL_VIDEO_OPENGL_CGL 1)
         set(SDL_VIDEO_RENDER_OGL 1)
-        set(HAVE_VIDEO_OPENGL TRUE)
+        set(HAVE_OPENGL TRUE)
       endif()
     endif()
 
-    if(VIDEO_OPENGLES)
+    if(SDL_OPENGLES)
       if(IOS OR TVOS)
         set(SDL_FRAMEWORK_OPENGLES 1)
         set(SDL_VIDEO_OPENGL_ES 1)
@@ -1893,10 +1894,10 @@ elseif(APPLE)
       endif()
       set(SDL_VIDEO_OPENGL_ES2 1)
       set(SDL_VIDEO_RENDER_OGL_ES2 1)
-      set(HAVE_VIDEO_OPENGLES TRUE)
+      set(HAVE_OPENGLES TRUE)
     endif()
 
-    if(VIDEO_VULKAN OR VIDEO_METAL OR RENDER_METAL)
+    if(SDL_VULKAN OR SDL_METAL OR SDL_RENDER_METAL)
       set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
       set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -ObjC")
       check_c_source_compiles("
@@ -1917,18 +1918,18 @@ elseif(APPLE)
         set(SDL_FRAMEWORK_METAL 1)
         set(SDL_FRAMEWORK_QUARTZCORE 1)
       else()
-        set(VIDEO_VULKAN 0)
-        set(VIDEO_METAL 0)
-        set(RENDER_METAL 0)
+        set(SDL_VULKAN 0)
+        set(SDL_METAL 0)
+        set(SDL_RENDER_METAL 0)
       endif()
     endif()
 
-    if(VIDEO_METAL)
+    if(SDL_METAL)
       set(SDL_VIDEO_METAL 1)
-      set(HAVE_VIDEO_METAL TRUE)
+      set(HAVE_METAL TRUE)
     endif()
 
-    if(RENDER_METAL)
+    if(SDL_RENDER_METAL)
       file(GLOB RENDER_METAL_SOURCES ${SDL2_SOURCE_DIR}/src/render/metal/*.m)
       set(SOURCE_FILES ${SOURCE_FILES} ${RENDER_METAL_SOURCES})
       set(SDL_VIDEO_RENDER_METAL 1)
@@ -2047,13 +2048,13 @@ elseif(HAIKU)
     set(SOURCE_FILES ${SOURCE_FILES} ${HAIKUVIDEO_SOURCES})
     set(HAVE_SDL_VIDEO TRUE)
 
-    if(VIDEO_OPENGL)
+    if(SDL_OPENGL)
       # TODO: Use FIND_PACKAGE(OpenGL) instead
       set(SDL_VIDEO_OPENGL 1)
       set(SDL_VIDEO_OPENGL_HAIKU 1)
       set(SDL_VIDEO_RENDER_OGL 1)
       list(APPEND EXTRA_LIBS GL)
-      set(HAVE_VIDEO_OPENGL TRUE)
+      set(HAVE_OPENGL TRUE)
     endif()
   endif()
 
@@ -2101,7 +2102,7 @@ elseif(RISCOS)
     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
     set(HAVE_SDL_TIMERS TRUE)
 
-    if(CLOCK_GETTIME)
+    if(SDL_CLOCK_GETTIME)
       set(HAVE_CLOCK_GETTIME 1)
     endif()
   endif()
@@ -2183,10 +2184,10 @@ elseif(VITA)
         list(APPEND EXTRA_LIBS
           pib
         )
-        set(HAVE_VIDEO_VITA_PIB ON)
+        set(HAVE_VITA_PIB ON)
         set(SDL_VIDEO_VITA_PIB 1)
       else()
-        set(HAVE_VIDEO_VITA_PIB OFF)
+        set(HAVE_VITA_PIB OFF)
       endif()
     endif()
 
@@ -2196,7 +2197,7 @@ elseif(VITA)
       if(HAVE_PVR_H)
         add_definitions("-D__psp2__")
         set(SDL_VIDEO_OPENGL_EGL 1)
-        set(HAVE_VIDEO_OPENGLES TRUE)
+        set(HAVE_OPENGLES TRUE)
         set(SDL_VIDEO_OPENGL_ES 1)
         set(SDL_VIDEO_RENDER_OGL_ES 1)
         set(SDL_VIDEO_OPENGL_ES2 1)
@@ -2206,10 +2207,10 @@ elseif(VITA)
           libgpu_es4_ext_stub_weak
           libIMGEGL_stub_weak
         )
-        set(HAVE_VIDEO_VITA_PVR ON)
+        set(HAVE_VITA_PVR ON)
         set(SDL_VIDEO_VITA_PVR 1)
       else()
-        set(HAVE_VIDEO_VITA_PVR OFF)
+        set(HAVE_VITA_PVR OFF)
       endif()
     endif()
 
@@ -2233,7 +2234,7 @@ elseif(VITA)
       SceProcessmgr_stub
       m
     )
-    if(HAVE_VIDEO_VITA_PIB)
+    if(HAVE_VITA_PIB)
         list(PREPEND EXTRA_LIBS
           pib
           libScePiglet_stub
@@ -2267,14 +2268,14 @@ elseif(VITA)
 
 endif()
 
-if(VIDEO_VULKAN AND NOT SDL_LOADSO)
+if(SDL_VULKAN AND NOT SDL_LOADSO)
   message(STATUS "Vulkan support is available, but disabled because there's no loadso.")
-  set(VIDEO_VULKAN OFF)
+  set(SDL_VULKAN OFF)
 endif()
 
-if(VIDEO_VULKAN)
+if(SDL_VULKAN)
   set(SDL_VIDEO_VULKAN 1)
-  set(HAVE_VIDEO_VULKAN TRUE)
+  set(HAVE_VULKAN TRUE)
 endif()
 
 # Dummies
@@ -2494,7 +2495,7 @@ macro(asan_check_add_debug_flag2 ASAN_FLAG)
 endmacro()
 
 # enable AddressSanitizer if supported
-if (ASAN)
+if (SDL_ASAN)
   asan_check_add_debug_flag2("address")
   asan_check_add_debug_flag("bool")
   asan_check_add_debug_flag("bounds")
@@ -2532,10 +2533,10 @@ message(STATUS "")
 message(STATUS "Options:")
 list(SORT ALLOPTIONS)
 foreach(_OPT ${ALLOPTIONS})
-  # Longest option is VIDEO_X11_XSCREENSAVER = 22 characters
+  # Longest option is SDL_WAYLAND_LIBDECOR_SHARED = 27 characters
   # Get the padding
   string(LENGTH ${_OPT} _OPTLEN)
-  math(EXPR _PADLEN "23 - ${_OPTLEN}")
+  math(EXPR _PADLEN "28 - ${_OPTLEN}")
   string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
   message_tested_option(${_OPT} ${_PADDING})
 endforeach()
@@ -2569,7 +2570,7 @@ if(WARN_ABOUT_ARM_SIMD_ASM_MIT)
   message(STATUS "uses code licensed under the MIT license. If this is a")
   message(STATUS "problem, please disable that code by rerunning CMake with:")
   message(STATUS "")
-  message(STATUS "    -DARMSIMD=OFF")
+  message(STATUS "    -DSDL_ARMSIMD=OFF")
 endif()
 
 if(WARN_ABOUT_ARM_NEON_ASM_MIT)
@@ -2578,7 +2579,7 @@ if(WARN_ABOUT_ARM_NEON_ASM_MIT)
   message(STATUS "uses code licensed under the MIT license. If this is a")
   message(STATUS "problem, please disable that code by rerunning CMake with:")
   message(STATUS "")
-  message(STATUS "    -DARMNEON=OFF")
+  message(STATUS "    -DSDL_ARMNEON=OFF")
 endif()
 
 # Ensure that the extra cflags are used at compile time
@@ -2623,7 +2624,7 @@ if(SDL_SHARED)
       SOVERSION ${LT_REVISION}
       OUTPUT_NAME "SDL2")
   endif()
-  if(MSVC AND NOT LIBC)
+  if(MSVC AND NOT SDL_LIBC)
     # Don't try to link with the default set of libraries.
     if(NOT WINDOWS_STORE)
       set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
@@ -2651,7 +2652,7 @@ if(ANDROID)
     add_library(SDL2::hidapi ALIAS hidapi)
   endif()
 
-  if(MSVC AND NOT LIBC)
+  if(MSVC AND NOT SDL_LIBC)
     # Don't try to link with the default set of libraries.
     set_target_properties(hidapi PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
     set_target_properties(hidapi PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
@@ -2675,7 +2676,7 @@ if(SDL_STATIC)
     # clobbered, when the suffix is realized via subsequent rename.
   endif()
   set_target_properties(SDL2-static PROPERTIES POSITION_INDEPENDENT_CODE ${SDL_STATIC_PIC})
-  if(MSVC AND NOT LIBC)
+  if(MSVC AND NOT SDL_LIBC)
     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
     set_target_properties(SDL2-static PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
diff --git a/build-scripts/checker-buildbot.sh b/build-scripts/checker-buildbot.sh
index e8f2f22..be89fd7 100755
--- a/build-scripts/checker-buildbot.sh
+++ b/build-scripts/checker-buildbot.sh
@@ -27,7 +27,7 @@ cd checker-buildbot
 # The -Wno-liblto is new since our checker-279 upgrade, I think; checker otherwise warns "libLTO.dylib relative to clang installed dir not found"
 
 # You might want to do this for CMake-backed builds instead...
-scan-build -o analysis cmake -G Ninja -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
+scan-build -o analysis cmake -G Ninja -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
 
 # ...or run configure without the scan-build wrapper...
 #CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0 -Wno-deprecated-declarations" LDFLAGS="-Wno-liblto" ../configure --enable-assertions=enabled
diff --git a/build-scripts/codechecker-buildbot.sh b/build-scripts/codechecker-buildbot.sh
index e8c0a4c..76b7853 100755
--- a/build-scripts/codechecker-buildbot.sh
+++ b/build-scripts/codechecker-buildbot.sh
@@ -24,7 +24,7 @@ mkdir codechecker-buildbot
 cd codechecker-buildbot
 
 # We turn off deprecated declarations, because we don't care about these warnings during static analysis.
-cmake -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
+cmake -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
 
 # CMake on macOS adds "-arch arm64" or whatever is appropriate, but this confuses CodeChecker, so strip it out.
 perl -w -pi -e 's/\-arch\s+.*?\s+//g;' compile_commands.json
diff --git a/cmake/macros.cmake b/cmake/macros.cmake
index cc955bd..578670b 100644
--- a/cmake/macros.cmake
+++ b/cmake/macros.cmake
@@ -42,12 +42,18 @@ macro(MESSAGE_TESTED_OPTION _NAME)
   if(${ARGC} EQUAL 2)
     set(_PAD ${ARGV1})
   endif()
-  if(NOT HAVE_${_NAME})
-    set(HAVE_${_NAME} OFF)
-  elseif("${HAVE_${_NAME}}" MATCHES "1|TRUE|YES|Y")
-    set(HAVE_${_NAME} ON)
+  string(SUBSTRING "${_NAME}" 0 4 _NAMESTART)
+  if(_NAMESTART STREQUAL "SDL_")
+    string(SUBSTRING "${_NAME}" 4 -1 _STRIPPEDNAME)
+  else()
+    set(_STRIPPEDNAME "${_NAME}")
+  endif()
+  if(NOT HAVE_${_STRIPPEDNAME})
+    set(HAVE_${_STRIPPEDNAME} OFF)
+  elseif("${HAVE_${_STRIPPEDNAME}}" MATCHES "1|TRUE|YES|Y")
+    set(HAVE_${_STRIPPEDNAME} ON)
   endif()
-  message(STATUS "  ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_NAME}}")
+  message(STATUS "  ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}")
 endmacro()
 
 macro(LISTTOSTR _LIST _OUTPUT)
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index 5e70eae..ea2a421 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -57,7 +57,7 @@ endmacro()
 # Requires:
 # - n/a
 macro(CheckOSS)
-  if(OSS)
+  if(SDL_OSS)
     set(OSS_HEADER_FILE "sys/soundcard.h")
     check_c_source_compiles("
         #include <sys/soundcard.h>
@@ -88,10 +88,10 @@ endmacro()
 # Requires:
 # - n/a
 # Optional:
-# - ALSA_SHARED opt
+# - SDL_ALSA_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckALSA)
-  if(ALSA)
+  if(SDL_ALSA)
     CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
     if(HAVE_ASOUNDLIB_H)
       CHECK_LIBRARY_EXISTS(asound snd_pcm_recover "" HAVE_LIBASOUND)
@@ -101,10 +101,10 @@ macro(CheckALSA)
       file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
       set(SDL_AUDIO_DRIVER_ALSA 1)
-      if(ALSA_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_ALSA_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
       endif()
-      if(ALSA_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_ALSA_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME("asound")
         set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
         set(HAVE_ALSA_SHARED TRUE)
@@ -119,10 +119,10 @@ endmacro()
 # Requires:
 # - PkgCheckModules
 # Optional:
-# - PIPEWIRE_SHARED opt
+# - SDL_PIPEWIRE_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckPipewire)
-    if(PIPEWIRE)
+    if(SDL_PIPEWIRE)
         pkg_check_modules(PKG_PIPEWIRE libpipewire-0.3>=0.3.20)
         if(PKG_PIPEWIRE_FOUND)
             set(HAVE_PIPEWIRE TRUE)
@@ -130,10 +130,10 @@ macro(CheckPipewire)
             set(SOURCE_FILES ${SOURCE_FILES} ${PIPEWIRE_SOURCES})
             set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
             list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS})
-            if(PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
+            if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
                 message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
             endif()
-            if(PIPEWIRE_SHARED AND HAVE_SDL_LOADSO)
+            if(SDL_PIPEWIRE_SHARED AND HAVE_SDL_LOADSO)
                 FindLibraryAndSONAME("pipewire-0.3")
                 set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
                 set(HAVE_PIPEWIRE_SHARED TRUE)
@@ -149,10 +149,10 @@ endmacro()
 # Requires:
 # - PkgCheckModules
 # Optional:
-# - PULSEAUDIO_SHARED opt
+# - SDL_PULSEAUDIO_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckPulseAudio)
-  if(PULSEAUDIO)
+  if(SDL_PULSEAUDIO)
     pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
     if(PKG_PULSEAUDIO_FOUND)
       set(HAVE_PULSEAUDIO TRUE)
@@ -160,15 +160,15 @@ macro(CheckPulseAudio)
       set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
       set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
       list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
-      if(PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
       endif()
-      if(PULSEAUDIO_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_PULSEAUDIO_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME("pulse-simple")
         set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
         set(HAVE_PULSEAUDIO_SHARED TRUE)
       else()
-        list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
+        list(APPEND EXTRA_LDFLAGS ${PKG_sPULSEAUDIO_LDFLAGS})
       endif()
       set(HAVE_SDL_AUDIO TRUE)
     endif()
@@ -178,10 +178,10 @@ endmacro()
 # Requires:
 # - PkgCheckModules
 # Optional:
-# - JACK_SHARED opt
+# - SDL_JACK_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckJACK)
-  if(JACK)
+  if(SDL_JACK)
     pkg_check_modules(PKG_JACK jack)
     if(PKG_JACK_FOUND)
       set(HAVE_JACK TRUE)
@@ -189,10 +189,10 @@ macro(CheckJACK)
       set(SOURCE_FILES ${SOURCE_FILES} ${JACK_SOURCES})
       set(SDL_AUDIO_DRIVER_JACK 1)
       list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS})
-      if(JACK_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
       endif()
-      if(JACK_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_JACK_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME("jack")
         set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
         set(HAVE_JACK_SHARED TRUE)
@@ -207,10 +207,10 @@ endmacro()
 # Requires:
 # - PkgCheckModules
 # Optional:
-# - ESD_SHARED opt
+# - SDL_ESD_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckESD)
-  if(ESD)
+  if(SDL_ESD)
     pkg_check_modules(PKG_ESD esound)
     if(PKG_ESD_FOUND)
       set(HAVE_ESD TRUE)
@@ -218,10 +218,10 @@ macro(CheckESD)
       set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
       set(SDL_AUDIO_DRIVER_ESD 1)
       list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
-      if(ESD_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_ESD_SHARED AND NOT HAVE_SDL_LOADSO)
           message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
       endif()
-      if(ESD_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_ESD_SHARED AND HAVE_SDL_LOADSO)
           FindLibraryAndSONAME(esd)
           set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
           set(HAVE_ESD_SHARED TRUE)
@@ -236,10 +236,10 @@ endmacro()
 # Requires:
 # - n/a
 # Optional:
-# - ARTS_SHARED opt
+# - SDL_ARTS_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckARTS)
-  if(ARTS)
+  if(SDL_ARTS)
     find_program(ARTS_CONFIG arts-config)
     if(ARTS_CONFIG)
       execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
@@ -251,10 +251,10 @@ macro(CheckARTS)
       set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
       set(SDL_AUDIO_DRIVER_ARTS 1)
       set(HAVE_ARTS TRUE)
-      if(ARTS_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_ARTS_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
       endif()
-      if(ARTS_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_ARTS_SHARED AND HAVE_SDL_LOADSO)
         # TODO
         FindLibraryAndSONAME(artsc)
         set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
@@ -270,10 +270,10 @@ endmacro()
 # Requires:
 # - n/a
 # Optional:
-# - NAS_SHARED opt
+# - SDL_NAS_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckNAS)
-  if(NAS)
+  if(SDL_NAS)
     # TODO: set include paths properly, so the NAS headers are found
     check_include_file(audio/audiolib.h HAVE_NAS_H)
     find_library(D_NAS_LIB audio)
@@ -282,10 +282,10 @@ macro(CheckNAS)
       file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
       set(SDL_AUDIO_DRIVER_NAS 1)
-      if(NAS_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_NAS_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
       endif()
-      if(NAS_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_NAS_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME("audio")
         set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
         set(HAVE_NAS_SHARED TRUE)
@@ -300,10 +300,10 @@ endmacro()
 # Requires:
 # - n/a
 # Optional:
-# - SNDIO_SHARED opt
+# - SDL_SNDIO_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckSNDIO)
-  if(SNDIO)
+  if(SDL_SNDIO)
     # TODO: set include paths properly, so the sndio headers are found
     check_include_file(sndio.h HAVE_SNDIO_H)
     find_library(D_SNDIO_LIB sndio)
@@ -312,10 +312,10 @@ macro(CheckSNDIO)
       file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
       set(SDL_AUDIO_DRIVER_SNDIO 1)
-      if(SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
       endif()
-      if(SNDIO_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_SNDIO_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME("sndio")
         set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
         set(HAVE_SNDIO_SHARED TRUE)
@@ -357,19 +357,19 @@ macro(CheckFusionSound)
 endmacro()
 
 # Requires:
-# - LIBSAMPLERATE
+# - SDL_LIBSAMPLERATE
 # Optional:
-# - LIBSAMPLERATE_SHARED opt
+# - SDL_LIBSAMPLERATE_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckLibSampleRate)
-  if(LIBSAMPLERATE)
+  if(SDL_LIBSAMPLERATE)
     check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)
     if(HAVE_LIBSAMPLERATE_H)
       set(HAVE_LIBSAMPLERATE TRUE)
-      if(LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
       endif()
-      if(LIBSAMPLERATE_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_LIBSAMPLERATE_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME("samplerate")
         set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
         set(HAVE_LIBSAMPLERATE_SHARED TRUE)
@@ -383,10 +383,10 @@ endmacro()
 # Requires:
 # - n/a
 # Optional:
-# - X11_SHARED opt
+# - SDL_X11_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckX11)
-  if(VIDEO_X11)
+  if(SDL_X11)
     foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
         FindLibraryAndSONAME("${_LIB}")
     endforeach()
@@ -423,15 +423,16 @@ macro(CheckX11)
         message_error("Missing Xext.h, maybe you need to install the libxext-dev package?")
       endif()
 
-      set(HAVE_VIDEO_X11 TRUE)
+      set(HAVE_X11 TRUE)
       set(HAVE_SDL_VIDEO TRUE)
 
       file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${X11_SOURCES})
       set(SDL_VIDEO_DRIVER_X11 1)
 
+      # !!! FIXME: why is this disabled for Apple?
       if(APPLE)
-        set(X11_SHARED OFF)
+        set(SDL_X11_SHARED OFF)
       endif()
 
       check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT)
@@ -446,7 +447,7 @@ macro(CheckX11)
         endif()
       endif()
 
-      if(X11_SHARED)
+      if(SDL_X11_SHARED)
         if(NOT HAVE_SDL_LOADSO)
           message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
           set(HAVE_X11_SHARED FALSE)
@@ -478,8 +479,8 @@ macro(CheckX11)
 
       check_symbol_exists(XkbKeycodeToKeysym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
 
-      if(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
-        set(HAVE_VIDEO_X11_XCURSOR TRUE)
+      if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H)
+        set(HAVE_X11_XCURSOR TRUE)
         if(HAVE_X11_SHARED AND XCURSOR_LIB)
           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
         else()
@@ -488,8 +489,8 @@ macro(CheckX11)
         set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
       endif()
 
-      if(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
-        set(HAVE_VIDEO_X11_XINERAMA TRUE)
+      if(SDL_X11_XINERAMA AND HAVE_XINERAMA_H)
+        set(HAVE_X11_XINERAMA TRUE)
         if(HAVE_X11_SHARED AND XINERAMA_LIB)
           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB_SONAME}\"")
         else()
@@ -498,8 +499,8 @@ macro(CheckX11)
         set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
       endif()
 
-      if(VIDEO_X11_XINPUT AND HAVE_XINPUT2_H)
-        set(HAVE_VIDEO_X11_XINPUT TRUE)
+      if(SDL_X11_XINPUT AND HAVE_XINPUT2_H)
+        set(HAVE_X11_XINPUT TRUE)
         if(HAVE_X11_SHARED AND XI_LIB)
           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
         else()
@@ -524,45 +525,45 @@ macro(CheckX11)
         endif()
       endif()
 
-      if(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
+      if(SDL_X11_XRANDR AND HAVE_XRANDR_H)
         if(HAVE_X11_SHARED AND XRANDR_LIB)
           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
         else()
           list(APPEND EXTRA_LIBS ${XRANDR_LIB})
         endif()
         set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
-        set(HAVE_VIDEO_X11_XRANDR TRUE)
+        set(HAVE_X11_XRANDR TRUE)
       endif()
 
-      if(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
+      if(SDL_X11_XSCRNSAVER AND HAVE_XSS_H)
         if(HAVE_X11_SHARED AND XSS_LIB)
           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
         else()
           list(APPEND EXTRA_LIBS ${XSS_LIB})
         endif()
         set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
-        set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
+        set(HAVE_X11_XSCRNSAVER TRUE)
       endif()
 
-      if(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
+      if(SDL_X11_XSHAPE AND HAVE_XSHAPE_H)
         set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
-        set(HAVE_VIDEO_X11_XSHAPE TRUE)
+        set(HAVE_X11_XSHAPE TRUE)
       endif()
 
-      if(VIDEO_X11_XVM AND HAVE_XF86VM_H)
+      if(SDL_X11_XVM AND HAVE_XF86VM_H)
         if(HAVE_X11_SHARED AND XXF86VM_LIB)
           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XXF86VM_LIB_SONAME}\"")
         else()
           list(APPEND EXTRA_LIBS ${XXF86VM_LIB})
         endif()
         set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
-        set(HAVE_VIDEO_X11_XVM TRUE)
+        set(HAVE_X11_XVM TRUE)
       endif()
 
       set(CMAKE_REQUIRED_LIBRARIES)
     endif()
   endif()
-  if(NOT HAVE_VIDEO_X11)
+  if(NOT HAVE_X11)
     # Prevent Mesa from including X11 headers
     list(APPEND EXTRA_CFLAGS "-DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11")
   endif()
@@ -593,14 +594,14 @@ endmacro()
 # - EGL
 # - PkgCheckModules
 # Optional:
-# - WAYLAND_SHARED opt
+# - SDL_WAYLAND_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckWayland)
-  if(VIDEO_WAYLAND)
+  if(SDL_WAYLAND)
     pkg_check_modules(WAYLAND wayland-client wayland-scanner wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
     pkg_check_modules(WAYLAND_SCANNER_1_15 "wayland-scanner>=1.15")
 
-    if(WAYLAND_FOUND AND HAVE_VIDEO_OPENGL_EGL)
+    if(WAYLAND_FOUND AND HAVE_OPENGL_EGL)
       execute_process(
         COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=wayland_scanner wayland-scanner
         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
@@ -627,7 +628,7 @@ macro(CheckWayland)
       include_directories(
           ${WAYLAND_INCLUDE_DIRS}
       )
-      set(HAVE_VIDEO_WAYLAND TRUE)
+      set(HAVE_WAYLAND TRUE)
       set(HAVE_SDL_VIDEO TRUE)
 
       file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
@@ -643,15 +644,15 @@ macro(CheckWayland)
         WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}")
       endforeach()
 
-      if(VIDEO_WAYLAND_QT_TOUCH)
-          set(HAVE_VIDEO_WAYLAND_QT_TOUCH TRUE)
+      if(SDL_WAYLAND_QT_TOUCH)
+          set(HAVE_WAYLAND_QT_TOUCH TRUE)
           set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
       endif()
 
-      if(WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
       endif()
-      if(WAYLAND_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_WAYLAND_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME(wayland-client)
         FindLibraryAndSONAME(wayland-egl)
         FindLibraryAndSONAME(wayland-cursor)
@@ -665,17 +666,17 @@ macro(CheckWayland)
         set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
       endif()
 
-      if(WAYLAND_LIBDECOR)
+      if(SDL_WAYLAND_LIBDECOR)
         pkg_check_modules(LIBDECOR libdecor-0)
         if(LIBDECOR_FOUND)
             set(HAVE_WAYLAND_LIBDECOR TRUE)
             set(HAVE_LIBDECOR_H 1)
             link_directories(${LIBDECOR_LIBRARY_DIRS})
             include_directories(${LIBDECOR_INCLUDE_DIRS})
-            if(LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
+            if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
                 message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
             endif()
-            if(LIBDECOR_SHARED AND HAVE_SDL_LOADSO)
+            if(SDL_WAYLAND_LIBDECOR_SHARED AND HAVE_SDL_LOADSO)
                 set(HAVE_LIBDECOR_SHARED TRUE)
                 FindLibraryAndSONAME(decor-0)
                 set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
@@ -694,11 +695,11 @@ endmacro()
 # - n/a
 #
 macro(CheckCOCOA)
-  if(VIDEO_COCOA)
+  if(SDL_COCOA)
     if(APPLE) # Apple always has Cocoa.
-      set(HAVE_VIDEO_COCOA TRUE)
+      set(HAVE_COCOA TRUE)
     endif()
-    if(HAVE_VIDEO_COCOA)
+    if(HAVE_COCOA)
       file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
       set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
       set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
@@ -714,19 +715,19 @@ endmacro()
 # - DIRECTFB_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckDirectFB)
-  if(VIDEO_DIRECTFB)
+  if(SDL_DIRECTFB)
     pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
     if(PKG_DIRECTFB_FOUND)
-      set(HAVE_VIDEO_DIRECTFB TRUE)
+      set(HAVE_DIRECTFB TRUE)
       file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${DIRECTFB_SOURCES})
       set(SDL_VIDEO_DRIVER_DIRECTFB 1)
       set(SDL_VIDEO_RENDER_DIRECTFB 1)
       list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
-      if(DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
       endif()
-      if(DIRECTFB_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_DIRECTFB_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME("directfb")
         set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
         set(HAVE_DIRECTFB_SHARED TRUE)
@@ -741,41 +742,41 @@ endmacro()
 # Requires:
 # - n/a
 macro(CheckVivante)
-  if(VIDEO_VIVANTE)
+  if(SDL_VIVANTE)
     check_c_source_compiles("
         #include <gc_vdk.h>
-        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_VDK)
+        int main(int argc, char** argv) {}" HAVE_VIVANTE_VDK)
     check_c_source_compiles("
         #define LINUX
         #define EGL_API_FB
         #include <EGL/eglvivante.h>
-        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_EGL_FB)
-    if(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
-      set(HAVE_VIDEO_VIVANTE TRUE)
+        int main(int argc, char** argv) {}" HAVE_VIVANTE_EGL_FB)
+    if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB)
+      set(HAVE_VIVANTE TRUE)
       set(HAVE_SDL_VIDEO TRUE)
 
       file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${VIVANTE_SOURCES})
       set(SDL_VIDEO_DRIVER_VIVANTE 1)
-      if(HAVE_VIDEO_VIVANTE_VDK)
+      if(HAVE_VIVANTE_VDK)
         set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
         list(APPEND EXTRA_LIBS VDK VIVANTE)
       else()
         set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
         list(APPEND EXTRA_LIBS EGL)
-      endif(HAVE_VIDEO_VIVANTE_VDK)
-    endif(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
-  endif(VIDEO_VIVANTE)
-endmacro(CheckVivante)
+      endif(HAVE_VIVANTE_VDK)
+    endif()
+  endif()
+endmacro()
 
 # Requires:
 # - nada
 macro(CheckGLX)
-  if(VIDEO_OPENGL)
+  if(SDL_OPENGL)
     check_c_source_compiles("
         #include <GL/glx.h>
-        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL_GLX)
-    if(HAVE_VIDEO_OPENGL_GLX)
+        int main(int argc, char** argv) {}" HAVE_OPENGL_GLX)
+    if(HAVE_OPENGL_GLX)
       set(SDL_VIDEO_OPENGL_GLX 1)
     endif()
   endif()
@@ -784,7 +785,7 @@ endmacro()
 # Requires:
 # - PkgCheckModules
 macro(CheckEGL)
-  if (VIDEO_OPENGL OR VIDEO_OPENGLES)
+  if (SDL_OPENGL OR SDL_OPENGLES)
     pkg_check_modules(EGL egl)
     string(REPLACE "-D_THREAD_SAFE;" "-D_THREAD_SAFE=1;" EGL_CFLAGS "${EGL_CFLAGS}")
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}")
@@ -794,8 +795,8 @@ macro(CheckEGL)
         #define EGL_NO_X11
         #include <EGL/egl.h>
         #include <EGL/eglext.h>
-        int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL)
-    if(HAVE_VIDEO_OPENGL_EGL)
+        int main (int argc, char** argv) {}" HAVE_OPENGL_EGL)
+    if(HAVE_OPENGL_EGL)
       set(SDL_VIDEO_OPENGL_EGL 1)
     endif()
   endif()
@@ -804,12 +805,12 @@ endmacro()
 # Requires:
 # - nada
 macro(CheckOpenGL)
-  if(VIDEO_OPENGL)
+  if(SDL_OPENGL)
     check_c_source_compiles("
         #include <GL/gl.h>
         #include <GL/glext.h>
-        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL)
-    if(HAVE_VIDEO_OPENGL)
+        int main(int argc, char** argv) {}" HAVE_OPENGL)
+    if(HAVE_OPENGL)
       set(SDL_VIDEO_OPENGL 1)
       set(SDL_VIDEO_RENDER_OGL 1)
     endif()
@@ -819,22 +820,22 @@ endmacro()
 # Requires:
 # - nada
 macro(CheckOpenGLES)
-  if(VIDEO_OPENGLES)
+  if(SDL_OPENGLES)
     check_c_source_compiles("
         #include <GLES/gl.h>
         #include <GLES/glext.h>
-        int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1)
-    if(HAVE_VIDEO_OPENGLES_V1)
-        set(HAVE_VIDEO_OPENGLES TRUE)
+        int main (int argc, char** argv) {}" HAVE_OPENGLES_V1)
+    if(HAVE_OPENGLES_V1)
+        set(HAVE_OPENGLES TRUE)
         set(SDL_VIDEO_OPENGL_ES 1)
         set(SDL_VIDEO_RENDER_OGL_ES 1)
     endif()
     check_c_source_compiles("
         #include <GLES2/gl2.h>
         #include <GLES2/gl2ext.h>
-        int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2)
-    if(HAVE_VIDEO_OPENGLES_V2)
-        set(HAVE_VIDEO_OPENGLES TRUE)
+        int main (int argc, char** argv) {}" HAVE_OPENGLES_V2)
+    if(HAVE_OPENGLES_V2)
+        set(HAVE_OPENGLES TRUE)
         set(SDL_VIDEO_OPENGL_ES2 1)
         set(SDL_VIDEO_RENDER_OGL_ES2 1)
     endif()
@@ -849,7 +850,7 @@ endmacro()
 # PTHREAD_CFLAGS
 # PTHREAD_LIBS
 macro(CheckPTHREAD)
-  if(PTHREADS)
+  if(SDL_PTHREADS)
     if(ANDROID)
       # the android libc provides built-in support for pthreads, so no
       # additional linking or compile flags are necessary
@@ -937,7 +938,7 @@ macro(CheckPTHREAD)
         endif()
       endif()
 
-      if(PTHREADS_SEM)
+      if(SDL_PTHREADS_SEM)
         check_c_source_compiles("#include <pthread.h>
                                  #include <semaphore.h>
                                  int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM)
@@ -1122,7 +1123,7 @@ endmacro()
 
 # Check for HIDAPI joystick drivers. This is currently a Unix thing, not Windows or macOS!
 macro(CheckHIDAPI)
-  if(HIDAPI)
+  if(SDL_HIDAPI)
     if(HIDAPI_SKIP_LIBUSB)
       set(HAVE_HIDAPI TRUE)
     else()
@@ -1161,7 +1162,7 @@ endmacro()
 # Requires:
 # - n/a
 macro(CheckRPI)
-  if(VIDEO_RPI)
+  if(SDL_RPI)
     pkg_check_modules(VIDEO_RPI bcm_host brcmegl)
     if (NOT VIDEO_RPI_FOUND)
       set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
@@ -1177,11 +1178,11 @@ macro(CheckRPI)
     set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}")
     check_c_source_compiles("
         #include <bcm_host.h>
-        int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
+        int main(int argc, char **argv) {}" HAVE_RPI)
     set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
     set(CMAKE_REQUIRED_LIBRARIES)
 
-    if(SDL_VIDEO AND HAVE_VIDEO_RPI)
+    if(SDL_VIDEO AND HAVE_RPI)
       set(HAVE_SDL_VIDEO TRUE)
       set(SDL_VIDEO_DRIVER_RPI 1)
       file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
@@ -1189,27 +1190,27 @@ macro(CheckRPI)
       list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES})
       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
       list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS})
-    endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
-  endif(VIDEO_RPI)
-endmacro(CheckRPI)
+    endif()
+  endif()
+endmacro()
 
 # Requires:
 # - EGL
 # - PkgCheckModules
 # Optional:
-# - KMSDRM_SHARED opt
+# - SDL_KMSDRM_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckKMSDRM)
-  if(VIDEO_KMSDRM)
+  if(SDL_KMSDRM)
     pkg_check_modules(KMSDRM libdrm gbm egl)
-    if(KMSDRM_FOUND AND HAVE_VIDEO_OPENGL_EGL)
+    if(KMSDRM_FOUND AND HAVE_OPENGL_EGL)
       link_directories(
         ${KMSDRM_LIBRARY_DIRS}
       )
       include_directories(
         ${KMSDRM_INCLUDE_DIRS}
       )
-      set(HAVE_VIDEO_KMSDRM TRUE)
+      set(HAVE_KMSDRM TRUE)
       set(HAVE_SDL_VIDEO TRUE)
 
       file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c)
@@ -1219,10 +1220,10 @@ macro(CheckKMSDRM)
 
       set(SDL_VIDEO_DRIVER_KMSDRM 1)
 
-      if(KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
+      if(SDL_KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
       endif()
-      if(KMSDRM_SHARED AND HAVE_SDL_LOADSO)
+      if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO)
         FindLibraryAndSONAME(drm)
         FindLibraryAndSONAME(gbm)
         set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")