CMakeLists.txt 11.3 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
21
  vtkDepthOfFieldPass.cxx
22
  vtkDepthImageProcessingPass.cxx
23
  vtkDepthPeelingPass.cxx
24
  vtkEDLShading.cxx
25
  vtkFrameBufferObject.cxx
26
  vtkGaussianBlurPass.cxx
27
  vtkGenericOpenGLRenderWindow.cxx
28
  vtkHiddenLineRemovalPass.cxx
29
  vtkImageProcessingPass.cxx
30
  vtkLightingMapPass.cxx
31 32
  vtkLightsPass.cxx
  vtkOpaquePass.cxx
33
  vtkOpenGLActor.cxx
Ken Martin's avatar
Ken Martin committed
34
  vtkOpenGLBufferObject.cxx
35
  vtkOpenGLCamera.cxx
36
  vtkOpenGLFXAAFilter.cxx
37
  vtkOpenGLGL2PSHelper.cxx
Ken Martin's avatar
Ken Martin committed
38
  vtkOpenGLGlyph3DHelper.cxx
39 40
  vtkOpenGLGlyph3DMapper.cxx
  vtkOpenGLHardwareSelector.cxx
Ken Martin's avatar
Ken Martin committed
41
  vtkOpenGLHelper.cxx
42
  vtkOpenGLImageAlgorithmHelper.cxx
43 44
  vtkOpenGLImageMapper.cxx
  vtkOpenGLImageSliceMapper.cxx
Ken Martin's avatar
Ken Martin committed
45
  vtkOpenGLIndexBufferObject.cxx
46
  vtkOpenGLLabeledContourMapper.cxx
47
  vtkOpenGLLight.cxx
48
  vtkOpenGLPointGaussianMapper.cxx
Ken Martin's avatar
Ken Martin committed
49
  vtkOpenGLPolyDataMapper.cxx
50 51
  vtkOpenGLPolyDataMapper2D.cxx
  vtkOpenGLProperty.cxx
52
  vtkOpenGLRenderPass.cxx
53
  vtkOpenGLRenderTimer.cxx
54
  vtkOpenGLRenderUtilities.cxx
55
  vtkOpenGLRenderWindow.cxx
56 57
  vtkOpenGLRenderer.cxx
  vtkOpenGLShaderCache.cxx
58 59
  vtkOpenGLSphereMapper.cxx
  vtkOpenGLStickMapper.cxx
60 61 62
  vtkOpenGLTextActor.cxx
  vtkOpenGLTextActor3D.cxx
  vtkOpenGLTextMapper.cxx
63
  vtkOpenGLTexture.cxx
Ken Martin's avatar
Ken Martin committed
64 65
  vtkOpenGLVertexArrayObject.cxx
  vtkOpenGLVertexBufferObject.cxx
66
  vtkOverlayPass.cxx
67
  vtkPointFillPass.cxx
68
  vtkRenderPassCollection.cxx
Ken Martin's avatar
Ken Martin committed
69
  vtkRenderStepsPass.cxx
70
  vtkSSAAPass.cxx
71
  vtkSequencePass.cxx
72 73
  vtkShader.cxx
  vtkShaderProgram.cxx
74 75
  vtkShadowMapBakerPass.cxx
  vtkShadowMapPass.cxx
76
  vtkSobelGradientMagnitudePass.cxx
77
  vtkTextureObject.cxx
78
  vtkTextureUnitManager.cxx
79
  vtkTransformFeedback.cxx
80
  vtkTranslucentPass.cxx
Tim Thirion's avatar
Tim Thirion committed
81
  vtkValuePass.cxx
82
  vtkValuePassHelper.cxx
83
  vtkVolumetricPass.cxx
84 85
  )

Ken Martin's avatar
Ken Martin committed
86
if (NOT DEFINED OPENGL_ES_VERSION)
87
  set(Module_SRCS ${Module_SRCS}
Ken Martin's avatar
Ken Martin committed
88
    vtkDataTransferHelper.cxx
89
    vtkDualDepthPeelingPass.cxx # Needs GL_MAX
Ken Martin's avatar
Ken Martin committed
90
    vtkFrameBufferObject2.cxx
91
    vtkPixelBufferObject.cxx
92
    vtkRenderbuffer.cxx
93 94 95 96
    )
