cmake/EGL build broken in upstream

Hello!

I’ve tried to build SDL from the hg repo and got this problem:

[ 0%] Building C object CMakeFiles/SDL2.dir/src/video/x11/SDL_x11window.c.o
/home/kerim/projects/SDL/src/video/x11/SDL_x11window.c: In function
?X11_CreateWindow?:
/home/kerim/projects/SDL/src/video/x11/SDL_x11window.c:553:19: error:
?SDL_VideoDevice? has no member named ?egl_data?

Apparently, cmake configuration doesn’t define
SDL_VIDEO_OPENGL_EGL anywhere.
Patch below is how I managed to fix it locally, hope it might be helpful.

Released SDL-2.0.0 builds fine from source -
http://www.libsdl.org/release/SDL2-2.0.0.tar.gz.

Thanks for a great library!

Kerim

diff -r 013483acb374 -r e16c832f0deb cmake/sdlchecks.cmake
— a/cmake/sdlchecks.cmake Tue Aug 20 23:20:32 2013 -0400
+++ b/cmake/sdlchecks.cmake Thu Aug 22 14:45:47 2013 +0400
@@ -565,6 +565,7 @@
#include <EGL/egl.h>
int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES)
if(HAVE_VIDEO_OPENGLES)

  •  set(SDL_VIDEO_OPENGL_EGL 1)
     check_c_source_compiles("
         #include <GLES/gl.h>
         #include <GLES/glext.h>
    

diff -r 013483acb374 -r e16c832f0deb include/SDL_config.h.cmake
— a/include/SDL_config.h.cmake Tue Aug 20 23:20:32 2013 -0400
+++ b/include/SDL_config.h.cmake Thu Aug 22 14:45:47 2013 +0400
@@ -287,6 +287,7 @@

/* Enable OpenGL support */
#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@
+#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@
#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@
#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@
#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@

2013/8/22 Kerim Borchaev <kerim.borchaev at gmail.com>

Hello!

I’ve tried to build SDL from the hg repo and got this problem:

[ 0%] Building C object
CMakeFiles/SDL2.dir/src/video/x11/SDL_x11window.c.o
/home/kerim/projects/SDL/src/video/x11/SDL_x11window.c: In function
?X11_CreateWindow?:
/home/kerim/projects/SDL/src/video/x11/SDL_x11window.c:553:19: error:
?SDL_VideoDevice? has no member named ?egl_data?

Apparently, cmake configuration doesn’t define
SDL_VIDEO_OPENGL_EGL anywhere.
Patch below is how I managed to fix it locally, hope it might be helpful.

Released SDL-2.0.0 builds fine from source -
http://www.libsdl.org/release/SDL2-2.0.0.tar.gz.

Thanks for a great library!

Kerim

diff -r 013483acb374 -r e16c832f0deb cmake/sdlchecks.cmake
— a/cmake/sdlchecks.cmake Tue Aug 20 23:20:32 2013 -0400
+++ b/cmake/sdlchecks.cmake Thu Aug 22 14:45:47 2013 +0400
@@ -565,6 +565,7 @@
#include <EGL/egl.h>
int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES)
if(HAVE_VIDEO_OPENGLES)

  •  set(SDL_VIDEO_OPENGL_EGL 1)
     check_c_source_compiles("
         #include <GLES/gl.h>
         #include <GLES/glext.h>
    

diff -r 013483acb374 -r e16c832f0deb include/SDL_config.h.cmake
— a/include/SDL_config.h.cmake Tue Aug 20 23:20:32 2013 -0400
+++ b/include/SDL_config.h.cmake Thu Aug 22 14:45:47 2013 +0400
@@ -287,6 +287,7 @@

/* Enable OpenGL support */
#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@
+#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@
#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@
#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@
#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@

Thanks for the patch. The proper fix though is to detect EGL/egl.h and if
true set(SDL_VIDEO_OPENGL_EGL 1), and independent of that, detect OpenGL ES
1/2. The reason behind this is that you can have OpenGL ES support without
EGL (and in theory, EGL without ES)–
Gabriel.