CMakeLists.txt 11.1 KB
Newer Older
1
2
3
4
if(TARGET vtkRenderingOpenGL)
  message(FATAL_ERROR "vtkRenderingOpenGL2 cannot be built with vtkRenderingOpenGL, please disable one of them.")
endif()

5
include(vtkOpenGL)
6
include(vtkObjectFactory)
7

8

9
10
# The TDx support has not been moved, this header is here to define nothing,
# and so allow classes in other modules to safely include it and keep going.
11
12
13
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vtkTDxConfigure.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/vtkTDxConfigure.h)

14
set(Module_SRCS
15
  ${CMAKE_CURRENT_BINARY_DIR}/${vtk-module}ObjectFactory.cxx
16
  vtkCameraPass.cxx
17
18
  vtkClearRGBPass.cxx
  vtkClearZPass.cxx
19
  vtkCompositePolyDataMapper2.cxx
20
  vtkDefaultPass.cxx
Ken Martin's avatar
Ken Martin committed
21
  vtkDepthOfFieldPass.cxx
Ken Martin's avatar
Ken Martin committed
22
  vtkDepthImageProcessingPass.cxx
23
  vtkDepthPeelingPass.cxx
Ken Martin's avatar
Ken Martin committed
24
  vtkDualDepthPeelingPass.cxx
Ken Martin's avatar
Ken Martin committed
25
  vtkEDLShading.cxx
26
  vtkFramebufferPass.cxx
27
  vtkGaussianBlurPass.cxx
28
  vtkGenericOpenGLRenderWindow.cxx
29
  vtkHiddenLineRemovalPass.cxx
30
  vtkImageProcessingPass.cxx
31
  vtkLightingMapPass.cxx
32
33
  vtkLightsPass.cxx
  vtkOpaquePass.cxx
34
  vtkOpenGLActor.cxx
David C. Lonie's avatar
David C. Lonie committed
35
  vtkOpenGLBillboardTextActor3D.cxx
Ken Martin's avatar
Ken Martin committed
36
  vtkOpenGLBufferObject.cxx
37
  vtkOpenGLCamera.cxx
David C. Lonie's avatar
David C. Lonie committed
38
  vtkOpenGLFXAAFilter.cxx
39
  vtkOpenGLFramebufferObject.cxx
David C. Lonie's avatar
David C. Lonie committed
40
  vtkOpenGLGL2PSHelper.cxx
Ken Martin's avatar
Ken Martin committed
41
  vtkOpenGLGlyph3DHelper.cxx
42
43
  vtkOpenGLGlyph3DMapper.cxx
  vtkOpenGLHardwareSelector.cxx
Ken Martin's avatar
Ken Martin committed
44
  vtkOpenGLHelper.cxx
45
  vtkOpenGLImageAlgorithmHelper.cxx
46
47
  vtkOpenGLImageMapper.cxx
  vtkOpenGLImageSliceMapper.cxx
Ken Martin's avatar
Ken Martin committed
48
  vtkOpenGLIndexBufferObject.cxx
49
  vtkOpenGLLabeledContourMapper.cxx
50
  vtkOpenGLLight.cxx
51
  vtkOpenGLPointGaussianMapper.cxx
Ken Martin's avatar
Ken Martin committed
52
  vtkOpenGLPolyDataMapper.cxx
53
54
  vtkOpenGLPolyDataMapper2D.cxx
  vtkOpenGLProperty.cxx
David C. Lonie's avatar
David C. Lonie committed
55
  vtkOpenGLRenderPass.cxx
David C. Lonie's avatar
David C. Lonie committed
56
  vtkOpenGLRenderTimer.cxx
57
  vtkOpenGLRenderTimerLog.cxx
58
  vtkOpenGLRenderUtilities.cxx
David C. Lonie's avatar
David C. Lonie committed
59
  vtkOpenGLRenderWindow.cxx
60
61
  vtkOpenGLRenderer.cxx
  vtkOpenGLShaderCache.cxx
62
  vtkOpenGLSkybox.cxx
63
64
  vtkOpenGLSphereMapper.cxx
  vtkOpenGLStickMapper.cxx
65
66
67
  vtkOpenGLTextActor.cxx
  vtkOpenGLTextActor3D.cxx
  vtkOpenGLTextMapper.cxx
68
  vtkOpenGLTexture.cxx
Ken Martin's avatar
Ken Martin committed
69
70
  vtkOpenGLVertexArrayObject.cxx
  vtkOpenGLVertexBufferObject.cxx
71
72
  vtkOpenGLVertexBufferObjectCache.cxx
  vtkOpenGLVertexBufferObjectGroup.cxx
73
  vtkOverlayPass.cxx
Ken Martin's avatar
Ken Martin committed
74
  vtkPixelBufferObject.cxx
75
  vtkPointFillPass.cxx
76
  vtkRenderPassCollection.cxx
Ken Martin's avatar
Ken Martin committed
77
  vtkRenderStepsPass.cxx
Ken Martin's avatar
Ken Martin committed
78
  vtkRenderbuffer.cxx
Ken Martin's avatar
Ken Martin committed
79
  vtkSSAAPass.cxx
80
  vtkSequencePass.cxx
81
82
  vtkShader.cxx
  vtkShaderProgram.cxx
Ken Martin's avatar
Ken Martin committed
83
84
  vtkShadowMapBakerPass.cxx
  vtkShadowMapPass.cxx
Ken Martin's avatar
Ken Martin committed
85
  vtkSimpleMotionBlurPass.cxx
86
  vtkSobelGradientMagnitudePass.cxx
87
  vtkTextureObject.cxx
88
  vtkTextureUnitManager.cxx
David C. Lonie's avatar
David C. Lonie committed
89
  vtkTransformFeedback.cxx
90
  vtkTranslucentPass.cxx
Ken Martin's avatar
Ken Martin committed
91
  vtkValuePass.cxx
92
  vtkVolumetricPass.cxx
93
94
  )

