set(headers
  # Node types:
  sketch/Cusp.h
  sketch/Group.h
  sketch/Node.h
  sketch/Style.h
  # Resource traits:
  sketch/Traits.h
  # Renderable geometry registration:
  sketch/RegisterVTKBackend.h
)

set(classes
  sketch/Geometry
  sketch/Path
  sketch/Registrar
  sketch/Resource
  sketch/Shape
  sketch/json/jsonResource
  sketch/queries/SelectionFootprint
)

set(operators
  Create
  CreateGroup
  CreatePath
  Read
  SetName
  Write
)

set(exercises
  Exercise3_1.cxx
)

## This converts each operation's parameters (XML SBT file) into
## a header file that is used by the operation to advertise itself.
foreach(operator ${operators})
  smtk_encode_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/sketch/operators/${operator}.sbt"
    HEADER_OUTPUT headerName
  )
  list(APPEND classes sketch/operators/${operator})
  list(APPEND _step3Dependencies ${headerName})
endforeach()
add_custom_target(step3GenHeaders DEPENDS ${_step3Dependencies})

foreach(class ${classes})
  list(APPEND headers ${class}.h)
  list(APPEND sources ${class}.cxx)
endforeach()

add_library(sketchStep3
  ${sources} ${headers}
)
smtk_export_header(sketchStep3 sketch/Exports.h)
target_link_libraries(sketchStep3
  PUBLIC
    smtkCore
    vtkSMTKGeometryExt
    VTK::CommonDataModel
)
target_include_directories(sketchStep3
  PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
)
# Ensure that changes to operation SBT files cause the library to rebuild:
add_dependencies(sketchStep3 step3GenHeaders)

# Tell ParaView's build system to build our plugin.
paraview_plugin_scan(
  PLUGIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/sketch/plugin/paraview.plugin"
  PROVIDES_PLUGINS paraview_plugins
  ENABLE_BY_DEFAULT ON
  HIDE_PLUGINS_FROM_CACHE ON
)
paraview_plugin_build(
  HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${PROJECT_VERSION}"
  LIBRARY_SUBDIRECTORY "smtk-${smtk_VERSION}"  # put the plugin .xml with smtk plugins.
  PLUGINS ${paraview_plugins}
  PLUGINS_FILE_NAME "smtk.sketchstep3.xml"
  AUTOLOAD ${paraview_plugins}
  INSTALL_EXPORT SketchStep3Plugins
  CMAKE_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
  ADD_INSTALL_RPATHS ON
  TARGET sketchStep3_paraview_plugins
)

exercises(
  LABEL "Step3"
  SOURCES ${exercises}
  LIBRARIES sketchStep3 smtkCore
)
