From 8953e77ec26b90da0e79e3cf3ecb727034768d58 Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Tue, 22 Jun 2021 13:34:01 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 15 ++++++++++++++- src/declarativeimports/core/CMakeLists.txt | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5b977ab8..d7f8164cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() ######################################################################### diff --git a/src/declarativeimports/core/CMakeLists.txt b/src/declarativeimports/core/CMakeLists.txt index 816f8fda7..df0023921 100644 --- a/src/declarativeimports/core/CMakeLists.txt +++ b/src/declarativeimports/core/CMakeLists.txt @@ -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")