Skip to content

Commit

Permalink
cmake: test for EGL and GLES on Windows, avoid EGL test on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Oct 17, 2024
1 parent dd95533 commit 400b0ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2026,10 +2026,8 @@ elseif(WINDOWS)
endif()

if(SDL_OPENGLES)
set(SDL_VIDEO_OPENGL_EGL 1)
set(SDL_VIDEO_OPENGL_ES2 1)
set(SDL_VIDEO_RENDER_OGL_ES2 1)
set(HAVE_OPENGLES TRUE)
CheckEGL()
CheckOpenGLES()
endif()

if(SDL_VULKAN)
Expand Down
2 changes: 2 additions & 0 deletions cmake/PreseedMSVCCache.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
if(MSVC)
function(SDL_Preseed_CMakeCache)
set(HAVE_OPENGLES_V1 "" CACHE INTERNAL "Test HAVE_OPENGLES_V1")
set(HAVE_OPENGLES_V2 "1" CACHE INTERNAL "Test HAVE_OPENGLES_V2")
set(COMPILER_SUPPORTS_W3 "1" CACHE INTERNAL "Test /W3")
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS")
set(HAVE_ALLOCA_H "" CACHE INTERNAL "Have include alloca.h")
Expand Down
32 changes: 18 additions & 14 deletions cmake/sdlchecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -679,21 +679,25 @@ endmacro()
# - PkgCheckModules
macro(CheckEGL)
if(SDL_OPENGL OR SDL_OPENGLES)
cmake_push_check_state()
find_package(OpenGL MODULE)
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENGL_EGL_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES "${SDL3_SOURCE_DIR}/src/video/khronos")
check_c_source_compiles("
#define EGL_API_FB
#define MESA_EGL_NO_X11_HEADERS
#define EGL_NO_X11
#include <EGL/egl.h>
#include <EGL/eglext.h>
int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL)
cmake_pop_check_state()
if(HAVE_OPENGL_EGL)
if(NOT MSVC)
cmake_push_check_state()
find_package(OpenGL MODULE)
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENGL_EGL_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES "${SDL3_SOURCE_DIR}/src/video/khronos")
check_c_source_compiles("
#define EGL_API_FB
#define MESA_EGL_NO_X11_HEADERS
#define EGL_NO_X11
#include <EGL/egl.h>
#include <EGL/eglext.h>
int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL)
cmake_pop_check_state()
endif()
if(MSVC OR HAVE_OPENGL_EGL)
set(SDL_VIDEO_OPENGL_EGL 1)
sdl_link_dependency(egl INCLUDES ${OPENGL_EGL_INCLUDE_DIRS})
if(NOT MSVC)
sdl_link_dependency(egl INCLUDES ${OPENGL_EGL_INCLUDE_DIRS})
endif()
endif()
endif()
endmacro()
Expand Down

0 comments on commit 400b0ee

Please sign in to comment.