Adding GLES Support to FindOpenGL

Hi there, please bear with me as this is my first post.

I would like to discuss this particular comment in the FindOpenGL.cmake file

For EGL targets the client must rely on GLVND support on the user’s system. Linking should use the OpenGL::OpenGL OpenGL::EGL targets. Using GLES* libraries is theoretically possible in place of OpenGL::OpenGL, but this module does not currently support that; contributions welcome.

In particular

Using GLES* libraries is theoretically possible in place of OpenGL::OpenGL, but this
module does not currently support that; contributions welcome.

I want to help make this contribution, but I want to make sure I’m not missing anything. I have an environment which seems to exercise this missing feature: a Yocto-based embedded Linux which uses GLES. I added a quick hack which makes the FindOpenGL module look for libEGLv2.so instead of libOpenGL.so, and it seems to work. So I thought the fix would just be something like

if (NOT OPENGL_opengl_LIBRARY)
    # look again for EGLv1/v2

This seems too easy to be true, so I’m sure I’m missing something. Could someone more knowledgeable in this area let me know if this is a viable fix?

Thanks a lot.

Cc: @chuckatkins @ben.boeckel

For reference, that comment was left behind by CMake MR 782. Since then there have been at least two attempts at adding GLES support that were never finished: