FindOpenGL: Add support for a separate GLU include directory
Add a OPENGL_GLU_INCLUDE_DIR cache variable for `GL/glu.h` and attach it as an include directory to the `OpenGL::GLU` target. Also add a `OPENGL_INCLUDE_DIRS` result variable to list all include directories. Account for the GLU header when deciding whether GLU is found. Fixes: #25627stage/master/nightly/2024/02/06^2
parent
2c3509136f
commit
aebebf72df
|
@ -0,0 +1,7 @@
|
|||
findopengl-glu-include-dir
|
||||
--------------------------
|
||||
|
||||
* The :module:`FindOpenGL` module learned to find a GLU include
|
||||
directory different than the GL include directory. A new
|
||||
``OPENGL_INCLUDE_DIRS`` result variable provides all include
|
||||
directories.
|
|
@ -92,12 +92,17 @@ This module sets the following variables:
|
|||
Defined if the system has GLES3.
|
||||
``OPENGL_INCLUDE_DIR``
|
||||
Path to the OpenGL include directory.
|
||||
The ``OPENGL_INCLUDE_DIRS`` variable is preferred.
|
||||
``OPENGL_EGL_INCLUDE_DIRS``
|
||||
Path to the EGL include directory.
|
||||
``OPENGL_LIBRARIES``
|
||||
Paths to the OpenGL library, windowing system libraries, and GLU libraries.
|
||||
On Linux, this assumes GLX and is never correct for EGL-based targets.
|
||||
Clients are encouraged to use the ``OpenGL::*`` import targets instead.
|
||||
``OPENGL_INCLUDE_DIRS``
|
||||
.. versionadded:: 3.29
|
||||
|
||||
Paths to the OpenGL include directories.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
Variables for GLVND-specific libraries ``OpenGL``, ``EGL`` and ``GLX``.
|
||||
|
@ -127,6 +132,11 @@ The following cache variables may also be set:
|
|||
|
||||
Path to the OpenGL GLES3 library.
|
||||
|
||||
``OPENGL_GLU_INCLUDE_DIR``
|
||||
.. versionadded:: 3.29
|
||||
|
||||
Path to the OpenGL GLU include directory.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
Variables for GLVND-specific libraries ``OpenGL``, ``EGL`` and ``GLX``.
|
||||
|
||||
|
@ -230,10 +240,13 @@ elseif (APPLE)
|
|||
"OpenGL GLU library")
|
||||
find_path(OPENGL_INCLUDE_DIR NAMES OpenGL/gl.h GL/gl.h DOC
|
||||
"Include for OpenGL")
|
||||
find_path(OPENGL_GLU_INCLUDE_DIR NAMES OpenGL/glu.h GL/glu.h DOC
|
||||
"Include for the OpenGL GLU library")
|
||||
list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
|
||||
|
||||
list(APPEND _OpenGL_CACHE_VARS
|
||||
OPENGL_INCLUDE_DIR
|
||||
OPENGL_GLU_INCLUDE_DIR
|
||||
OPENGL_gl_LIBRARY
|
||||
OPENGL_glu_LIBRARY
|
||||
)
|
||||
|
@ -289,6 +302,8 @@ else()
|
|||
/opt/graphics/OpenGL/include
|
||||
)
|
||||
|
||||
find_path(OPENGL_GLU_INCLUDE_DIR GL/glu.h ${_OPENGL_INCLUDE_PATH})
|
||||
|
||||
list(APPEND _OpenGL_CACHE_VARS
|
||||
OPENGL_INCLUDE_DIR
|
||||
OPENGL_GLX_INCLUDE_DIR
|
||||
|
@ -296,6 +311,7 @@ else()
|
|||
OPENGL_GLES2_INCLUDE_DIR
|
||||
OPENGL_GLES3_INCLUDE_DIR
|
||||
OPENGL_xmesa_INCLUDE_DIR
|
||||
OPENGL_GLU_INCLUDE_DIR
|
||||
)
|
||||
|
||||
# Search for the GLVND libraries. We do this regardless of COMPONENTS; we'll
|
||||
|
@ -509,7 +525,7 @@ else()
|
|||
set( OPENGL_XMESA_FOUND "NO" )
|
||||
endif()
|
||||
|
||||
if(OPENGL_glu_LIBRARY)
|
||||
if(OPENGL_glu_LIBRARY AND (WIN32 OR OPENGL_GLU_INCLUDE_DIR))
|
||||
set( OPENGL_GLU_FOUND "YES" )
|
||||
else()
|
||||
set( OPENGL_GLU_FOUND "NO" )
|
||||
|
@ -567,6 +583,8 @@ unset(_OpenGL_REQUIRED_VARS)
|
|||
|
||||
# OpenGL:: targets
|
||||
if(OPENGL_FOUND)
|
||||
set(OPENGL_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
|
||||
|
||||
# ::OpenGL is a GLVND library, and thus Linux-only: we don't bother checking
|
||||
# for a framework version of this library.
|
||||
if(OPENGL_opengl_LIBRARY AND NOT TARGET OpenGL::OpenGL)
|
||||
|
@ -600,6 +618,7 @@ if(OPENGL_FOUND)
|
|||
OpenGL::OpenGL)
|
||||
set_target_properties(OpenGL::GLX PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${OPENGL_GLX_INCLUDE_DIR}")
|
||||
list(APPEND OPENGL_INCLUDE_DIRS ${OPENGL_GLX_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# ::GLES2 is a GLVND library, and thus Linux-only: we don't bother checking
|
||||
|
@ -629,6 +648,7 @@ if(OPENGL_FOUND)
|
|||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${OPENGL_GLES2_INCLUDE_DIR}"
|
||||
)
|
||||
list(APPEND OPENGL_INCLUDE_DIRS ${OPENGL_GLES2_INCLUDE_DIR})
|
||||
|
||||
if (OPENGL_USE_GLES2)
|
||||
set(_OpenGL_EGL_IMPL OpenGL::GLES2)
|
||||
|
@ -662,6 +682,7 @@ if(OPENGL_FOUND)
|
|||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${OPENGL_GLES3_INCLUDE_DIR}"
|
||||
)
|
||||
list(APPEND OPENGL_INCLUDE_DIRS ${OPENGL_GLES3_INCLUDE_DIR})
|
||||
|
||||
if (OPENGL_USE_GLES3)
|
||||
set(_OpenGL_EGL_IMPL OpenGL::GLES3)
|
||||
|
@ -713,6 +734,7 @@ if(OPENGL_FOUND)
|
|||
# Note that EGL's include directory is different from OpenGL/GLX's!
|
||||
set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${OPENGL_EGL_INCLUDE_DIR}")
|
||||
list(APPEND OPENGL_INCLUDE_DIRS ${OPENGL_EGL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU)
|
||||
|
@ -727,6 +749,10 @@ if(OPENGL_FOUND)
|
|||
endif()
|
||||
set_target_properties(OpenGL::GLU PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES OpenGL::GL)
|
||||
# Note that GLU's include directory may be different from OpenGL's!
|
||||
set_target_properties(OpenGL::GLU PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${OPENGL_GLU_INCLUDE_DIR}")
|
||||
list(APPEND OPENGL_INCLUDE_DIRS ${OPENGL_GLU_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# OPENGL_LIBRARIES mirrors OpenGL::GL's logic ...
|
||||
|
@ -743,6 +769,8 @@ if(OPENGL_FOUND)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES OPENGL_INCLUDE_DIRS)
|
||||
|
||||
# This deprecated setting is for backward compatibility with CMake1.4
|
||||
set(OPENGL_LIBRARY ${OPENGL_LIBRARIES})
|
||||
# This deprecated setting is for backward compatibility with CMake1.4
|
||||
|
|
|
@ -2,6 +2,7 @@ set(CYGWIN 0)
|
|||
set(WIN32 0)
|
||||
set(APPLE 0)
|
||||
set(OPENGL_INCLUDE_DIR GL/include)
|
||||
set(OPENGL_GLU_INCLUDE_DIR GLU/include)
|
||||
set(OPENGL_GLX_INCLUDE_DIR GLX/include)
|
||||
set(OPENGL_gl_LIBRARY GL)
|
||||
set(OPENGL_opengl_LIBRARY OpenGL)
|
||||
|
|
Loading…
Reference in New Issue