else()
  if (${OPENGL_ES_VERSION} MATCHES 3.0)
    set(Module_SRCS ${Module_SRCS}
97
      vtkDualDepthPeelingPass.cxx # Needs GL_MAX
Ken Martin's avatar
Ken Martin committed
98
      vtkFrameBufferObject2.cxx
99
      vtkPixelBufferObject.cxx
100
      vtkRenderbuffer.cxx
101 102
      )
  endif()
103 104
endif()

105 106 107 108
set(${vtk-module}_HDRS
  vtkOpenGL.h
  ${CMAKE_CURRENT_BINARY_DIR}/vtkTDxConfigure.h
  ${CMAKE_CURRENT_BINARY_DIR}/vtkOpenGLError.h
109
  ${CMAKE_CURRENT_BINARY_DIR}/vtkRenderingOpenGLConfigure.h
110 111
  )

112
set_source_files_properties(
Ken Martin's avatar
Ken Martin committed
113
  ${CMAKE_CURRENT_BINARY_DIR}/${vtk-module}ObjectFactory.cxx
114
  vtkFrameBufferObject
Ken Martin's avatar
Ken Martin committed
115
  vtkOpenGLBufferObject
116
  vtkOpenGLGL2PSHelper
117 118
  vtkOpenGLGlyph3DHelper
  vtkOpenGLGlyph3DMapper
Ken Martin's avatar
Ken Martin committed
119 120
  vtkOpenGLHelper
  vtkOpenGLIndexBufferObject
121
  vtkOpenGLRenderTimer
122
  vtkOpenGLShaderCache
Ken Martin's avatar
Ken Martin committed
123 124
  vtkOpenGLVertexArrayObject
  vtkOpenGLVertexBufferObject
125
  vtkPixelBufferObject
Ken Martin's avatar
Ken Martin committed
126
  vtkRenderbuffer
127
  vtkTextureObject
128
  vtkTextureUnitManager
129
  vtkTransformFeedback
130
  vtkValuePassHelper
131 132
  WRAP_EXCLUDE)

133 134
set_source_files_properties(
  ${CMAKE_CURRENT_BINARY_DIR}/${vtk-module}ObjectFactory.cxx
135
  vtkOpenGLGL2PSHelper
136 137
  vtkOpenGLGlyph3DHelper
  vtkOpenGLHelper
138
  vtkOpenGLRenderTimer
139
  vtkValuePassHelper
140 141
  PROPERTIES WRAP_EXCLUDE_PYTHON 1)

142
set_source_files_properties(
143
  vtkOpenGLGL2PSHelper
144 145 146 147
  vtkOpenGLRenderWindow
  ABSTRACT
  )

148
set(shader_files
149
  glsl/vtkDepthOfFieldPassFS.glsl
150 151
  glsl/vtkDepthPeelingPassFinalFS.glsl
  glsl/vtkDepthPeelingPassIntermediateFS.glsl
152
  glsl/vtkEDLBilateralFilterFS.glsl
153 154
  glsl/vtkEDLComposeFS.glsl
  glsl/vtkEDLShadeFS.glsl
155
  glsl/vtkFXAAFilterFS.glsl
156 157
  glsl/vtkGaussianBlurPassFS.glsl
  glsl/vtkGaussianBlurPassVS.glsl
Ken Martin's avatar
Ken Martin committed
158
  glsl/vtkGlyph3DVS.glsl
159
  glsl/vtkPointGaussianVS.glsl
160
  glsl/vtkPointFillPassFS.glsl
Ken Martin's avatar
Ken Martin committed
161 162 163 164
  glsl/vtkPolyData2DFS.glsl
  glsl/vtkPolyData2DVS.glsl
  glsl/vtkPolyDataFS.glsl
  glsl/vtkPolyDataVS.glsl
165 166 167 168
  glsl/vtkPolyDataWideLineGS.glsl
  glsl/vtkSSAAPassFS.glsl
  glsl/vtkSobelGradientMagnitudePass1FS.glsl
  glsl/vtkSobelGradientMagnitudePass2FS.glsl
169 170
  glsl/vtkSphereMapperVS.glsl
  glsl/vtkStickMapperVS.glsl
171 172
  glsl/vtkTextureObjectFS.glsl
  glsl/vtkTextureObjectVS.glsl
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
  )
