Commit 3ded5548 authored by Robert Maynard's avatar Robert Maynard

Extend the CMake rewrite to include vtkm_rendering

parent 56c73622
This diff is collapsed.
......@@ -23,6 +23,8 @@
#
# vtkm Target that should be used to link to VTK-m
#
# vtkm_rendering Target that contains all the rendering code
#
# vtkm::tbb Target that contains tbb related link information
# implicitly linked to by `vtkm` if tbb is enabled
#
......@@ -58,6 +60,8 @@ endif()
set(VTKm_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
set(VTKm_ENABLE_CUDA "@VTKm_ENABLE_CUDA@")
set(VTKm_ENABLE_TBB "@VTKm_ENABLE_TBB@")
set(VTKm_ENABLE_RENDERING "@VTKm_ENABLE_RENDERING@")
set(VTKm_RENDERING_BACKEND "@VTKm_RENDERING_BACKEND@")
# Load the library exports, but only if not compiling VTK-m itself
set_and_check(VTKm_CONFIG_DIR "@PACKAGE_VTKm_INSTALL_CONFIG_DIR@")
......@@ -73,4 +77,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
# This includes a host of functions used by VTK-m CMake.
include(VTKmWrappers)
if(VTKm_ENABLE_RENDERING)
include(VTKmRenderingBackends)
endif()
check_required_components(vtkm)
##============================================================================
## Copyright (c) Kitware, Inc.
## All rights reserved.
## See LICENSE.txt for details.
## This software is distributed WITHOUT ANY WARRANTY; without even
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##
## Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
## Copyright 2014 UT-Battelle, LLC.
## Copyright 2014 Los Alamos National Security.
##
## Under the terms of Contract DE-NA0003525 with NTESS,
## the U.S. Government retains certain rights in this software.
##
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
## Laboratory (LANL), the U.S. Government retains certain rights in
## this software.
##============================================================================
#-----------------------------------------------------------------------------
# find OpenGL and supporting libraries provided to make using VTK-m easier
# for consumers.
#
# vtkm_find_gl(
# REQUIRED [GL|GLUT|GLEW]
# OPTIONAL [GL|GLUT|GLEW]
# QUIET [ON/OFF]
# )
#
# Imports everything as imported modules with the following names:
# - GLUT::GLUT
# - GLEW::GLEW
# - OpenGL::GL
# For OpenGL Will also provide the more explicit targets of:
# - OpenGL::OpenGL
# - OpenGL::GLX
# - OpenGL::EGL
function(vtkm_find_gl)
set(oneValueArgs QUIET)
set(multiValueArgs REQUIRED OPTIONAL)
cmake_parse_arguments(find_gl
"${options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN}
)
set(QUIETLY )
if(find_gl_QUIET)
set(QUIETLY "QUIET")
endif()
foreach(item ${find_gl_REQUIRED})
set(${item}_REQUIRED "REQUIRED")
set(DO_${item}_FIND TRUE)
endforeach()
foreach(item ${find_gl_OPTIONAL})
set(DO_${item}_FIND TRUE)
endforeach()
#Find GL
if(CMAKE_VERSION VERSION_LESS 3.10)
if(DO_GL_FIND AND NOT TARGET OpenGL::GL)
find_package(OpenGL ${GL_REQUIRED} ${QUIETLY} MODULE)
endif()
else()
#clunky but we need to make sure we use the upstream module if it exists
set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "")
if(DO_GL_FIND AND NOT TARGET OpenGL::GL)
find_package(OpenGL ${GL_REQUIRED} ${QUIETLY} MODULE)
endif()
set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH})
endif()
#Find GLEW
if(DO_GLEW_FIND AND NOT TARGET GLEW::GLEW)
find_package(GLEW ${GLEW_REQUIRED} ${QUIETLY})
endif()
if(DO_GLUT_FIND AND NOT TARGET GLUT::GLUT)
find_package(GLUT ${GLUT_REQUIRED} ${QUIETLY})
endif()
endfunction()
#-----------------------------------------------------------------------------
if(TARGET vtkm_rendering_backend)
return()
endif()
add_library(vtkm_rendering_backend INTERFACE)
if(NOT VTKm_RENDERING_BACKEND STREQUAL "None")
vtkm_find_gl(REQUIRED GL GLEW
OPTIONAL
QUIET)
endif()
#-----------------------------------------------------------------------------
if(VTKm_RENDERING_BACKEND STREQUAL "OpenGL")
if(TARGET OpenGL::GLX)
target_link_libraries(vtkm_rendering_backend
INTERFACE OpenGL::OpenGL OpenGL::GLX GLEW::GLEW)
elseif(TARGET OpenGL::GL)
target_link_libraries(vtkm_rendering_backend
INTERFACE OpenGL::GL GLEW::GLEW)
endif()
elseif(VTKm_RENDERING_BACKEND STREQUAL "OSMesa")
target_link_libraries(vtkm_rendering_backend
INTERFACE OpenGL::GL GLEW::GLEW)
elseif(VTKm_RENDERING_BACKEND STREQUAL "EGL")
target_link_libraries(vtkm_rendering_backend
INTERFACE OpenGL::OpenGL OpenGL::EGL GLEW::GLEW)
endif()
......@@ -117,8 +117,6 @@ function(vtkm_install_template_sources)
vtkm_install_headers("${dir_prefix}" ${hfiles})
endfunction(vtkm_install_template_sources)
#-----------------------------------------------------------------------------
# Add a VTK-m library. The name of the library will match the "kit" name
# (e.g. vtkm_rendering) unless the NAME argument is given.
......@@ -231,7 +229,7 @@ function(vtkm_unit_tests)
RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH}
)
target_link_libraries(${test_prog} PRIVATE vtkm)
target_link_libraries(${test_prog} PRIVATE vtkm ${VTKm_UT_LIBRARIES})
if(NOT VTKm_UT_NO_TESTS)
return()
......
......@@ -75,7 +75,6 @@ option(VTKm_ENABLE_TBB "Enable TBB support" OFF)
option(VTKm_ENABLE_RENDERING "Enable rendering library" ON)
option(VTKm_ENABLE_TESTING "Enable VTKm Testing" ON)
option(VTKm_ENABLE_BENCHMARKS "Enable VTKm Benchmarking" OFF)
option(VTKm_ENABLE_OSMESA "Enable creating the OSMesa canvas" OFF)
option(VTKm_ENABLE_DOCUMENTATION "Build Doxygen documentation" OFF)
option(VTKm_ENABLE_EXAMPLES "Build examples" OFF)
......@@ -222,6 +221,7 @@ install(FILES ${VTKm_SOURCE_DIR}/LICENSE.txt
install(
FILES
${VTKm_SOURCE_DIR}/CMake/FindTBB.cmake
${VTKm_SOURCE_DIR}/CMake/FindOpenGL.cmake
DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
)
......@@ -230,6 +230,7 @@ install(
FILES
${VTKm_SOURCE_DIR}/CMake/VTKmWrappers.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmBackends.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmRenderingBackends.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmExportHeaderTemplate.h.in
DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
)
......
......@@ -23,20 +23,17 @@
#path so that our examples can find VTK-m
set(CMAKE_PREFIX_PATH ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR})
# add_subdirectory(clipping)
add_subdirectory(clipping)
# add_subdirectory(contour_tree)
# add_subdirectory(cosmotools)
# add_subdirectory(demo)
add_subdirectory(demo)
# add_subdirectory(dynamic_dispatcher)
# add_subdirectory(game_of_life)
# add_subdirectory(hello_world)
add_subdirectory(game_of_life)
add_subdirectory(hello_world)
# add_subdirectory(isosurface)
add_subdirectory(multi_backend)
# add_subdirectory(streamline)
# add_subdirectory(tetrahedra)
# add_subdirectory(particle_advection)
# if(VTKm_ENABLE_RENDERING)
# add_subdirectory(rendering)
# endif()
add_subdirectory(rendering)
# add_subdirectory(unified_memory)
......@@ -19,45 +19,33 @@
## this software.
##
##=============================================================================
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(Clipping CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET
OPTIONAL_COMPONENTS Serial CUDA TBB
)
find_package(VTKm REQUIRED QUIET)
add_executable(Clipping_SERIAL Clipping.cxx)
target_include_directories(Clipping_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Clipping_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Clipping_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
target_compile_definitions(Clipping_SERIAL PRIVATE
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_SERIAL")
target_link_libraries(Clipping_SERIAL PRIVATE vtkm)
if(VTKm_CUDA_FOUND)
set (cudaSource "${CMAKE_CURRENT_BINARY_DIR}/Clipping.cu")
configure_file(Clipping.cxx ${cudaSource} COPYONLY)
set(old_nvcc_flags ${CUDA_NVCC_FLAGS})
set(old_cxx_flags ${CMAKE_CXX_FLAGS})
vtkm_setup_nvcc_flags( old_nvcc_flags old_cxx_flags)
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_add_executable(Clipping_CUDA ${cudaSource})
target_include_directories(Clipping_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Clipping_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Clipping_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
set(CUDA_NVCC_FLAGS ${old_nvcc_flags})
set(CMAKE_CXX_FLAGS ${old_cxx_flags})
endif()
if(VTKm_TBB_FOUND)
if(TARGET vtkm::tbb)
add_executable(Clipping_TBB Clipping.cxx)
target_include_directories(Clipping_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Clipping_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Clipping_TBB PRIVATE PRIVATE ${VTKm_COMPILE_OPTIONS})
target_compile_definitions(Clipping_TBB PRIVATE
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")
target_link_libraries(Clipping_TBB PRIVATE vtkm)
endif()
if(TARGET vtkm::cuda)
set (cudaSource "${CMAKE_CURRENT_BINARY_DIR}/Clipping.cu")
configure_file(Clipping.cxx ${cudaSource} COPYONLY)
add_executable(Clipping_CUDA ${cudaSource})
target_compile_definitions(Clipping_CUDA PRIVATE
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_CUDA")
target_link_libraries(Clipping_CUDA PRIVATE vtkm)
endif()
......@@ -19,33 +19,23 @@
## this software.
##
##=============================================================================
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(VTKmDemo CXX)
#Find the VTK-m package
find_package(VTKm QUIET REQUIRED
OPTIONAL_COMPONENTS Serial CUDA TBB OSMesa Rendering
)
find_package(VTKm REQUIRED QUIET)
if(TARGET vtkm_rendering)
if(VTKm_OSMesa_FOUND AND VTKm_Rendering_FOUND)
if(VTKm_CUDA_FOUND)
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_add_executable(Demo Demo.cu)
else()
add_executable(Demo Demo.cxx)
endif()
#need to setup the default device adapter.
target_include_directories(Demo PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Demo PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Demo PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(Demo Demo.cxx)
target_link_libraries(Demo PRIVATE vtkm_rendering)
#when we are using TBB pass in the default device adapter as
#a compile definition to make sure we build with TBB selected
if(VTKm_TBB_FOUND)
if(TARGET vtkm::cuda)
set_source_files_properties(Demo.cxx LANGUAGE "CUDA")
target_compile_definitions(Demo
PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_CUDA")
elseif(TARGET vtkm::tbb)
target_compile_definitions(Demo
PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")
endif()
endif()
......@@ -85,7 +85,7 @@ int main(int argc, char* argv[])
vtkm::rendering::Camera camera = vtkm::rendering::Camera();
//Set3DView
vtkm::Bounds coordsBounds = coords.GetBounds(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
vtkm::Bounds coordsBounds = coords.GetBounds();
camera.ResetToBounds(coordsBounds);
......
......@@ -19,22 +19,22 @@
## this software.
##
##=============================================================================
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(GameOfLife CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED
OPTIONAL_COMPONENTS Serial CUDA TBB OpenGL GLUT
)
find_package(VTKm REQUIRED QUIET)
vtkm_find_gl(OPTIONAL GL GLUT GLEW)
if(VTKm_CUDA_FOUND)
cuda_add_executable(GameOfLife GameOfLife.cu LoadShaders.h)
else()
add_executable(GameOfLife GameOfLife.cxx LoadShaders.h)
endif()
if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
if(TARGET vtkm::cuda)
set_source_files_properties(GameOfLife.cxx LANGUAGE "CUDA")
endif()
target_include_directories(GameOfLife PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(GameOfLife PRIVATE ${VTKm_LIBRARIES})
target_compile_options(GameOfLife PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(GameOfLife GameOfLife.cxx LoadShaders.h)
target_link_libraries(GameOfLife PRIVATE vtkm OpenGL::GL GLEW::GLEW GLUT::GLUT)
endif()
......@@ -17,6 +17,8 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
// Must be included before any other GL includes:
#include <GL/glew.h>
// Must be included before any other GL includes:
#include <GL/glew.h>
......
......@@ -19,35 +19,30 @@
## this software.
##
##=============================================================================
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(HelloWorld CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET
OPTIONAL_COMPONENTS Serial CUDA TBB OpenGL GLUT
)
find_package(VTKm REQUIRED QUIET)
vtkm_find_gl(OPTIONAL GL GLUT GLEW)
if(VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(HelloWorld_SERIAL HelloWorld.cxx LoadShaders.h)
set_source_files_properties(LoadShaders.h PROPERTIES HEADER_FILE_ONLY TRUE)
target_include_directories(HelloWorld_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(HelloWorld_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(HelloWorld_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
if(VTKm_CUDA_FOUND)
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
cuda_add_executable(HelloWorld_CUDA HelloWorld.cu LoadShaders.h)
target_include_directories(HelloWorld_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(HelloWorld_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(HelloWorld_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()
add_executable(HelloWorld_SERIAL HelloWorld.cxx LoadShaders.h)
target_link_libraries(HelloWorld_SERIAL
PRIVATE vtkm OpenGL::GL GLEW::GLEW GLUT::GLUT)
if(VTKm_TBB_FOUND)
if(TARGET vtkm::tbb)
add_executable(HelloWorld_TBB HelloWorldTBB.cxx LoadShaders.h)
target_include_directories(HelloWorld_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(HelloWorld_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(HelloWorld_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
target_link_libraries(HelloWorld_TBB
PRIVATE vtkm OpenGL::GL GLEW::GLEW GLUT::GLUT)
endif()
if(TARGET vtkm::cuda)
add_executable(HelloWorld_CUDA HelloWorld.cu LoadShaders.h)
target_link_libraries(HelloWorld_CUDA
PRIVATE vtkm OpenGL::GL GLEW::GLEW GLUT::GLUT)
endif()
endif()
......@@ -19,6 +19,8 @@
## this software.
##
##=============================================================================
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(MultiBackend CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
......
......@@ -19,15 +19,27 @@
## this software.
##
##=============================================================================
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(Rendering CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET
OPTIONAL_COMPONENTS Serial OpenGL Rendering GLUT
)
find_package(VTKm REQUIRED QUIET)
if(VTKm_OpenGL_FOUND AND VTKm_Rendering_FOUND AND VTKm_GLUT_FOUND)
add_executable(Rendering_SERIAL Rendering.cxx)
target_include_directories(Rendering_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Rendering_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Rendering_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
if(NOT TARGET vtkm_rendering OR NOT VTKm_RENDERING_BACKEND STREQUAL "OpenGL")
return()
endif()
vtkm_find_gl(OPTIONAL GLUT)
if(NOT TARGET GLUT::GLUT)
return()
endif()
add_executable(Rendering_SERIAL Rendering.cxx)
target_link_libraries(Rendering_SERIAL PRIVATE vtkm_rendering GLUT::GLUT)
if(TARGET vtkm::tbb)
add_executable(Rendering_TBB Rendering.cxx)
target_compile_definitions(Rendering_TBB PRIVATE
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")
target_link_libraries(Rendering_TBB PRIVATE vtkm_rendering GLUT::GLUT)
endif()
......@@ -82,11 +82,9 @@ add_subdirectory(filter)
#-----------------------------------------------------------------------------
# Build rendering
# if(VTKm_ENABLE_RENDERING)
# add_subdirectory(rendering)
# endif()
add_subdirectory(rendering)
# add_subdirectory(interop)
add_subdirectory(interop)
#-----------------------------------------------------------------------------
#add the benchmarking folder
......
......@@ -23,9 +23,11 @@ set(headers
TransferToOpenGL.h
)
if(VTKm_ENABLE_TESTING)
# Determine if we actually want to compile OpenGL Interop tests.
vtkm_configure_component_OpenGL()
#-----------------------------------------------------------------------------
vtkm_declare_headers(${headers} TESTABLE FALSE)
if(VTKm_ENABLE_TESTING AND TARGET vtkm_rendering)
add_subdirectory(testing)
endif()
#-----------------------------------------------------------------------------
......@@ -34,11 +36,3 @@ add_subdirectory(internal)
if(VTKm_CUDA_FOUND)
add_subdirectory(cuda)
endif()
#-----------------------------------------------------------------------------
vtkm_declare_headers(${headers} TESTABLE FALSE)
#-----------------------------------------------------------------------------
if(VTKm_OpenGL_FOUND)
add_subdirectory(testing)
endif()
......@@ -28,6 +28,6 @@ set(headers
vtkm_declare_headers(${headers} TESTABLE FALSE)
#-----------------------------------------------------------------------------
if(VTKm_OpenGL_FOUND)
if(TARGET vtkm_rendering)
add_subdirectory(testing)
endif()
......@@ -18,9 +18,13 @@
## this software.
##============================================================================
if(NOT TARGET GLEW::GLEW)
return()
endif()
set(unit_tests
UnitTestBufferTypePicker.cxx
UnitTestOpenGLHeaders.cxx
UnitTestOpenGLHeaders.cxx
UnitTestBufferTypePicker.cxx
)
vtkm_unit_tests(SOURCES ${unit_tests})
vtkm_unit_tests(SOURCES ${unit_tests} LIBRARIES GLEW::GLEW)
......@@ -22,40 +22,35 @@ set(headers
TestingOpenGLInterop.h
TestingTransferFancyHandles.h
)
vtkm_declare_headers(${headers} TESTABLE FALSE)
if(NOT TARGET GLUT::GLUT)
find_package(GLUT QUIET)
set(unit_tests)
if(NOT TARGET GLUT::GLUT)
return()
endif()
endif()
# So because we are using GLEW to do our
# GL binding we can only expect one
# of these transfer tests to work
#
#
set(needs_rendering FALSE)
if(VTKm_OSMesa_FOUND AND TARGET vtkm_rendering)
# rendering can only have a single backend so we need to
if(VTKm_RENDERING_BACKEND STREQUAL "OSMesa" AND TARGET vtkm_rendering)
list(APPEND unit_tests
UnitTestTransferOSMesa.cxx
UnitTestFancyTransferOSMesa.cxx
)
set(needs_rendering TRUE)
elseif(VTKm_EGL_FOUND AND TARGET vtkm_rendering)
elseif(VTKm_RENDERING_BACKEND STREQUAL "EGL" AND TARGET vtkm_rendering)
list(APPEND unit_tests
UnitTestTransferEGL.cxx
UnitTestFancyTransferEGL.cxx
)
set(needs_rendering TRUE)
else()
vtkm_configure_component_GLUT()
if(VTKm_GLUT_FOUND)
list(APPEND unit_tests
UnitTestTransferGLUT.cxx
UnitTestFancyTransferGLUT.cxx
)
endif()
elseif(VTKm_RENDERING_BACKEND STREQUAL "OpenGL" AND TARGET vtkm_rendering)
list(APPEND unit_tests
UnitTestTransferGLUT.cxx
UnitTestFancyTransferGLUT.cxx
)
endif()
vtkm_declare_headers(${headers} TESTABLE FALSE)
vtkm_unit_tests(SOURCES ${unit_tests})
if(needs_rendering)
target_link_libraries(UnitTests_vtkm_interop_testing PRIVATE vtkm_rendering)
if(unit_tests)
vtkm_unit_tests(SOURCES ${unit_tests} LIBRARIES vtkm_rendering GLUT::GLUT)
endif()
......@@ -18,6 +18,24 @@
## this software.
##============================================================================
if(NOT VTKm_ENABLE_RENDERING)
return()
endif()
# determine what backend for rendering we want to build
set(default_backend "OpenGL")
if(NOT VTKm_RENDERING_BACKEND)
message(STATUS "Setting rendering backend to '${default_backend}' as none was specified.")
set(VTKm_RENDERING_BACKEND "${default_backend}" CACHE
STRING "Choose the backend for vtkm rendering." FORCE)
# Set the possible values of rendering backend types for cmake-gui
set(extra_backends )
if(UNIX AND NOT APPLE)
list(APPEND extra_backends "OSMesa" "EGL")
endif()
set_property(CACHE VTKm_RENDERING_BACKEND PROPERTY STRINGS "None" "OpenGL" ${extra_backends})
endif()
set(headers
Actor.h
AxisAnnotation.h
......@@ -100,6 +118,8 @@ set(sources
raytracing/VolumeRendererStructured.cxx
)
# Note that EGL and OSMesa Canvas depend on the GL version being built. Only
# the None backend supports not building the opengl version
set(opengl_headers
CanvasGL.h
MapperGL.h
......@@ -148,64 +168,39 @@ set(device_sources
)
#-----------------------------------------------------------------------------
vtkm_configure_component_OpenGL()
if(VTKm_OpenGL_FOUND)
list(APPEND headers ${opengl_headers})
list(APPEND sources ${opengl_sources})
vtkm_configure_component_OSMesa()
if(VTKm_OSMesa_FOUND)
list(APPEND headers ${osmesa_headers})
list(APPEND sources ${osmesa_sources})
endif()
# vtkm_configure_component_EGL()
# if(VTKm_EGL_FOUND)
# list(APPEND headers ${egl_headers})
# list(APPEND sources ${egl_sources})
# endif()
endif()
if(VTKm_ENABLE_OSMESA AND NOT VTKm_OSMesa_FOUND)
message(SEND_ERROR "OSMesa was requested by not properly configured.
Either make sure the OSMesa headers and library are properly found or set
VTKm_ENABLE_OSMESA to OFF.")
endif()
vtkm_declare_headers(${headers})
vtkm_library(
NAME vtkm_rendering
SOURCES ${sources}
HEADERS ${headers}
WRAP_FOR_CUDA ${device_sources}
)
# EGL Libs are added here to ensure propper linking when statically compiling.
# This is safe to do even when not using EGL as the values will then be empty.
target_link_libraries(vtkm_rendering
PUBLIC vtkm_cont
PRIVATE ${VTKm_OPENGL_LIBRARIES}
${VTKm_BACKEND_LIBRARIES}
${EGL_LIBRARIES}
)
# EGL Dirs are added here to ensure propper linking when statically compiling.
# This is safe to do even when not using EGL as the values will then be empty.
target_include_directories(vtkm_rendering
PRIVATE ${VTKm_OPENGL_INCLUDE_DIRS}
${VTKm_BACKEND_INCLUDE_DIRS}
${EGL_INCLUDE_DIRS}
)
if(VTKm_RENDERING_BACKEND STREQUAL "OpenGL")
vtkm_declare_headers(${opengl_headers})
target_sources(vtkm_rendering PRIVATE ${opengl_sources})
elseif(VTKm_RENDERING_BACKEND STREQUAL "OSMesa")
vtkm_declare_headers(${opengl_headers} ${osmesa_headers})
target_sources(vtkm_rendering PRIVATE ${opengl_sources} ${osmesa_sources})
elseif(VTKm_RENDERING_BACKEND STREQUAL "EGL")
vtkm_declare_headers(${opengl_headers} ${egl_headers})
target_sources(vtkm_rendering PRIVATE ${opengl_sources} ${egl_sources})
endif()
#-----------------------------------------------------------------------------
target_link_libraries(vtkm_rendering PUBLIC vtkm)
if(UNIX AND NOT APPLE)
target_link_libraries(vtkm_rendering PRIVATE rt )
endif()
#-----------------------------------------------------------------------------
include(VTKmRenderingBackends)
target_link_libraries(vtkm_rendering PUBLIC vtkm_rendering_backend)
install(TARGETS vtkm_rendering_backend
EXPORT ${VTKm_EXPORT_NAME}
)
# Subclasses need rendering library
vtkm_configure_component_Rendering()
#-----------------------------------------------------------------------------
add_subdirectory(internal)
add_subdirectory(raytracing)
#-----------------------------------------------------------------------------
add_subdirectory(testing)
......@@ -19,15 +19,11 @@
##============================================================================
set(headers
RunTriangulator.h
)
set(opengl_headers
OpenGLHeaders.h
RunTriangulator.h
)
if(VTKm_OpenGL_FOUND)
list(APPEND headers ${opengl_headers})
endif()
set_source_files_properties(OpenGLHeaders.h
PROPERTIES VTKm_CANT_BE_HEADER_TESTED TRUE)