##============================================================================
##  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.
##============================================================================

vtkm_option(VTKm_ENABLE_GL_INTEROP "Build OpenGL interop library" ON)
if(!VTKm_ENABLE_GL_INTEROP)
  return()
endif()

vtkm_find_gl(OPTIONAL GL GLEW GLUT)
if(NOT TARGET OpenGL::GL)
  message(WARNING
    "VTKm_ENABLE_GL_INTEROP is ON but could not find OpenGL library. Not building vtkm_interop.")
  return()
endif()
if(NOT TARGET GLEW::GLEW)
  message(WARNING
    "VTKm_ENABLE_GL_INTEROP is ON but could not find GL Extention Wrangler (GLEW) library. Not building vtkm_interop.")
  return()
endif()

set(headers
  BufferState.h
  TransferToOpenGL.h
  )

set(srcs
  TransferToOpenGL.cxx
  )

#-----------------------------------------------------------------------------
vtkm_declare_headers(${headers})

vtkm_library(
  NAME vtkm_interop
  HEADERS ${headers}
  WRAP_FOR_CUDA ${srcs}
  )
target_link_libraries(vtkm_interop
  PUBLIC vtkm_cont OpenGL::GL GLEW::GLEW
  )

#-----------------------------------------------------------------------------
add_subdirectory(internal)
add_subdirectory(cuda)

add_subdirectory(testing)
