From 8e2751e1a4c4ab03f94590807a677320ad12a815 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 18 Sep 2017 15:45:18 -0400 Subject: [PATCH] Refactor VTK-m to make the interop code non-conditional. --- CMake/VTKmConfig.cmake.in | 1 - CMake/VTKmConfigureComponents.cmake | 10 ----- examples/game_of_life/CMakeLists.txt | 2 +- examples/hello_world/CMakeLists.txt | 4 +- vtkm/internal/CMakeLists.txt | 4 -- vtkm/internal/Configure.h.in | 5 --- vtkm/interop/CMakeLists.txt | 38 +++++++------------ vtkm/interop/internal/CMakeLists.txt | 7 +++- vtkm/interop/internal/OpenGLHeaders.h | 3 -- .../testing/UnitTestBufferTypePicker.cxx | 2 + .../testing/UnitTestOpenGLHeaders.cxx | 1 + vtkm/interop/testing/CMakeLists.txt | 2 +- .../testing/UnitTestFancyTransferEGL.cxx | 2 +- .../testing/UnitTestFancyTransferGLUT.cxx | 18 ++++----- .../testing/UnitTestFancyTransferOSMesa.cxx | 1 + vtkm/interop/testing/UnitTestTransferEGL.cxx | 8 ++-- vtkm/interop/testing/UnitTestTransferGLUT.cxx | 18 ++++----- .../testing/UnitTestTransferOSMesa.cxx | 8 ++-- 18 files changed, 54 insertions(+), 80 deletions(-) diff --git a/CMake/VTKmConfig.cmake.in b/CMake/VTKmConfig.cmake.in index 7841ab826..5644e0979 100755 --- a/CMake/VTKmConfig.cmake.in +++ b/CMake/VTKmConfig.cmake.in @@ -65,7 +65,6 @@ 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_OPENGL_INTEROP "@VTKm_ENABLE_OPENGL_INTEROP@") set(VTKm_ENABLE_OSMESA "@VTKm_ENABLE_OSMESA@") set(VTKm_ENABLE_RENDERING "@VTKm_ENABLE_RENDERING@") diff --git a/CMake/VTKmConfigureComponents.cmake b/CMake/VTKmConfigureComponents.cmake index 0db7b9173..fe3512e4b 100644 --- a/CMake/VTKmConfigureComponents.cmake +++ b/CMake/VTKmConfigureComponents.cmake @@ -41,7 +41,6 @@ set(VTKm_AVAILABLE_COMPONENTS EGL GLFW GLUT - Interop Rendering TBB CUDA @@ -162,7 +161,6 @@ macro(vtkm_configure_component_OpenGL) #explicitly or else in release mode we get sigsegv on launch if(UNIX) find_package(Threads ${VTKm_FIND_PACKAGE_QUIETLY}) - list(APPEND vtkm_interop_dependent_vars CMAKE_USE_PTHREADS_INIT) list(APPEND vtkm_opengl_libraries ${CMAKE_THREAD_LIBS_INIT}) endif() @@ -232,14 +230,6 @@ macro(vtkm_configure_component_GLUT) ) endmacro(vtkm_configure_component_GLUT) -macro(vtkm_configure_component_Interop) - vtkm_configure_component_OpenGL() - - vtkm_finish_configure_component(Interop - DEPENDENT_VARIABLES VTKm_OpenGL_FOUND VTKm_ENABLE_OPENGL_INTEROP - ) -endmacro(vtkm_configure_component_Interop) - macro(vtkm_configure_component_Rendering) if(VTKm_ENABLE_RENDERING) vtkm_configure_component_OpenGL() diff --git a/examples/game_of_life/CMakeLists.txt b/examples/game_of_life/CMakeLists.txt index ec810caff..19bba0957 100644 --- a/examples/game_of_life/CMakeLists.txt +++ b/examples/game_of_life/CMakeLists.txt @@ -25,7 +25,7 @@ project(GameOfLife CXX) #Find the VTK-m package find_package(VTKm REQUIRED - OPTIONAL_COMPONENTS Serial CUDA TBB OpenGL GLUT Interop + OPTIONAL_COMPONENTS Serial CUDA TBB OpenGL GLUT ) if(VTKm_CUDA_FOUND) diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index cf514b0c9..659eba9d3 100755 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -22,10 +22,10 @@ #Find the VTK-m package find_package(VTKm REQUIRED QUIET - OPTIONAL_COMPONENTS Serial CUDA TBB OpenGL GLUT Interop + OPTIONAL_COMPONENTS Serial CUDA TBB OpenGL GLUT ) -if(VTKm_Interop_FOUND AND VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND) +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) diff --git a/vtkm/internal/CMakeLists.txt b/vtkm/internal/CMakeLists.txt index 3a0e6e06c..46784b564 100755 --- a/vtkm/internal/CMakeLists.txt +++ b/vtkm/internal/CMakeLists.txt @@ -29,8 +29,6 @@ set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS}) set(VTKM_ENABLE_CUDA ${VTKm_ENABLE_CUDA}) set(VTKM_ENABLE_TBB ${VTKm_ENABLE_TBB}) -set(VTKM_ENABLE_OPENGL_INTEROP ${VTKm_ENABLE_OPENGL_INTEROP}) - vtkm_get_kit_name(kit_name kit_dir) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Configure.h.in ${VTKm_BINARY_DIR}/include/${kit_dir}/Configure.h @@ -38,8 +36,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Configure.h.in vtkm_install_headers( vtkm/internal ${VTKm_BINARY_DIR}/include/${kit_dir}/Configure.h) -unset(VTKM_ENABLE_OPENGL_INTEROP) - unset(VTKM_ENABLE_TBB) unset(VTKM_ENABLE_CUDA) diff --git a/vtkm/internal/Configure.h.in b/vtkm/internal/Configure.h.in index f796f5be0..9240509ef 100644 --- a/vtkm/internal/Configure.h.in +++ b/vtkm/internal/Configure.h.in @@ -255,11 +255,6 @@ #cmakedefine VTKM_ENABLE_TBB #endif -//Mark if we are building with interop enabled -#ifndef VTKM_ENABLE_OPENGL_INTEROP -#cmakedefine VTKM_ENABLE_OPENGL_INTEROP -#endif - #if __cplusplus >= 201103L || \ ( defined(VTKM_MSVC) && _MSC_VER >= 1800 ) || \ ( defined(VTKM_ICC) && defined(__INTEL_CXX11_MODE__) ) diff --git a/vtkm/interop/CMakeLists.txt b/vtkm/interop/CMakeLists.txt index 2ce2ed2f0..005ad6a3a 100755 --- a/vtkm/interop/CMakeLists.txt +++ b/vtkm/interop/CMakeLists.txt @@ -18,33 +18,23 @@ ## this software. ##============================================================================ -# Determine if we actually want to compile OpenGL Interop. -# We defer declaration of the option because whether we offer it depends on -# dependent components that are not loaded in the base directories. -vtkm_configure_component_OpenGL() +set(headers + BufferState.h + TransferToOpenGL.h + ) -include(CMakeDependentOption) +if(VTKm_ENABLE_TESTING) + # Determine if we actually want to compile OpenGL Interop tests. + vtkm_configure_component_OpenGL() +endif() -cmake_dependent_option( - VTKm_ENABLE_OPENGL_INTEROP "Enable OpenGL Interop" ON - "VTKm_OpenGL_FOUND" OFF) +#----------------------------------------------------------------------------- +add_subdirectory(internal) -if(VTKm_ENABLE_OPENGL_INTEROP) - vtkm_configure_component_Interop() - if(NOT VTKm_Interop_FOUND) - message(SEND_ERROR "Could not configure for OpenGL Interop. Either configure necessary subcomponents or turn off VTKm_ENABLE_OPENGL_INTEROP.") - endif() - - set(headers - BufferState.h - TransferToOpenGL.h - ) - - #----------------------------------------------------------------------------- - add_subdirectory(internal) - - #----------------------------------------------------------------------------- - vtkm_declare_headers(${headers}) +#----------------------------------------------------------------------------- +vtkm_declare_headers(${headers} TESTABLE FALSE) +#----------------------------------------------------------------------------- +if(VTKm_OpenGL_FOUND) add_subdirectory(testing) endif() diff --git a/vtkm/interop/internal/CMakeLists.txt b/vtkm/interop/internal/CMakeLists.txt index 00a20a3e6..452dee49c 100644 --- a/vtkm/interop/internal/CMakeLists.txt +++ b/vtkm/interop/internal/CMakeLists.txt @@ -25,6 +25,9 @@ set(headers ) #----------------------------------------------------------------------------- -vtkm_declare_headers(${headers}) +vtkm_declare_headers(${headers} TESTABLE FALSE) -add_subdirectory(testing) +#----------------------------------------------------------------------------- +if(VTKm_OpenGL_FOUND) + add_subdirectory(testing) +endif() diff --git a/vtkm/interop/internal/OpenGLHeaders.h b/vtkm/interop/internal/OpenGLHeaders.h index c0269cb81..8c161182b 100644 --- a/vtkm/interop/internal/OpenGLHeaders.h +++ b/vtkm/interop/internal/OpenGLHeaders.h @@ -23,12 +23,9 @@ #include #if defined(__APPLE__) -#include #include #else -#include - #include #endif diff --git a/vtkm/interop/internal/testing/UnitTestBufferTypePicker.cxx b/vtkm/interop/internal/testing/UnitTestBufferTypePicker.cxx index c46a4782d..f55893326 100644 --- a/vtkm/interop/internal/testing/UnitTestBufferTypePicker.cxx +++ b/vtkm/interop/internal/testing/UnitTestBufferTypePicker.cxx @@ -18,6 +18,8 @@ // this software. //============================================================================ #include + +#include #include namespace diff --git a/vtkm/interop/internal/testing/UnitTestOpenGLHeaders.cxx b/vtkm/interop/internal/testing/UnitTestOpenGLHeaders.cxx index 14a49733b..8c1fceb37 100644 --- a/vtkm/interop/internal/testing/UnitTestOpenGLHeaders.cxx +++ b/vtkm/interop/internal/testing/UnitTestOpenGLHeaders.cxx @@ -17,6 +17,7 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ +#include #include #include diff --git a/vtkm/interop/testing/CMakeLists.txt b/vtkm/interop/testing/CMakeLists.txt index fbd8f0e80..df44034cb 100644 --- a/vtkm/interop/testing/CMakeLists.txt +++ b/vtkm/interop/testing/CMakeLists.txt @@ -54,7 +54,7 @@ else() endif() -vtkm_declare_headers(${headers}) +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) diff --git a/vtkm/interop/testing/UnitTestFancyTransferEGL.cxx b/vtkm/interop/testing/UnitTestFancyTransferEGL.cxx index 46a7a1a07..00621fda6 100644 --- a/vtkm/interop/testing/UnitTestFancyTransferEGL.cxx +++ b/vtkm/interop/testing/UnitTestFancyTransferEGL.cxx @@ -17,7 +17,7 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ - +#include #include #include diff --git a/vtkm/interop/testing/UnitTestFancyTransferGLUT.cxx b/vtkm/interop/testing/UnitTestFancyTransferGLUT.cxx index 18382e93b..47176996b 100644 --- a/vtkm/interop/testing/UnitTestFancyTransferGLUT.cxx +++ b/vtkm/interop/testing/UnitTestFancyTransferGLUT.cxx @@ -17,6 +17,15 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ +// OpenGL Graphics includes +//glew needs to go before glut +#include +#include +#if defined(__APPLE__) +#include +#else +#include +#endif #include @@ -26,15 +35,6 @@ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif -// OpenGL Graphics includes -//glew needs to go before glut -#include -#if defined(__APPLE__) -#include -#else -#include -#endif - #if defined(VTKM_GCC) && defined(VTKM_POSIX) && !defined(__APPLE__) // // 1. Some Linux distributions default linker implicitly enables the as-needed diff --git a/vtkm/interop/testing/UnitTestFancyTransferOSMesa.cxx b/vtkm/interop/testing/UnitTestFancyTransferOSMesa.cxx index 36b3180db..88c1c85d8 100644 --- a/vtkm/interop/testing/UnitTestFancyTransferOSMesa.cxx +++ b/vtkm/interop/testing/UnitTestFancyTransferOSMesa.cxx @@ -18,6 +18,7 @@ // this software. //============================================================================ +#include #include #include diff --git a/vtkm/interop/testing/UnitTestTransferEGL.cxx b/vtkm/interop/testing/UnitTestTransferEGL.cxx index fa7400349..545ea7a48 100644 --- a/vtkm/interop/testing/UnitTestTransferEGL.cxx +++ b/vtkm/interop/testing/UnitTestTransferEGL.cxx @@ -17,13 +17,13 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ - -//This sets up testing with the default device adapter and array container - -#include +#include #include #include +//This sets up testing with the default device adapter and array container +#include + int UnitTestTransferEGL(int, char* []) { //get egl canvas to construct a context for us diff --git a/vtkm/interop/testing/UnitTestTransferGLUT.cxx b/vtkm/interop/testing/UnitTestTransferGLUT.cxx index 713bc13f1..8bd9f469a 100644 --- a/vtkm/interop/testing/UnitTestTransferGLUT.cxx +++ b/vtkm/interop/testing/UnitTestTransferGLUT.cxx @@ -17,6 +17,15 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ +// OpenGL Graphics includes +//glew needs to go before glut +#include +#include +#if defined(__APPLE__) +#include +#else +#include +#endif //This sets up testing with the default device adapter and array container #include @@ -28,15 +37,6 @@ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif -// OpenGL Graphics includes -//glew needs to go before glut -#include -#if defined(__APPLE__) -#include -#else -#include -#endif - #if defined(VTKM_GCC) && defined(VTKM_POSIX) && !defined(__APPLE__) // // 1. Some Linux distributions default linker implicitly enables the as-needed diff --git a/vtkm/interop/testing/UnitTestTransferOSMesa.cxx b/vtkm/interop/testing/UnitTestTransferOSMesa.cxx index 1f5b7838c..5ea39729c 100644 --- a/vtkm/interop/testing/UnitTestTransferOSMesa.cxx +++ b/vtkm/interop/testing/UnitTestTransferOSMesa.cxx @@ -17,13 +17,13 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ - -//This sets up testing with the default device adapter and array container - -#include +#include #include #include +//This sets up testing with the default device adapter and array container +#include + int UnitTestTransferOSMesa(int, char* []) { //get osmesa canvas to construct a context for us