From 8f97771b1c30c4f2f7f4f787a12d32b5343264c8 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Wed, 4 Nov 2026 19:28:56 +0000 Subject: [PATCH] FindOpenGL: unset OPENGL_USE_ variables on exit If the OpenGL find module is called twice in a project, first with a component then the second time without, the second call will use the value of the OPENGL_USE_ variable from the first call. This has been seen to cause incorrect results in a project using Qt where the first call is part of the project's own logic and the second call happens within a call to Qt 6.12.0's Qt6 find module. Fixes: #28246 --- Modules/FindOpenGL.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 101dbad77e..ba74ecff77 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -901,3 +901,8 @@ set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) mark_as_advanced(${_OpenGL_CACHE_VARS}) unset(_OpenGL_CACHE_VARS) + +foreach(component ${OpenGL_FIND_COMPONENTS}) + string(TOUPPER ${component} _COMPONENT) + unset(OPENGL_USE_${_COMPONENT}) +endforeach()