unset(shader_h_files)
foreach(file ${shader_files})
  get_filename_component(file_we ${file} NAME_WE)
  set(src  ${CMAKE_CURRENT_SOURCE_DIR}/${file})
  set(res  ${CMAKE_CURRENT_BINARY_DIR}/${file_we}.cxx)
  set(resh ${CMAKE_CURRENT_BINARY_DIR}/${file_we}.h)
  list(APPEND shader_h_files ${resh})
  add_custom_command(
    OUTPUT ${res} ${resh}
    DEPENDS ${src} vtkEncodeString
    COMMAND vtkEncodeString
    ARGS ${res} ${src} ${file_we}
      --build-header VTKRENDERINGOPENGL2_EXPORT vtkRenderingOpenGL2Module.h
    )
  list(APPEND Module_SRCS ${res})
189 190 191 192 193
  set_source_files_properties(${file_we}
    PROPERTIES
      WRAP_EXCLUDE 1
      WRAP_EXCLUDE_PYTHON 1
    )
194 195
endforeach()

196 197 198 199 200 201 202 203
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
204
# setup factory overrides
205 206 207
set(opengl_overrides
  Actor
  Camera
208
  LabeledContourMapper
209 210 211 212 213
  HardwareSelector
  ImageMapper
  ImageSliceMapper
  Glyph3DMapper
  Light
214
  PointGaussianMapper
Ken Martin's avatar
Ken Martin committed
215
  PolyDataMapper
216 217 218
  PolyDataMapper2D
  Property
  Renderer
219 220 221
  TextActor
  TextActor3D
  TextMapper
222 223
  Texture
  )
224 225 226 227 228 229

# 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")

230 231 232
foreach(_override ${opengl_overrides})
  vtk_add_override(vtk${_override} vtkOpenGL${_override})
endforeach()
Ken Martin's avatar
Ken Martin committed
233 234 235 236 237 238 239 240 241 242

# FIXME: Not sure that this is the best way to handle X...
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})
  # Add some custom overrides
  list(APPEND vtk_module_overrides "vtkRenderWindowInteractor")
243
  set(vtk_module_vtkRenderWindowInteractor_override "vtkXRenderWindowInteractor")
Ken Martin's avatar
Ken Martin committed
244
  list(APPEND vtk_module_overrides "vtkRenderWindow")
245
  set(vtk_module_vtkRenderWindow_override "vtkXOpenGLRenderWindow")
Ken Martin's avatar
Ken Martin committed
246
  list(APPEND Module_SRCS
247
    vtkXRenderWindowInteractor.cxx
248
    vtkXOpenGLRenderWindow.cxx
Ken Martin's avatar
Ken Martin committed
249 250 251
    )
elseif(VTK_USE_OSMESA)
  list(APPEND vtk_module_overrides "vtkRenderWindow")
252 253
  set(vtk_module_vtkRenderWindow_override "vtkOSOpenGLRenderWindow")
  list(APPEND Module_SRCS vtkOSOpenGLRenderWindow.cxx)
254 255 256 257 258 259 260
elseif(VTK_USE_OFFSCREEN_EGL)
  list(APPEND vtk_module_overrides "vtkRenderWindow")
  set(vtk_module_vtkRenderWindow_override "vtkEGLRenderWindow")
  list(APPEND Module_SRCS vtkEGLRenderWindow.cxx)
  set_source_files_properties(
    vtkEGLRenderWindow.cxx
    PROPERTIES COMPILE_DEFINITIONS "VTK_EGL_DEVICE_INDEX=${VTK_EGL_DEVICE_INDEX};VTK_USE_OFFSCREEN_EGL")