Ken Martin's avatar
Ken Martin committed
95
if (NOT DEFINED OPENGL_ES_VERSION)
96
  set(Module_SRCS ${Module_SRCS}
Ken Martin's avatar
Ken Martin committed
97
    vtkDataTransferHelper.cxx
Ken Martin's avatar
Ken Martin committed
98
    )
99
100
endif()

101
102
103
104
set(${vtk-module}_HDRS
  vtkOpenGL.h
  ${CMAKE_CURRENT_BINARY_DIR}/vtkTDxConfigure.h
  ${CMAKE_CURRENT_BINARY_DIR}/vtkOpenGLError.h
105
  ${CMAKE_CURRENT_BINARY_DIR}/vtkRenderingOpenGLConfigure.h
106
107
  )

108
set_source_files_properties(
Ken Martin's avatar
Ken Martin committed
109
  ${CMAKE_CURRENT_BINARY_DIR}/${vtk-module}ObjectFactory.cxx
110
  vtkOpenGLFramebufferObject
Ken Martin's avatar
Ken Martin committed
111
  vtkOpenGLBufferObject
David C. Lonie's avatar
David C. Lonie committed
112
  vtkOpenGLGL2PSHelper
113
114
  vtkOpenGLGlyph3DHelper
  vtkOpenGLGlyph3DMapper
Ken Martin's avatar
Ken Martin committed
115
116
  vtkOpenGLHelper
  vtkOpenGLIndexBufferObject
117
  vtkOpenGLRenderTimer
118
  vtkOpenGLShaderCache
Ken Martin's avatar
Ken Martin committed
119
120
  vtkOpenGLVertexArrayObject
  vtkOpenGLVertexBufferObject
121
  vtkOpenGLVertexBufferObjectCache
122
  vtkPixelBufferObject
Ken Martin's avatar
Ken Martin committed
123
  vtkRenderbuffer
124
  vtkTextureObject
125
  vtkTextureUnitManager
David C. Lonie's avatar
David C. Lonie committed
126
  vtkTransformFeedback
127
128
  WRAP_EXCLUDE)

129
130
set_source_files_properties(
  ${CMAKE_CURRENT_BINARY_DIR}/${vtk-module}ObjectFactory.cxx
David C. Lonie's avatar
David C. Lonie committed
131
  vtkOpenGLGL2PSHelper
132
133
  vtkOpenGLGlyph3DHelper
  vtkOpenGLHelper
134
  vtkOpenGLRenderTimer
135
136
  PROPERTIES WRAP_EXCLUDE_PYTHON 1)

