1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 # file Copyright.txt or https://cmake.org/licensing for details. 4 # See https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2445 10 # FindModule for OpenGL and GLU. 15 # This module respects several optional COMPONENTS: ``EGL``, ``GLX``, 16 # ``OpenGL``, ``GLES2``, and ``GLES3``. There are corresponding import targets 17 # for each of these flags. 22 # This module defines the :prop_tgt:`IMPORTED` targets: 25 # Defined to the platform-specific OpenGL libraries if the system has OpenGL. 27 # Defined to libOpenGL if the system is GLVND-based. 29 # Defined if the system has GLU. 31 # Defined if the system has GLX. 33 # Defined if the system has EGL. 35 # Defined if the system has GLES2. 37 # Defined if the system has GLES3. 42 # This module sets the following variables: 45 # True, if the system has OpenGL and all components are found. 46 # ``OPENGL_XMESA_FOUND`` 47 # True, if the system has XMESA. 48 # ``OPENGL_GLU_FOUND`` 49 # True, if the system has GLU. 50 # ``OpenGL_OpenGL_FOUND`` 51 # True, if the system has an OpenGL library. 52 # ``OpenGL_GLX_FOUND`` 53 # True, if the system has GLX. 54 # ``OpenGL_EGL_FOUND`` 55 # True, if the system has EGL. 56 # ``OpenGL_GLES2_FOUND`` 57 # True, if the system has GLES2. 58 # ``OpenGL_GLES3_FOUND`` 59 # True, if the system has GLES3. 60 # ``OPENGL_INCLUDE_DIR`` 61 # Path to the OpenGL include directory. 62 # ``OPENGL_EGL_INCLUDE_DIRS`` 63 # Path to the EGL include directory. 64 # ``OPENGL_LIBRARIES`` 65 # Paths to the OpenGL library, windowing system libraries, and GLU libraries. 66 # On Linux, this assumes GLX and is never correct for EGL-based targets. 67 # Clients are encouraged to use the ``OpenGL::*`` import targets instead. 72 # The following cache variables may also be set: 74 # ``OPENGL_egl_LIBRARY`` 75 # Path to the EGL library. 76 # ``OPENGL_glu_LIBRARY`` 77 # Path to the GLU library. 78 # ``OPENGL_glx_LIBRARY`` 79 # Path to the GLVND 'GLX' library. 80 # ``OPENGL_opengl_LIBRARY`` 81 # Path to the GLVND 'OpenGL' library 82 # ``OPENGL_gl_LIBRARY`` 83 # Path to the OpenGL library. New code should prefer the ``OpenGL::*`` import 89 # Some Linux systems utilize GLVND as a new ABI for OpenGL. GLVND separates 90 # context libraries from OpenGL itself; OpenGL lives in "libOpenGL", and 91 # contexts are defined in "libGLX" or "libEGL". GLVND is currently the only way 92 # to get OpenGL 3+ functionality via EGL in a manner portable across vendors. 93 # Projects may use GLVND explicitly with target ``OpenGL::OpenGL`` and either 94 # ``OpenGL::GLX`` or ``OpenGL::EGL``. 96 # Projects may use the ``OpenGL::GL`` target (or ``OPENGL_LIBRARIES`` variable) 97 # to use legacy GL interfaces. These will use the legacy GL library located 98 # by ``OPENGL_gl_LIBRARY``, if available. If ``OPENGL_gl_LIBRARY`` is empty or 99 # not found and GLVND is available, the ``OpenGL::GL`` target will use GLVND 100 # ``OpenGL::OpenGL`` and ``OpenGL::GLX`` (and the ``OPENGL_LIBRARIES`` 101 # variable will use the corresponding libraries). Thus, for non-EGL-based 102 # Linux targets, the ``OpenGL::GL`` target is most portable. 104 # A ``OpenGL_GL_PREFERENCE`` variable may be set to specify the preferred way 105 # to provide legacy GL interfaces in case multiple choices are available. 106 # The value may be one of: 109 # If the GLVND OpenGL and GLX libraries are available, prefer them. 110 # This forces ``OPENGL_gl_LIBRARY`` to be empty. 111 # This is the default if components were requested (since components 112 # correspond to GLVND libraries) or if policy :policy:`CMP0072` is 116 # Prefer to use the legacy libGL library, if available. 117 # This is the default if no components were requested and 118 # policy :policy:`CMP0072` is not set to ``NEW``. 120 # For EGL targets the client must rely on GLVND support on the user's system. 121 # Linking should use the ``OpenGL::OpenGL OpenGL::EGL`` targets. Using GLES* 122 # libraries is theoretically possible in place of ``OpenGL::OpenGL``. 124 # ``OPENGL_egl_LIBRARY`` and ``OPENGL_EGL_INCLUDE_DIRS`` are defined in the case of 125 # GLVND. For non-GLVND Linux and other systems these are left undefined. 130 # On OSX FindOpenGL defaults to using the framework version of OpenGL. People 131 # will have to change the cache values of OPENGL_glu_LIBRARY and 132 # OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX. 134 set(_OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
136 # Provide OPENGL_USE_<C> variables
for each component.
137 foreach(component ${OpenGL_FIND_COMPONENTS})
139 set(OPENGL_USE_${_COMPONENT} 1)
143 find_path(OPENGL_INCLUDE_DIR GL/gl.h )
144 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
146 find_library(OPENGL_gl_LIBRARY opengl32 )
147 find_library(OPENGL_glu_LIBRARY glu32 )
152 set (OPENGL_gl_LIBRARY import32 CACHE STRING "OpenGL library for win32")
153 set (OPENGL_glu_LIBRARY import32 CACHE STRING "GLU library for win32")
155 set (OPENGL_gl_LIBRARY opengl32 CACHE STRING "OpenGL library for win32")
156 set (OPENGL_glu_LIBRARY glu32 CACHE STRING "GLU library for win32")
160 # The OpenGL.framework provides both gl and glu 161 find_library(OPENGL_gl_LIBRARY OpenGL DOC
"OpenGL library for OS X")
162 find_library(OPENGL_glu_LIBRARY OpenGL DOC
163 "GLU library for OS X (usually same as OpenGL library)")
164 find_path(OPENGL_INCLUDE_DIR OpenGL/gl.h DOC
"Include for OpenGL on OS X")
165 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
168 if (CMAKE_SYSTEM_NAME MATCHES
"HP-UX")
169 # Handle HP-UX cases where we only want to find OpenGL in either hpux64 170 # or hpux32 depending on if we're doing a 64 bit build. 171 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
173 /opt/graphics/OpenGL/lib/hpux32/)
176 /opt/graphics/OpenGL/lib/hpux64/
177 /opt/graphics/OpenGL/lib/pa20_64)
179 elseif(CMAKE_SYSTEM_NAME STREQUAL Haiku)
181 /boot/develop/lib/x86)
182 set(_OPENGL_INCLUDE_PATH
183 /boot/develop/headers/os/opengl)
184 elseif (CMAKE_SYSTEM_NAME STREQUAL
"Linux")
185 # CMake doesn't support arbitrary globs in search paths. 186 file(GLOB _OPENGL_LIB_PATH
187 # The NVidia driver installation tool on Linux installs libraries to a
188 # `nvidia-<version>` subdirectory.
190 "/usr/lib32/nvidia-*")
193 # The first line below is to make sure that the proper headers 194 # are used on a Linux machine with the NVidia drivers installed. 195 # They replace Mesa with NVidia's own library but normally do not 196 # install headers and that causes the linking to 197 # fail since the compiler finds the Mesa headers but NVidia's library. 198 # Make sure the NVIDIA directory comes BEFORE the others. 199 # - Atanas Georgiev <atanas@cs.columbia.edu> 200 find_path(OPENGL_INCLUDE_DIR GL/gl.h
201 /usr/share/doc/NVIDIA_GLX-1.0/include
202 /usr/openwin/share/include
203 /opt/graphics/OpenGL/include
204 ${_OPENGL_INCLUDE_PATH}
206 find_path(OPENGL_GLX_INCLUDE_DIR GL/glx.h ${_OPENGL_INCLUDE_PATH})
207 find_path(OPENGL_EGL_INCLUDE_DIR EGL/egl.h ${_OPENGL_INCLUDE_PATH})
208 find_path(OPENGL_GLES2_INCLUDE_DIR GLES2/gl2.h ${_OPENGL_INCLUDE_PATH})
209 find_path(OPENGL_GLES3_INCLUDE_DIR GLES3/gl3.h ${_OPENGL_INCLUDE_PATH})
210 find_path(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h
211 /usr/share/doc/NVIDIA_GLX-1.0/include
212 /usr/openwin/share/include
213 /opt/graphics/OpenGL/include
216 # Search for the GLVND libraries. We do this regardless of COMPONENTS; we'll 217 # take into account the COMPONENTS logic later. 218 find_library(OPENGL_opengl_LIBRARY
220 PATHS ${_OPENGL_LIB_PATH}
223 find_library(OPENGL_glx_LIBRARY
225 PATHS ${_OPENGL_LIB_PATH}
228 find_library(OPENGL_egl_LIBRARY
230 PATHS ${_OPENGL_LIB_PATH}
233 find_library(OPENGL_gles2_LIBRARY
235 PATHS ${_OPENGL_LIB_PATH}
238 find_library(OPENGL_gles3_LIBRARY
240 GLESv2 # mesa provides only libGLESv2
241 PATHS ${_OPENGL_LIB_PATH}
244 find_library(OPENGL_glu_LIBRARY
246 PATHS ${OPENGL_gl_LIBRARY}
247 /opt/graphics/OpenGL/lib
252 set(_OpenGL_GL_POLICY_WARN 0)
253 if(NOT DEFINED OpenGL_GL_PREFERENCE)
254 set(OpenGL_GL_PREFERENCE
"")
256 if(NOT OpenGL_GL_PREFERENCE STREQUAL
"")
257 # A preference has been explicitly specified. 258 if(NOT OpenGL_GL_PREFERENCE MATCHES
"^(GLVND|LEGACY)$")
260 "OpenGL_GL_PREFERENCE value '${OpenGL_GL_PREFERENCE}' not recognized. " 261 "Allowed values are 'GLVND' and 'LEGACY'." 264 elseif(OpenGL_FIND_COMPONENTS)
265 # No preference was explicitly specified, but the caller did request 266 # at least one GLVND component. Prefer GLVND for legacy GL. 267 set(OpenGL_GL_PREFERENCE
"GLVND")
269 # No preference was explicitly specified and no GLVND components were 270 # requested. Use a policy to choose the default. 271 cmake_policy(GET CMP0072 _OpenGL_GL_POLICY)
272 if(
"x${_OpenGL_GL_POLICY}x" STREQUAL
"xNEWx")
273 set(OpenGL_GL_PREFERENCE
"GLVND")
275 set(OpenGL_GL_PREFERENCE
"LEGACY")
276 if(
"x${_OpenGL_GL_POLICY}x" STREQUAL
"xx")
277 set(_OpenGL_GL_POLICY_WARN 1)
280 unset(_OpenGL_GL_POLICY)
283 if("x${OpenGL_GL_PREFERENCE}x
" STREQUAL "xGLVNDx
" AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY) 284 # We can provide legacy GL using GLVND libraries. 285 # Do not use any legacy GL library. 286 set(OPENGL_gl_LIBRARY "") 288 # We cannot provide legacy GL using GLVND libraries. 289 # Search for the legacy GL library. 290 find_library(OPENGL_gl_LIBRARY 292 PATHS /opt/graphics/OpenGL/lib 299 if(_OpenGL_GL_POLICY_WARN AND OPENGL_gl_LIBRARY AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY) 300 message(AUTHOR_WARNING 301 "Policy CMP0072 is not
set: FindOpenGL prefers GLVND by
default when available.
" 302 "Run \
"cmake --help-policy CMP0072\" for policy details. " 303 "Use the cmake_policy command to set the policy and suppress this warning." 305 "FindOpenGL found both a legacy GL library:\n" 306 " OPENGL_gl_LIBRARY: ${OPENGL_gl_LIBRARY}\n" 307 "and GLVND libraries for OpenGL and GLX:\n" 308 " OPENGL_opengl_LIBRARY: ${OPENGL_opengl_LIBRARY}\n" 309 " OPENGL_glx_LIBRARY: ${OPENGL_glx_LIBRARY}\n" 310 "OpenGL_GL_PREFERENCE has not been set to \"GLVND\" or \"LEGACY\", so for " 311 "compatibility with CMake 3.10 and below the legacy GL library will be used." 314 unset(_OpenGL_GL_POLICY_WARN)
316 # FPHSA cannot handle "this OR that is required", so we conditionally set what 317 # it must look for. First clear any previous config we might have done: 318 set(_OpenGL_REQUIRED_VARS)
320 # now we append the libraries as appropriate. The complicated logic
321 # basically comes down to
"use libOpenGL when we can, and add in specific 322 # context mechanisms when requested, or we need them to preserve the previous 323 # default where glx is always available." 324 if((NOT OPENGL_USE_EGL AND
325 NOT OPENGL_opengl_LIBRARY AND
326 OPENGL_glx_LIBRARY AND
327 NOT OPENGL_gl_LIBRARY) OR
328 (NOT OPENGL_USE_EGL AND
329 NOT OPENGL_USE_GLES3 AND
330 NOT OPENGL_USE_GLES2 AND
331 NOT OPENGL_glx_LIBRARY AND
332 NOT OPENGL_gl_LIBRARY) OR
333 (NOT OPENGL_USE_EGL AND
334 OPENGL_opengl_LIBRARY AND
335 OPENGL_glx_LIBRARY) OR
336 (NOT OPENGL_USE_GLES3 AND
337 NOT OPENGL_USE_GLES2 AND
339 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_opengl_LIBRARY)
342 # GLVND GLX library. Preferred when available. 343 if((NOT OPENGL_USE_OPENGL AND
344 NOT OPENGL_USE_GLX AND
345 NOT OPENGL_USE_EGL AND
346 NOT OPENGL_USE_GLES3 AND
347 NOT OPENGL_USE_GLES2 AND
348 NOT OPENGL_glx_LIBRARY AND
349 NOT OPENGL_gl_LIBRARY) OR
351 NOT OPENGL_USE_EGL AND
352 NOT OPENGL_USE_GLES3 AND
353 NOT OPENGL_USE_GLES2 AND
354 NOT OPENGL_glx_LIBRARY AND
355 NOT OPENGL_gl_LIBRARY) OR
356 (NOT OPENGL_USE_EGL AND
357 NOT OPENGL_USE_GLES3 AND
358 NOT OPENGL_USE_GLES2 AND
359 OPENGL_opengl_LIBRARY AND
360 OPENGL_glx_LIBRARY) OR
361 (OPENGL_USE_GLX AND OPENGL_USE_EGL))
362 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_glx_LIBRARY)
367 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_egl_LIBRARY)
370 # GLVND GLES2 library. 371 if(OPENGL_USE_GLES2 AND NOT EMSCRIPTEN)
372 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_gles2_LIBRARY)
375 # GLVND GLES3 library. 376 if(OPENGL_USE_GLES3 AND NOT EMSCRIPTEN)
377 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_gles3_LIBRARY)
380 # Old-style "libGL" library: used as a fallback when GLVND isn't available. 381 if((NOT OPENGL_USE_EGL AND
382 NOT OPENGL_opengl_LIBRARY AND
383 OPENGL_glx_LIBRARY AND
384 OPENGL_gl_LIBRARY) OR
385 (NOT OPENGL_USE_EGL AND
386 NOT OPENGL_glx_LIBRARY AND
388 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
391 # We always need the 'gl.h' include dir. 392 list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
394 unset(_OPENGL_INCLUDE_PATH)
395 unset(_OPENGL_LIB_PATH)
397 find_library(OPENGL_glu_LIBRARY
399 PATHS ${OPENGL_gl_LIBRARY}
400 /opt/graphics/OpenGL/lib
406 if(OPENGL_xmesa_INCLUDE_DIR)
407 set( OPENGL_XMESA_FOUND "YES" )
409 set( OPENGL_XMESA_FOUND "NO" )
412 if(OPENGL_glu_LIBRARY)
413 set( OPENGL_GLU_FOUND "YES" )
415 set( OPENGL_GLU_FOUND "NO" )
418 # OpenGL_OpenGL_FOUND is a bit unique in that it is okay if /either/ libOpenGL 420 # Using libGL with libEGL is never okay, though; we handle that case later. 421 if(NOT OPENGL_opengl_LIBRARY AND NOT OPENGL_gl_LIBRARY)
422 set(OpenGL_OpenGL_FOUND FALSE)
424 set(OpenGL_OpenGL_FOUND TRUE)
427 if(OPENGL_glx_LIBRARY AND OPENGL_GLX_INCLUDE_DIR)
428 set(OpenGL_GLX_FOUND TRUE)
430 set(OpenGL_GLX_FOUND FALSE)
433 if(OPENGL_egl_LIBRARY AND OPENGL_EGL_INCLUDE_DIR)
434 set(OpenGL_EGL_FOUND TRUE)
436 set(OpenGL_EGL_FOUND FALSE)
439 if(OPENGL_gles2_LIBRARY AND OPENGL_GLES2_INCLUDE_DIR)
440 set(OpenGL_GLES2_FOUND TRUE)
442 set(OpenGL_GLES2_FOUND FALSE)
445 if(OPENGL_gles3_LIBRARY AND OPENGL_GLES3_INCLUDE_DIR OR EMSCRIPTEN)
446 set(OpenGL_GLES3_FOUND TRUE)
448 set(OpenGL_GLES3_FOUND FALSE)
451 # User-visible names should be plural. 452 if(OPENGL_EGL_INCLUDE_DIR)
453 set(OPENGL_EGL_INCLUDE_DIRS ${OPENGL_EGL_INCLUDE_DIR})
456 include(FindPackageHandleStandardArgs)
457 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS}
459 unset(_OpenGL_REQUIRED_VARS)
463 # ::OpenGL is a GLVND library, and thus Linux-only: we don't bother checking 464 # for a framework version of this library. 465 if(OPENGL_opengl_LIBRARY AND NOT TARGET OpenGL::OpenGL)
466 if(IS_ABSOLUTE
"${OPENGL_opengl_LIBRARY}")
467 add_library(OpenGL::OpenGL UNKNOWN IMPORTED)
468 set_target_properties(OpenGL::OpenGL PROPERTIES IMPORTED_LOCATION
469 "${OPENGL_opengl_LIBRARY}")
471 add_library(OpenGL::OpenGL INTERFACE IMPORTED)
472 set_target_properties(OpenGL::OpenGL PROPERTIES IMPORTED_LIBNAME
473 "${OPENGL_opengl_LIBRARY}")
475 set_target_properties(OpenGL::OpenGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
476 "${OPENGL_INCLUDE_DIR}
") 477 set(_OpenGL_EGL_IMPL OpenGL::OpenGL) 480 # ::GLX is a GLVND library, and thus Linux-only: we don't bother checking 481 # for a framework version of this library. 482 if(OpenGL_GLX_FOUND AND NOT TARGET OpenGL::GLX) 483 if(IS_ABSOLUTE "${OPENGL_glx_LIBRARY}
") 484 add_library(OpenGL::GLX UNKNOWN IMPORTED) 485 set_target_properties(OpenGL::GLX PROPERTIES IMPORTED_LOCATION 486 "${OPENGL_glx_LIBRARY}
") 488 add_library(OpenGL::GLX INTERFACE IMPORTED) 489 set_target_properties(OpenGL::GLX PROPERTIES IMPORTED_LIBNAME 490 "${OPENGL_glx_LIBRARY}
") 492 set_target_properties(OpenGL::GLX PROPERTIES INTERFACE_LINK_LIBRARIES 494 set_target_properties(OpenGL::GLX PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 495 "${OPENGL_GLX_INCLUDE_DIR}
") 498 # ::GLES2 is a GLVND library, and thus Linux-only: we don't bother checking 499 # for a framework version of this library. 500 if(OpenGL_GLES2_FOUND AND NOT TARGET OpenGL::GLES2) 501 set(_opengl_gles_cxx_flags) 503 # Configure compile options 505 # For GLES2 we do not make any decision for which WebGL version should 506 # be used (1 or 2). For old version of EMSCRIPTEN < 1.39.5 the user will 507 # have to register its own "-s USE_WEBGL1=1 or -s USE_WEBGL2=1
" 508 list(APPEND _opengl_gles_cxx_flags 509 "SHELL:-s FULL_ES2=1
" 511 if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "1.39.5
") 512 list(APPEND _opengl_gles_cxx_flags 513 "SHELL:-s MIN_WEBGL_VERSION=1
" 514 "SHELL:-s MAX_WEBGL_VERSION=2
" 520 if(NOT OPENGL_gles2_LIBRARY) 521 add_library(OpenGL::GLES2 INTERFACE IMPORTED) 523 if(IS_ABSOLUTE "${OPENGL_gles2_LIBRARY}
") 524 add_library(OpenGL::GLES2 UNKNOWN IMPORTED) 525 set_target_properties(OpenGL::GLES2 PROPERTIES 526 IMPORTED_LOCATION "${OPENGL_gles2_LIBRARY}
" 529 add_library(OpenGL::GLES2 INTERFACE IMPORTED) 530 set_target_properties(OpenGL::GLES2 PROPERTIES 531 IMPORTED_LIBNAME "${OPENGL_gles2_LIBRARY}
" 536 # Attach target properties 537 set_target_properties(OpenGL::GLES2 539 INTERFACE_INCLUDE_DIRECTORIES 540 "${OPENGL_GLES2_INCLUDE_DIR}
" 541 INTERFACE_COMPILE_OPTIONS 542 "${_opengl_gles_cxx_flags}
" 543 INTERFACE_LINK_OPTIONS 544 "${_opengl_gles_cxx_flags}
" 547 if (OPENGL_USE_GLES2) 548 set(_OpenGL_EGL_IMPL OpenGL::GLES2) 551 unset(_opengl_gles_cxx_flags) 554 # ::GLES3 is a GLVND library, and thus Linux-only: we don't bother checking 555 # for a framework version of this library. 556 if(OpenGL_GLES3_FOUND AND NOT TARGET OpenGL::GLES3) 557 set(_opengl_gles_cxx_flags) 560 # For GLES3 we force EMSCRIPTEN to use WebGL 2 561 list(APPEND _opengl_gles_cxx_flags 562 "SHELL:-s FULL_ES3=1
" 564 if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "1.39.5
") 565 list(APPEND _opengl_gles_cxx_flags 566 "SHELL:-s MIN_WEBGL_VERSION=2
" 567 "SHELL:-s MAX_WEBGL_VERSION=2
" 570 list(APPEND _opengl_gles_cxx_flags 571 "SHELL:-s USE_WEBGL2=1
" 577 if(NOT OPENGL_gles3_LIBRARY) 578 add_library(OpenGL::GLES3 INTERFACE IMPORTED) 580 if(IS_ABSOLUTE "${OPENGL_gles3_LIBRARY}
") 581 add_library(OpenGL::GLES3 UNKNOWN IMPORTED) 582 set_target_properties(OpenGL::GLES3 PROPERTIES 583 IMPORTED_LOCATION "${OPENGL_gles3_LIBRARY}
" 586 add_library(OpenGL::GLES3 INTERFACE IMPORTED) 587 set_target_properties(OpenGL::GLES3 PROPERTIES 588 IMPORTED_LIBNAME "${OPENGL_gles3_LIBRARY}
" 593 # Attach target properties 594 set_target_properties(OpenGL::GLES3 PROPERTIES 595 INTERFACE_INCLUDE_DIRECTORIES 596 "${OPENGL_GLES3_INCLUDE_DIR}
" 597 INTERFACE_COMPILE_OPTIONS 598 "${_opengl_gles_cxx_flags}
" 599 INTERFACE_LINK_OPTIONS 600 "${_opengl_gles_cxx_flags}
" 603 if (OPENGL_USE_GLES3) 604 set(_OpenGL_EGL_IMPL OpenGL::GLES3) 607 unset(_opengl_gles_cxx_flags) 610 if(OPENGL_gl_LIBRARY AND NOT TARGET OpenGL::GL) 611 # A legacy GL library is available, so use it for the legacy GL target. 612 if(IS_ABSOLUTE "${OPENGL_gl_LIBRARY}
") 613 add_library(OpenGL::GL UNKNOWN IMPORTED) 614 if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$
") 615 set(_gl_fw "${OPENGL_gl_LIBRARY}/${CMAKE_MATCH_1}
") 616 if(EXISTS "${_gl_fw}.tbd
") 617 string(APPEND _gl_fw ".tbd
") 619 set_target_properties(OpenGL::GL PROPERTIES 620 IMPORTED_LOCATION "${_gl_fw}
") 622 set_target_properties(OpenGL::GL PROPERTIES 623 IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}
") 626 add_library(OpenGL::GL INTERFACE IMPORTED) 627 set_target_properties(OpenGL::GL PROPERTIES 628 IMPORTED_LIBNAME "${OPENGL_gl_LIBRARY}
") 630 set_target_properties(OpenGL::GL PROPERTIES 631 INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}
") 632 elseif(NOT TARGET OpenGL::GL AND TARGET OpenGL::OpenGL AND TARGET OpenGL::GLX) 633 # A legacy GL library is not available, but we can provide the legacy GL 634 # target using GLVND OpenGL+GLX. 635 add_library(OpenGL::GL INTERFACE IMPORTED) 636 set_target_properties(OpenGL::GL PROPERTIES INTERFACE_LINK_LIBRARIES 638 set_property(TARGET OpenGL::GL APPEND PROPERTY INTERFACE_LINK_LIBRARIES 640 set_target_properties(OpenGL::GL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 641 "${OPENGL_INCLUDE_DIR}
") 644 # ::EGL is a GLVND library, and thus Linux-only: we don't bother checking 645 # for a framework version of this library. 646 if(_OpenGL_EGL_IMPL AND OpenGL_EGL_FOUND AND NOT TARGET OpenGL::EGL) 647 if(IS_ABSOLUTE "${OPENGL_egl_LIBRARY}
") 648 add_library(OpenGL::EGL UNKNOWN IMPORTED) 649 set_target_properties(OpenGL::EGL PROPERTIES IMPORTED_LOCATION 650 "${OPENGL_egl_LIBRARY}
") 652 add_library(OpenGL::EGL INTERFACE IMPORTED) 653 set_target_properties(OpenGL::EGL PROPERTIES IMPORTED_LIBNAME 654 "${OPENGL_egl_LIBRARY}
") 656 set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_LINK_LIBRARIES 657 "${_OpenGL_EGL_IMPL}
") 658 # Note that EGL's include directory is different from OpenGL/GLX's! 659 set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 660 "${OPENGL_EGL_INCLUDE_DIR}
") 663 if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU) 664 if(IS_ABSOLUTE "${OPENGL_glu_LIBRARY}
") 665 add_library(OpenGL::GLU UNKNOWN IMPORTED) 666 if(OPENGL_glu_LIBRARY MATCHES "/([^/]+)\\.framework$
") 667 set(_glu_fw "${OPENGL_glu_LIBRARY}/${CMAKE_MATCH_1}
") 668 if(EXISTS "${_glu_fw}.tbd
") 669 string(APPEND _glu_fw ".tbd
") 671 set_target_properties(OpenGL::GLU PROPERTIES 672 IMPORTED_LOCATION "${_glu_fw}
") 674 set_target_properties(OpenGL::GLU PROPERTIES 675 IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}
") 678 add_library(OpenGL::GLU INTERFACE IMPORTED) 679 set_target_properties(OpenGL::GLU PROPERTIES 680 IMPORTED_LIBNAME "${OPENGL_glu_LIBRARY}
") 682 set_target_properties(OpenGL::GLU PROPERTIES 683 INTERFACE_LINK_LIBRARIES OpenGL::GL) 686 # OPENGL_LIBRARIES mirrors OpenGL::GL's logic ... 687 if(OPENGL_gl_LIBRARY) 688 set(OPENGL_LIBRARIES ${OPENGL_gl_LIBRARY}) 689 elseif(TARGET OpenGL::OpenGL AND TARGET OpenGL::GLX) 690 set(OPENGL_LIBRARIES ${OPENGL_opengl_LIBRARY} ${OPENGL_glx_LIBRARY}) 692 set(OPENGL_LIBRARIES "") 694 # ... and also includes GLU, if available. 695 if(TARGET OpenGL::GLU) 696 list(APPEND OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY}) 700 # This deprecated setting is for backward compatibility with CMake1.4 701 set(OPENGL_LIBRARY ${OPENGL_LIBRARIES}) 702 # This deprecated setting is for backward compatibility with CMake1.4 703 set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) 707 OPENGL_xmesa_INCLUDE_DIR 714 OPENGL_opengl_LIBRARY 715 OPENGL_EGL_INCLUDE_DIR 716 OPENGL_GLES2_INCLUDE_DIR 717 OPENGL_GLES3_INCLUDE_DIR 718 OPENGL_GLX_INCLUDE_DIR
int Run(int processType, int argc, char *argv[])