Add compatibility code when GLVND is not available

CMake's FindOpenGL internally handles EGL only correctly when GLVND is
available. This might not the case on embedded systems and actually it
is not necessary when EGL::EGL is found.

BUG: 438444
This commit is contained in:
Andreas Cord-Landwehr 2021-06-22 13:34:01 +02:00
parent 784f530af5
commit 8953e77ec2
2 changed files with 17 additions and 2 deletions

View File

@ -104,6 +104,12 @@ set_package_properties(OpenGL PROPERTIES DESCRIPTION "The OpenGL libraries"
TYPE OPTIONAL
)
find_package(EGL)
set_package_properties(EGL PROPERTIES
PURPOSE "Fallback when OpenGL not available because of missing GLVND"
TYPE OPTIONAL
)
add_feature_info(GLX ${OpenGL_GLX_FOUND} "OpenGL GLX libraries.")
if(OpenGL_GLX_FOUND AND X11_FOUND AND (Qt5Gui_OPENGL_IMPLEMENTATION STREQUAL "GL"))
set(HAVE_GLX 1)
@ -114,7 +120,14 @@ endif()
add_feature_info(EGL ${OpenGL_EGL_FOUND}
"A platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES and OpenVG.")
# OpenGL_EGL_FOUND is defined by FindOpenGL
set(HAVE_EGL ${OpenGL_EGL_FOUND})
if(TARGET OpenGL::EGL)
set(HAVE_EGL ${OpenGL_EGL_FOUND})
set(EGL_TARGET OpenGL::EGL)
elseif(${EGL_FOUND})
set(HAVE_EGL ${EGL_FOUND})
set(EGL_TARGET EGL::EGL)
message(STATUS "Switch to EGL compatibility target EGL::EGL because OpenGL::EGL is not available")
endif()
#########################################################################

View File

@ -58,7 +58,9 @@ if(HAVE_X11)
endif()
if(HAVE_EGL)
target_link_libraries(corebindingsplugin OpenGL::EGL)
target_link_libraries(corebindingsplugin ${EGL_TARGET})
else()
endif()
if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GLESv2")