137
set(shader_files
Ken Martin's avatar
Ken Martin committed
138
  glsl/vtkDepthOfFieldPassFS.glsl
139
140
  glsl/vtkDepthPeelingPassFinalFS.glsl
  glsl/vtkDepthPeelingPassIntermediateFS.glsl
Ken Martin's avatar
Ken Martin committed
141
  glsl/vtkEDLBilateralFilterFS.glsl
Ken Martin's avatar
Ken Martin committed
142
143
  glsl/vtkEDLComposeFS.glsl
  glsl/vtkEDLShadeFS.glsl
David C. Lonie's avatar
David C. Lonie committed
144
  glsl/vtkFXAAFilterFS.glsl
145
146
  glsl/vtkGaussianBlurPassFS.glsl
  glsl/vtkGaussianBlurPassVS.glsl
Ken Martin's avatar
Ken Martin committed
147
  glsl/vtkGlyph3DVS.glsl
Ken Martin's avatar
Ken Martin committed
148
  glsl/vtkPointGaussianVS.glsl
149
  glsl/vtkPointFillPassFS.glsl
Ken Martin's avatar
Ken Martin committed
150
151
152
153
  glsl/vtkPolyData2DFS.glsl
  glsl/vtkPolyData2DVS.glsl
  glsl/vtkPolyDataFS.glsl
  glsl/vtkPolyDataVS.glsl
Ken Martin's avatar
Ken Martin committed
154
155
  glsl/vtkPolyDataWideLineGS.glsl
  glsl/vtkSSAAPassFS.glsl
Ken Martin's avatar
Ken Martin committed
156
  glsl/vtkSimpleMotionBlurPassFS.glsl
Ken Martin's avatar
Ken Martin committed
157
158
  glsl/vtkSobelGradientMagnitudePass1FS.glsl
  glsl/vtkSobelGradientMagnitudePass2FS.glsl
159
160
  glsl/vtkSphereMapperVS.glsl
  glsl/vtkStickMapperVS.glsl
Ken Martin's avatar
Ken Martin committed
161
162
  glsl/vtkTextureObjectFS.glsl
  glsl/vtkTextureObjectVS.glsl
163
164
165
  )
unset(shader_h_files)
foreach(file ${shader_files})
166
167
168
169
170
171
172
173
174
175
  vtk_encode_string(
    INPUT         "${file}"
    EXPORT_SYMBOL "VTKRENDERINGOPENGL2_EXPORT"
    EXPORT_HEADER "vtkRenderingOpenGL2Module.h"
    HEADER_OUTPUT header
    SOURCE_OUTPUT source)
  list(APPEND Module_SRCS ${source})
  set_source_files_properties(
    ${header}
    ${source}
176
177
178
179
    PROPERTIES
      WRAP_EXCLUDE 1
      WRAP_EXCLUDE_PYTHON 1
    )
180
181
endforeach()

182
183
184
185
186
187
188
189
if(VTK_USE_X)
  find_package(X11 REQUIRED)
  if(NOT X11_Xt_FOUND)
    message(FATAL_ERROR "X11_Xt_LIB could not be found. Required for VTK X lib.")
  endif()
  include_directories(${X11_INCLUDE_DIR} ${X11_Xt_INCLUDE_PATH})
endif()

Ken Martin's avatar
Ken Martin committed
190
# setup factory overrides
191
192
set(opengl_overrides
  Actor
David C. Lonie's avatar
David C. Lonie committed
193
  BillboardTextActor3D
194
  Camera
195
  LabeledContourMapper
196
197
198
199
200
  HardwareSelector
  ImageMapper
  ImageSliceMapper
  Glyph3DMapper
  Light
201
  PointGaussianMapper
Ken Martin's avatar
Ken Martin committed
202
  PolyDataMapper
203
204
205
  PolyDataMapper2D
  Property
  Renderer
206
  RenderTimerLog
207
  Skybox
208
209
210
  TextActor
  TextActor3D
  TextMapper
211
212
  Texture
  )
213
214
215
216
217
218

# Now to see about the GPU info list.
list(APPEND vtk_module_overrides "vtkGPUInfoList")
list(APPEND Module_SRCS "vtkDummyGPUInfoList.cxx")
set(vtk_module_vtkGPUInfoList_override "vtkDummyGPUInfoList")

219
220
221
foreach(_override ${opengl_overrides})
  vtk_add_override(vtk${_override} vtkOpenGL${_override})
endforeach()
Ken Martin's avatar
Ken Martin committed
222

223
224
225
226
227
228
229
230
231
232
233
234
235
236

