SDL: cmake: testnative can also be built on non-Linux

From b8b852a55bf8eeed5498d732e457a59c105dcf3e Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 27 Mar 2023 14:11:23 +0200
Subject: [PATCH] cmake: testnative can also be built on non-Linux

---
 test/CMakeLists.txt |  4 ++--
 test/testevdev.c    | 11 ++++++++++-
 test/testnative.c   |  9 +++++----
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0fd0f0c45676..662a278ad132 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -162,7 +162,7 @@ add_sdl_test_executable(testdrawchessboard SOURCES testdrawchessboard.c)
 add_sdl_test_executable(testdropfile SOURCES testdropfile.c)
 add_sdl_test_executable(testerror NONINTERACTIVE SOURCES testerror.c)
 
-if(LINUX AND SDL3_TESTS_SUBPROJECT)
+if(SDL3_TESTS_SUBPROJECT)
     set(build_options_dependent_tests )
 
     add_sdl_test_executable(testevdev NONINTERACTIVE SOURCES testevdev.c)
@@ -185,7 +185,7 @@ if(LINUX AND SDL3_TESTS_SUBPROJECT)
         endif()
         list(APPEND build_options_dependent_tests testnative)
     elseif(WINDOWS)
-        add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS SOURCES testnative.ctestnativew32.c)
+        add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativew32.c)
         list(APPEND build_options_dependent_tests testnative)
     elseif(HAVE_X11)
         add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativex11.c)
diff --git a/test/testevdev.c b/test/testevdev.c
index 2da38af8dc5b..4fae3295c649 100644
--- a/test/testevdev.c
+++ b/test/testevdev.c
@@ -11,9 +11,18 @@
   freely.
 */
 
-#include "../src/SDL_internal.h"
+#include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include <SDL3/SDL_test.h>
 
+/* Hack to avoid dynapi renaming */
+#include "../src/dynapi/SDL_dynapi.h"
+#ifdef SDL_DYNAMIC_API
+#undef SDL_DYNAMIC_API
+#endif
+
+#include "../src/SDL_internal.h"
+
 #include <stdio.h>
 #include <string.h>
 
diff --git a/test/testnative.c b/test/testnative.c
index a21598a5d036..a58ce3ad50a3 100644
--- a/test/testnative.c
+++ b/test/testnative.c
@@ -11,14 +11,15 @@
 */
 /* Simple program:  Create a native window and attach an SDL renderer */
 
-#include <stdlib.h> /* for srand() */
-#include <time.h>   /* for time() */
+#include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
 
 #include "testnative.h"
 #include "testutils.h"
 
-#include <SDL3/SDL_main.h>
-#include <SDL3/SDL_test.h>
+#include <stdlib.h> /* for srand() */
+#include <time.h>   /* for time() */
 
 #define WINDOW_W    640
 #define WINDOW_H    480