SDL: gles2: only build tests when building SDL3 or when the headers are available

From 7f888f98f7d13bf350d5e9773e2d9e3a1caa84a3 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 23 Mar 2024 02:56:41 +0100
Subject: [PATCH] gles2: only build tests when building SDL3 or when the
 headers are available

---
 test/CMakeLists.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 338b29b7a5615..fea1130eb2430 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -363,8 +363,11 @@ add_sdl_test_executable(testgles SOURCES testgles.c)
 if(ANDROID)
     target_link_libraries(testgles PRIVATE GLESv1_CM)
 endif()
-add_sdl_test_executable(testgles2 SOURCES testgles2.c)
-add_sdl_test_executable(testgles2_sdf NEEDS_RESOURCES TESTUTILS SOURCES testgles2_sdf.c)
+check_include_file("GLES2/gl2platform.h" HAVE_GLES2_GL2PLATFORM_H)
+if(HAVE_GLES2_GL2PLATFORM_H OR (TARGET SDL3-static OR SDL3-shared))
+    add_sdl_test_executable(testgles2 SOURCES testgles2.c)
+    add_sdl_test_executable(testgles2_sdf NEEDS_RESOURCES TESTUTILS SOURCES testgles2_sdf.c)
+endif()
 add_sdl_test_executable(testhaptic SOURCES testhaptic.c)
 add_sdl_test_executable(testhotplug SOURCES testhotplug.c)
 add_sdl_test_executable(testpen SOURCES testpen.c)