# Update sources to include render window specializations for
# offscreen-only modes, if enabled.
if(VTK_OPENGL_HAS_OSMESA)
  list(APPEND Module_SRCS vtkOSOpenGLRenderWindow.cxx)
endif()
if(VTK_OPENGL_HAS_EGL OR ANDROID)
  list(APPEND Module_SRCS vtkEGLRenderWindow.cxx)
  set_source_files_properties(vtkEGLRenderWindow.cxx
    PROPERTIES COMPILE_DEFINITIONS
    "VTK_DEFAULT_EGL_DEVICE_INDEX=${VTK_DEFAULT_EGL_DEVICE_INDEX}")
endif()

# Setup factory overrides and add window system specific render windows.
Ken Martin's avatar
Ken Martin committed
237
238
if(VTK_USE_X)
  # Add some custom overrides
239
240
241
242
  if(NOT VTK_DEFAULT_RENDER_WINDOW_HEADLESS)
    vtk_add_override("vtkRenderWindowInteractor" "vtkXRenderWindowInteractor")
    vtk_add_override("vtkRenderWindow" "vtkXOpenGLRenderWindow")
  endif()
Ken Martin's avatar
Ken Martin committed
243
  list(APPEND Module_SRCS
244
    vtkXRenderWindowInteractor.cxx
245
    vtkXOpenGLRenderWindow.cxx)
Ken Martin's avatar
Ken Martin committed
246
247
elseif(WIN32)
  # Add some custom overrides
248
249
250
251
  if(NOT VTK_DEFAULT_RENDER_WINDOW_HEADLESS)
    vtk_add_override("vtkRenderWindowInteractor" "vtkWin32RenderWindowInteractor")
    vtk_add_override("vtkRenderWindow" "vtkWin32OpenGLRenderWindow")
  endif()
Ken Martin's avatar
Ken Martin committed
252
  list(APPEND Module_SRCS
253
    vtkWin32RenderWindowInteractor.cxx
Ken Martin's avatar
Ken Martin committed
254
    vtkWin32OpenGLRenderWindow.cxx
Ken Martin's avatar
Ken Martin committed
255
256
257
    )
elseif(VTK_USE_COCOA)
  # Add some custom overrides
258
259
260
261
  if(NOT VTK_DEFAULT_RENDER_WINDOW_HEADLESS)
    vtk_add_override("vtkRenderWindowInteractor" "vtkCocoaRenderWindowInteractor")
    vtk_add_override("vtkRenderWindow" "vtkCocoaRenderWindow")
  endif()
Ken Martin's avatar
Ken Martin committed
262
263
264
265
266
267
268
269
270
271
272
273
274
275
  list(APPEND Module_SRCS
    vtkCocoaRenderWindowInteractor.mm
    vtkCocoaRenderWindow.mm
    vtkCocoaGLView.mm
    )
  list(APPEND ${vtk-module}_HDRS
    vtkCocoaMacOSXSDKCompatibility.h
    )
  # Set specified Objective-C++ flags, if any.
  if(VTK_REQUIRED_OBJCXX_FLAGS)
    set_source_files_properties(vtkCocoaRenderWindowInteractor.mm
                                vtkCocoaRenderWindow.mm
                                vtkCocoaGLView.mm
                                PROPERTIES COMPILE_FLAGS "${VTK_REQUIRED_OBJCXX_FLAGS}")
276
  endif()
277
278
279
280
281
282
  set_source_files_properties(
    vtkCocoaGLView
    PROPERTIES
      WRAP_EXCLUDE 1
      WRAP_EXCLUDE_PYTHON 1
    )
283
284
elseif(ANDROID)
  # Add some custom overrides
285
286
  vtk_add_override("vtkRenderWindowInteractor" "vtkAndroidRenderWindowInteractor")
  vtk_add_override("vtkRenderWindow" "vtkEGLRenderWindow")
287
  list(APPEND Module_SRCS
Ken Martin's avatar
Ken Martin committed
288
    vtkAndroidRenderWindowInteractor.cxx
289
    # vtkEGLRenderWindow.cxx -- already added above.
290
    )
Ken Martin's avatar
Ken Martin committed
291
  include_directories(
292
    "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue"
Ken Martin's avatar
Ken Martin committed
293
    )
294
295
elseif(APPLE_IOS)
  # Add some custom overrides
