SDL: cmake: Remove the hard dependency on the EGL package from Wayland

From 3da8c67d8d045c139d8fb77dd11934b606ceacdd Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Fri, 23 Oct 2026 14:52:04 -0400
Subject: [PATCH] cmake: Remove the hard dependency on the EGL package from
 Wayland

Wayland has no need for EGL when building SDL without any type of OpenGL support. Only consider it to be a requirement when OpenGL and/or OpenGL ES support is enabled.

This is not to be confused with the wayland-egl package, which is a helper library that is part of libwayland, and, despite the name, doesn't have a dependency on the actual EGL library either.
---
 cmake/sdlchecks.cmake | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index d585b0b998e7b..fc940c79f9381 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -641,14 +641,13 @@ macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
 endmacro()
 
 # Requires:
-# - EGL
 # - PkgCheckModules
 # Optional:
 # - SDL_WAYLAND_SHARED opt
 # - HAVE_SDL_LOADSO opt
 macro(CheckWayland)
   if(SDL_WAYLAND)
-    set(WAYLAND_PKG_CONFIG_SPEC "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
+    set(WAYLAND_PKG_CONFIG_SPEC "wayland-client>=1.18" wayland-egl wayland-cursor "xkbcommon>=0.5.0")
     if(PKG_CONFIG_FOUND)
       pkg_check_modules(PC_WAYLAND IMPORTED_TARGET ${WAYLAND_PKG_CONFIG_SPEC})
     else()
@@ -679,6 +678,12 @@ macro(CheckWayland)
       endif()
     endif()
 
+    # OpenGL presentation on Wayland requires EGL.
+    if ((HAVE_OPENGL OR HAVE_OPENGLES) AND NOT HAVE_OPENGL_EGL)
+      message(STATUS "EGL not found and is required for OpenGL presentation on Wayland; disabling")
+      set(WAYLAND_FOUND FALSE)
+    endif()
+
     if(WAYLAND_FOUND)
       set(HAVE_WAYLAND TRUE)
       set(HAVE_SDL_VIDEO TRUE)