Ken Martin's avatar
Ken Martin committed
261 262 263
elseif(WIN32)
  # Add some custom overrides
  list(APPEND vtk_module_overrides "vtkRenderWindowInteractor")
264
  set(vtk_module_vtkRenderWindowInteractor_override "vtkWin32RenderWindowInteractor")
Ken Martin's avatar
Ken Martin committed
265
  list(APPEND vtk_module_overrides "vtkRenderWindow")
Ken Martin's avatar
Ken Martin committed
266
  set(vtk_module_vtkRenderWindow_override "vtkWin32OpenGLRenderWindow")
Ken Martin's avatar
Ken Martin committed
267
  list(APPEND Module_SRCS
268
    vtkWin32RenderWindowInteractor.cxx
Ken Martin's avatar
Ken Martin committed
269
    vtkWin32OpenGLRenderWindow.cxx
Ken Martin's avatar
Ken Martin committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
    )
elseif(VTK_USE_COCOA)
  # Add some custom overrides
  list(APPEND vtk_module_overrides "vtkRenderWindowInteractor")
  set(vtk_module_vtkRenderWindowInteractor_override "vtkCocoaRenderWindowInteractor")
  list(APPEND vtk_module_overrides "vtkRenderWindow")
  set(vtk_module_vtkRenderWindow_override "vtkCocoaRenderWindow")
  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}")
291
  endif()
292 293 294 295 296 297
  set_source_files_properties(
    vtkCocoaGLView
    PROPERTIES
      WRAP_EXCLUDE 1
      WRAP_EXCLUDE_PYTHON 1
    )
298 299
elseif(ANDROID)
  # Add some custom overrides
300 301
  list(APPEND vtk_module_overrides "vtkRenderWindowInteractor")
  set(vtk_module_vtkRenderWindowInteractor_override "vtkAndroidRenderWindowInteractor")
302 303 304
  list(APPEND vtk_module_overrides "vtkRenderWindow")
  set(vtk_module_vtkRenderWindow_override "vtkEGLRenderWindow")
  list(APPEND Module_SRCS
305
    vtkAndroidRenderWindowInteractor.cxx
306 307
    vtkEGLRenderWindow.cxx
    )
308 309 310 311
  include_directories(
    "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include"
    "${ANDROID_NDK}/sources/android/native_app_glue"
    )
312 313
elseif(APPLE_IOS)
  # Add some custom overrides
Ken Martin's avatar
Ken Martin committed
314 315 316 317 318 319 320 321 322 323 324 325 326
  list(APPEND vtk_module_overrides "vtkRenderWindowInteractor")
  set(vtk_module_vtkRenderWindowInteractor_override "vtkIOSRenderWindowInteractor")
  list(APPEND vtk_module_overrides "vtkRenderWindow")
  set(vtk_module_vtkRenderWindow_override "vtkIOSRenderWindow")
  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}")
327
  endif()
328
 endif()
329

330
vtk_object_factory_configure("${vtk_module_overrides}")
331

332 333 334
# 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")
335 336 337 338
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)
339 340 341 342
configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/vtkOpenGLError.h.in
    ${CMAKE_CURRENT_BINARY_DIR}/vtkOpenGLError.h)

343 344 345 346 347
# 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\"")
348

349
vtk_module_library(${vtk-module} ${Module_SRCS})
350
vtk_opengl_link(${vtk-module})
351
if(VTK_USE_X)
352
  vtk_module_link_libraries(${vtk-module}
353
    LINK_PUBLIC ${X11_LIBRARIES} ${X11_Xt_LIB})
Ken Martin's avatar
Ken Martin committed
354 355
elseif(VTK_USE_COCOA)
  vtk_module_link_libraries(${vtk-module} LINK_PUBLIC "-framework Cocoa")
356
endif()
357 358 359 360 361

if(ANDROID)
  target_link_libraries(${vtk-module}
    LINK_PUBLIC ${OPENGL_egl_LIBRARY})
endif()
Ken Martin's avatar
Ken Martin committed
362 363 364 365

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