296
297
  vtk_add_override("vtkRenderWindowInteractor" "vtkIOSRenderWindowInteractor")
  vtk_add_override("vtkRenderWindow" "vtkIOSRenderWindow")
Ken Martin's avatar
Ken Martin committed
298
299
300
301
302
303
304
305
306
  list(APPEND Module_SRCS
    vtkIOSRenderWindowInteractor.mm
    vtkIOSRenderWindow.mm
    )
  # Set specified Objective-C++ flags, if any.
  if(VTK_REQUIRED_OBJCXX_FLAGS)
    set_source_files_properties(vtkIOSRenderWindowInteractor.mm
                                vtkIOSRenderWindow.mm
                                PROPERTIES COMPILE_FLAGS "${VTK_REQUIRED_OBJCXX_FLAGS}")
307
  endif()
308
309
310
311
endif()

# If no overrides were defined for vtkRenderWindow and any of the offscreen
# features were available, make the approriate render window the default.
312
if(VTK_DEFAULT_RENDER_WINDOW_HEADLESS OR NOT DEFINED vtk_module_vtkRenderWindow_override)
313
314
315
316
317
318
  if(VTK_OPENGL_HAS_EGL)
    vtk_add_override("vtkRenderWindow" "vtkEGLRenderWindow")
  elseif(VTK_OPENGL_HAS_OSMESA)
    vtk_add_override("vtkRenderWindow" "vtkOSOpenGLRenderWindow")
  endif()
endif()
Ken Martin's avatar
Ken Martin committed
319

320
vtk_object_factory_configure("${vtk_module_overrides}")
321

322
323
324
# Detect and clear OpenGL errors. If not then other classes/user code
# may detect VTK's OpenGL errors and vice-versa.
set(VTK_REPORT_OPENGL_ERRORS ON CACHE BOOL "Enable OpenGL error check and report")
325
326
327
328
cmake_dependent_option(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS
  "Enable OpenGL error check and reporting in non-debug builds." OFF
  VTK_REPORT_OPENGL_ERRORS OFF)
mark_as_advanced(VTK_REPORT_OPENGL_ERRORS VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS)
329
330
331
332
configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/vtkOpenGLError.h.in
    ${CMAKE_CURRENT_BINARY_DIR}/vtkOpenGLError.h)

333
334
335
336
337
# Configure the module specific settings into a module configured header.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vtkRenderingOpenGLConfigure.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/vtkRenderingOpenGLConfigure.h)
# Set up some of the module specific preprocessor definitions.
set(${vtk-module}_EXPORT_CODE "#include \"vtkRenderingOpenGLConfigure.h\"")
Ken Martin's avatar
Ken Martin committed
338

339
vtk_module_library(${vtk-module} ${Module_SRCS})
340
vtk_opengl_link(${vtk-module})
341
if(VTK_USE_X)
342
  vtk_module_link_libraries(${vtk-module}
343
    LINK_PUBLIC ${X11_LIBRARIES} ${X11_Xt_LIB})
Ken Martin's avatar
Ken Martin committed
344
345
elseif(VTK_USE_COCOA)
  vtk_module_link_libraries(${vtk-module} LINK_PUBLIC "-framework Cocoa")
346
endif()
347
348
349

if(ANDROID)
  target_link_libraries(${vtk-module}
350
351
352
    LINK_PUBLIC ${OPENGL_egl_LIBRARY}
    LINK_PRIVATE android
    )
353
endif()
Ken Martin's avatar
Ken Martin committed
354
355
356
357

if (APPLE_IOS)
  vtk_module_link_libraries(${vtk-module} LINK_PUBLIC "-framework UIKit")
endif()
358

359
360
361
VTK_ADD_EXECUTABLE(vtkProbeOpenGLVersion vtkProbeOpenGLVersion.cxx)
target_link_libraries(vtkProbeOpenGLVersion ${vtk-module})

362
363
364
365
366
367
368
369
if (WIN32 AND ( NOT CMAKE_CROSSCOMPILING OR DEFINED CMAKE_CROSSCOMPILING_EMULATOR) )
  VTK_ADD_EXECUTABLE(vtkTestOpenGLVersion vtkTestOpenGLVersion.cxx)
  set_target_properties(vtkTestOpenGLVersion
    PROPERTIES
      WIN32_EXECUTABLE TRUE
      )
  target_link_libraries(vtkTestOpenGLVersion opengl32)
endif()