From a52d0db5328d89ba27be786b4fc81063f203db46 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 4 Mar 2021 18:28:10 +0300
Subject: [PATCH] test/CMakeLists.txt: add OpenGL module checks and adjust
dependencies.
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
---
test/CMakeLists.txt | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 322154c47..970578505 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -13,6 +13,12 @@ if(WINDOWS)
add_definitions(-Dmain=SDL_main)
endif()
+find_package(OpenGL)
+
+if (OPENGL_FOUND)
+add_definitions(-DHAVE_OPENGL)
+endif()
+
add_executable(checkkeys checkkeys.c)
add_executable(loopwave loopwave.c)
add_executable(loopwavequeue loopwavequeue.c)
@@ -88,6 +94,13 @@ add_executable(controllermap controllermap.c)
add_executable(testvulkan testvulkan.c)
add_executable(testoffscreen testoffscreen.c)
+if(OPENGL_FOUND)
+add_dependencies(testshader OpenGL::GL)
+add_dependencies(testgl2 OpenGL::GL)
+target_link_libraries(testshader OpenGL::GL)
+target_link_libraries(testgl2 OpenGL::GL)
+endif()
+
# HACK: Dummy target to cause the resource files to be copied to the build directory.
# Need to make it an executable so we can use the TARGET_FILE_DIR generator expression.
# This is needed so they get copied to the correct Debug/Release subdirectory in Xcode.