File: vtkOpenGLOptions.cmake

package info (click to toggle)
paraview 5.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 497,236 kB
  • sloc: cpp: 3,171,290; ansic: 1,315,072; python: 134,290; xml: 103,324; sql: 65,887; sh: 5,286; javascript: 4,901; yacc: 4,383; java: 3,977; perl: 2,363; lex: 1,909; f90: 1,255; objc: 143; makefile: 119; tcl: 59; pascal: 50; fortran: 29
file content (138 lines) | stat: -rw-r--r-- 5,396 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#[==[.md
# vtkOpenGLOptions

This module provides options that control which OpenGL and Windowing system
libraries are used.

#]==]
include(CMakeDependentOption)

# For each platform specific API, we define VTK_USE_<API> options.
cmake_dependent_option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON
  "APPLE;NOT APPLE_IOS" OFF)
mark_as_advanced(VTK_USE_COCOA)

set(default_use_x OFF)
if(UNIX AND NOT ANDROID AND NOT APPLE AND NOT APPLE_IOS AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
  set(default_use_x ON)
endif()
option(VTK_USE_X "Use X for VTK render windows" "${default_use_x}")
mark_as_advanced(VTK_USE_X)

set(default_use_sdl2 OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
  set(default_use_sdl2 ON)
endif()
option(VTK_USE_SDL2 "Add SDL2 classes to VTK" "${default_use_sdl2}")
mark_as_advanced(VTK_USE_SDL2)

# For optional APIs that could be available for the OpenGL implementation
# being used, we define VTK_OPENGL_HAS_<feature> options. These are not to be
# treated as mutually exclusive.

#-----------------------------------------------------------------------------
# OSMesa variables
#-----------------------------------------------------------------------------
# OpenGL implementation supports OSMesa for creating offscreen context.
option(VTK_OPENGL_HAS_OSMESA
  "The OpenGL library being used supports offscreen Mesa (OSMesa)" OFF)
mark_as_advanced(VTK_OPENGL_HAS_OSMESA)

#-----------------------------------------------------------------------------
# GLES variables
#-----------------------------------------------------------------------------

set(default_has_egl OFF)
if (ANDROID)
  set(VTK_OPENGL_USE_GLES ON)
  set(default_has_egl ON)
else ()
  # OpenGLES implementation.
  option(VTK_OPENGL_USE_GLES "Use the OpenGL ES API" OFF)
  mark_as_advanced(VTK_OPENGL_USE_GLES)
endif ()

#-----------------------------------------------------------------------------
# EGL variables
#-----------------------------------------------------------------------------
# OpenGL implementation supports EGL for creating offscreen context.
option(VTK_OPENGL_HAS_EGL "The OpenGL library being used supports EGL" "${default_has_egl}")
mark_as_advanced(VTK_OPENGL_HAS_EGL)

set(VTK_DEFAULT_EGL_DEVICE_INDEX "0" CACHE STRING
  "EGL device (graphics card) index to use by default for EGL render windows.")
mark_as_advanced(VTK_DEFAULT_EGL_DEVICE_INDEX)

#-----------------------------------------------------------------------------
# Irrespective of support for offscreen API, VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN
# lets the user select the default state for the  `Offscreen` flag on the
# vtkRenderWindow when it is instantiated (formerly VTK_USE_OFFSCREEN).
option(VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN "Use offscreen render window by default" OFF)
mark_as_advanced(VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)

#-----------------------------------------------------------------------------
set(vtk_can_do_offscreen FALSE)
set(vtk_can_do_onscreen FALSE)
set(vtk_can_do_headless FALSE)

if (WIN32 OR VTK_OPENGL_HAS_OSMESA OR VTK_OPENGL_HAS_EGL OR VTK_USE_SDL2)
  set(vtk_can_do_offscreen TRUE)
endif ()
if (WIN32 OR VTK_USE_COCOA OR VTK_USE_X OR VTK_USE_SDL2) # XXX: See error message below.
  set(vtk_can_do_onscreen TRUE)
endif ()

if (VTK_OPENGL_HAS_OSMESA OR VTK_OPENGL_HAS_EGL)
  set(vtk_can_do_headless TRUE)
endif ()

# iOS does not use EGL
if (APPLE_IOS)
  set(vtk_can_do_offscreen TRUE)
  set(vtk_can_do_onscreen TRUE)
  set(vtk_can_do_headless FALSE)
endif ()

if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
  set(vtk_can_do_headless FALSE)
endif ()

if (NOT vtk_can_do_onscreen AND NOT vtk_can_do_offscreen)
  message(FATAL_ERROR
    "VTK current build configuration is not satisfiable as it supports neither onscreen "
    "nor offscreen rendering. Make sure to set to ON at least one of the following to "
    "be able to configure: `VTK_USE_X`, `VTK_USE_COCOA`, `VTK_OPENGL_HAS_OSMESA`, "
    "`VTK_OPENGL_HAS_EGL` or `VTK_USE_SDL2`.")
endif ()

if (VTK_OPENGL_HAS_OSMESA AND VTK_OPENGL_HAS_EGL)
  message(FATAL_ERROR
    "`VTK_OPENGL_HAS_OSMESA` and `VTK_OPENGL_HAS_EGL` option can't be both "
    "set to `ON`. The current build configuration is not satisfiable. "
    "Please set to `OFF` any of these two.")
endif ()

if (VTK_OPENGL_HAS_OSMESA AND vtk_can_do_onscreen)
  message(FATAL_ERROR
    "The `VTK_OPENGL_HAS_OSMESA` can't be set to `ON` if any of the following is true: "
    "the target platform is Windows, `VTK_USE_COCOA` is `ON`, or `VTK_USE_X` "
    "is `ON` or `VTK_USE_SDL2` is `ON`. OSMesa does not support on-screen "
    "rendering and VTK's OpenGL selection is at build time, so the current "
    "build configuration is not satisfiable.")
endif ()

cmake_dependent_option(
  VTK_USE_OPENGL_DELAYED_LOAD
  "Use delay loading for OpenGL"
  OFF "WIN32;COMMAND target_link_options" OFF)
mark_as_advanced(VTK_USE_OPENGL_DELAYED_LOAD)

#-----------------------------------------------------------------------------
# For builds where we can support both on-screen and headless rendering, the default
# is to create an on-screen render window. Setting this option to ON will change the default
# to create an headless render window by default instead.
cmake_dependent_option(
  VTK_DEFAULT_RENDER_WINDOW_HEADLESS
  "Enable to create the headless render window when `vtkRenderWindow` is instantiated."
  OFF
  "vtk_can_do_onscreen;vtk_can_do_headless" OFF)