FindOpenGL: unset OPENGL_USE_<C> variables on exit

If the OpenGL find module is called twice in a project, first with a
component <C> then the second time without, the second call will use the
value of the OPENGL_USE_<C> 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
This commit is contained in:
Chris Mayo committed 2026-11-04 19:28:56 +00:00
1 parent ba258369af
commit 8f97771b1c
1 file changed
+5
+5
View File
@@ -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()