Commit 37a2359c authored by Robert Maynard's avatar Robert Maynard

Refactor the rendering context flags to not be a combo box.

This way in the future it is easier to make currently mutually exclusive
compile options be all enabled at the same time.
parent af0a7810
......@@ -61,7 +61,9 @@ 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@")
set(VTKm_ENABLE_GL_CONTEXT "@VTKm_ENABLE_GL_CONTEXT")
set(VTKm_ENABLE_OSMESA_CONTEXT "@VTKm_ENABLE_OSMESA_CONTEXT")
set(VTKm_ENABLE_EGL_CONTEXT "@VTKm_ENABLE_EGL_CONTEXT")
set(VTKm_ENABLE_MPI "@VTKm_ENABLE_MPI@")
# Load the library exports, but only if not compiling VTK-m itself
......@@ -79,7 +81,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
include(VTKmWrappers)
if(VTKm_ENABLE_RENDERING)
include(VTKmRenderingBackends)
include(VTKmRenderingContexts)
endif()
check_required_components(vtkm)
......@@ -85,11 +85,11 @@ function(vtkm_find_gl)
endfunction()
#-----------------------------------------------------------------------------
if(TARGET vtkm_rendering_backend)
if(TARGET vtkm_rendering_gl_context)
return()
endif()
add_library(vtkm_rendering_backend INTERFACE)
add_library(vtkm_rendering_gl_context INTERFACE)
if(NOT VTKm_RENDERING_BACKEND STREQUAL "None")
vtkm_find_gl(REQUIRED GL GLEW
OPTIONAL
......@@ -97,18 +97,18 @@ if(NOT VTKm_RENDERING_BACKEND STREQUAL "None")
endif()
#-----------------------------------------------------------------------------
if(VTKm_RENDERING_BACKEND STREQUAL "OpenGL")
if(VTKm_ENABLE_GL_CONTEXT)
if(TARGET OpenGL::GLX)
target_link_libraries(vtkm_rendering_backend
target_link_libraries(vtkm_rendering_gl_context
INTERFACE OpenGL::OpenGL OpenGL::GLX GLEW::GLEW)
elseif(TARGET OpenGL::GL)
target_link_libraries(vtkm_rendering_backend
target_link_libraries(vtkm_rendering_gl_context
INTERFACE OpenGL::GL GLEW::GLEW)
endif()
elseif(VTKm_RENDERING_BACKEND STREQUAL "OSMesa")
target_link_libraries(vtkm_rendering_backend
elseif(VTKm_ENABLE_OSMESA_CONTEXT)
target_link_libraries(vtkm_rendering_gl_context
INTERFACE OpenGL::GL GLEW::GLEW)
elseif(VTKm_RENDERING_BACKEND STREQUAL "EGL")
target_link_libraries(vtkm_rendering_backend
elseif(VTKm_ENABLE_EGL_CONTEXT)
target_link_libraries(vtkm_rendering_gl_context
INTERFACE OpenGL::OpenGL OpenGL::EGL GLEW::GLEW)
endif()
......@@ -105,13 +105,9 @@ extract_version_components("${version_txt}" "VTKm")
# Get the version from git if we can
determine_version(${VTKm_SOURCE_DIR} ${GIT_EXECUTABLE} "VTKm")
# Create an "interface" target library. This is not a real library but rather
# holds CMake configuration that is required for CXX targets that use VTK-m
# headers. In particular, it makes sure the appropriate C++11 version is being
# used. (The cxx_constexpr and cxx_auto_type features happen to force C++11.
# Directly asking for C++11 with this interface is not supported in CMake 3.3.)
# This is also exported so that dependent CMake projects can load the same
# configuration.
# Create vtkm_compiler_flags library. This is an interface library that
# holds all the C++ compiler flags that are needed for consumers and
# when building VTK-m.
include(VTKmCompilerFlags)
include(VTKmWrappers)
include(VTKmCPUVectorization)
......@@ -245,7 +241,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/VTKmRenderingContexts.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmExportHeaderTemplate.h.in
DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
)
......
......@@ -25,7 +25,7 @@ project(Rendering CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
if(NOT TARGET vtkm_rendering OR NOT VTKm_RENDERING_BACKEND STREQUAL "OpenGL")
if(NOT TARGET vtkm_rendering OR NOT VTKm_ENABLE_GL_CONTEXT)
return()
endif()
......
......@@ -34,17 +34,17 @@ if(NOT TARGET GLUT::GLUT)
endif()
# rendering can only have a single backend so we need to
if(VTKm_RENDERING_BACKEND STREQUAL "OSMesa" AND TARGET vtkm_rendering)
if(VTKm_ENABLE_OSMESA_CONTEXT AND TARGET vtkm_rendering)
list(APPEND unit_tests
UnitTestTransferOSMesa.cxx
UnitTestFancyTransferOSMesa.cxx
)
elseif(VTKm_RENDERING_BACKEND STREQUAL "EGL" AND TARGET vtkm_rendering)
elseif(VTKm_ENABLE_EGL_CONTEXT AND TARGET vtkm_rendering)
list(APPEND unit_tests
UnitTestTransferEGL.cxx
UnitTestFancyTransferEGL.cxx
)
elseif(VTKm_RENDERING_BACKEND STREQUAL "OpenGL" AND TARGET vtkm_rendering)
elseif(VTKm_ENABLE_GL_CONTEXT AND TARGET vtkm_rendering)
list(APPEND unit_tests
UnitTestTransferGLUT.cxx
UnitTestFancyTransferGLUT.cxx
......
......@@ -21,19 +21,23 @@
if(NOT VTKm_ENABLE_RENDERING)
return()
endif()
# determine what backend for rendering we want to build
set(default_backend "None")
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})
# determine what context(s) for rendering we want to build
option(VTKm_ENABLE_GL_CONTEXT "Enable GL context for vtkm rendering" OFF)
if(UNIX AND NOT APPLE)
option(VTKm_ENABLE_OSMESA_CONTEXT "Enable OSMesa context for vtkm rendering" OFF)
option(VTKm_ENABLE_EGL_CONTEXT "Enable EGL context for vtkm rendering" OFF)
mark_as_advanced(VTKm_ENABLE_OSMESA_CONTEXT)
mark_as_advanced(VTKm_ENABLE_EGL_CONTEXT)
endif()
if(VTKm_ENABLE_GL_CONTEXT AND VTKm_ENABLE_OSMESA_CONTEXT)
message(FATAL_ERROR "VTK-m GL and OSMesa contexts are mutually exclusive")
endif()
if(VTKm_ENABLE_GL_CONTEXT AND VTKm_ENABLE_EGL_CONTEXT)
message(FATAL_ERROR "VTK-m GL and EGL contexts are mutually exclusive")
endif()
if(VTKm_ENABLE_EGL_CONTEXT AND VTKm_ENABLE_OSMESA_CONTEXT)
message(FATAL_ERROR "VTK-m EGL and OSMesa contexts are mutually exclusive")
endif()
set(headers
......@@ -175,13 +179,13 @@ vtkm_library(
WRAP_FOR_CUDA ${device_sources}
)
if(VTKm_RENDERING_BACKEND STREQUAL "OpenGL")
if(VTKm_ENABLE_GL_CONTEXT)
vtkm_declare_headers(${opengl_headers})
target_sources(vtkm_rendering PRIVATE ${opengl_sources})
elseif(VTKm_RENDERING_BACKEND STREQUAL "OSMesa")
elseif(VTKm_ENABLE_OSMESA_CONTEXT)
vtkm_declare_headers(${opengl_headers} ${osmesa_headers})
target_sources(vtkm_rendering PRIVATE ${opengl_sources} ${osmesa_sources})
elseif(VTKm_RENDERING_BACKEND STREQUAL "EGL")
elseif(VTKm_ENABLE_EGL_CONTEXT)
vtkm_declare_headers(${opengl_headers} ${egl_headers})
target_sources(vtkm_rendering PRIVATE ${opengl_sources} ${egl_sources})
endif()
......@@ -194,9 +198,9 @@ if(UNIX AND NOT APPLE)
endif()
#-----------------------------------------------------------------------------
include(VTKmRenderingBackends)
target_link_libraries(vtkm_rendering PUBLIC vtkm_rendering_backend)
install(TARGETS vtkm_rendering_backend
include(VTKmRenderingContexts)
target_link_libraries(vtkm_rendering PUBLIC vtkm_rendering_gl_context)
install(TARGETS vtkm_rendering_gl_context
EXPORT ${VTKm_EXPORT_NAME}
)
......
......@@ -35,13 +35,13 @@ set(unit_tests
vtkm_unit_tests(SOURCES ${unit_tests} LIBRARIES vtkm_rendering)
if(VTKm_RENDERING_BACKEND STREQUAL "OpenGL")
if(VTKm_ENABLE_GL_CONTEXT)
# message(STATUS "rendering testing/glfw needs a FindGLFW")
# message(STATUS "rendering testing/glut needs compile corrections")
# add_subdirectory(glfw)
# add_subdirectory(glut)
elseif(VTKm_RENDERING_BACKEND STREQUAL "OSMesa")
elseif(VTKm_ENABLE_OSMESA_CONTEXT)
add_subdirectory(osmesa)
elseif(VTKm_RENDERING_BACKEND STREQUAL "EGL")
elseif(VTKm_ENABLE_EGL_CONTEXT)
add_subdirectory(egl)
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment