SDL: Merge commit '34de3b57a101f8d885041add5e21311a153bb1bf' into main

From 34de3b57a101f8d885041add5e21311a153bb1bf Mon Sep 17 00:00:00 2001
From: Cacodemon345 <[EMAIL REDACTED]>
Date: Thu, 11 Mar 2021 15:10:29 +0600
Subject: [PATCH] Fix CMake script on FreeBSD

---
 cmake/sdlchecks.cmake | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index fc1eb701b..0e28df618 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -795,11 +795,18 @@ macro(CheckOpenGLX11)
   endif()
 endmacro()
 
+# Requires:
+# - PkgCheckModules
+macro(CheckEGL)
+  pkg_check_modules(EGL egl)
+  string(REPLACE "-D_THREAD_SAFE;" "-D_THREAD_SAFE=1;" EGL_CFLAGS ${EGL_CFLAGS})
+endmacro()
+
 # Requires:
 # - PkgCheckModules
 macro(CheckEGLKMSDRM)
   if (HAVE_VIDEO_OPENGLES OR HAVE_VIDEO_OPENGL)
-    pkg_check_modules(EGL egl)
+    CheckEGL()
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}")
     check_c_source_compiles("
 	#define EGL_API_FB
@@ -817,7 +824,7 @@ endmacro()
 # Requires:
 # - PkgCheckModules
 macro(CheckOpenGLESX11)
-  pkg_check_modules(EGL egl)
+  CheckEGL()
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}")
   if(VIDEO_OPENGLES)
     check_c_source_compiles("