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/ApplicationConfiguration
  sketch/Geometry
  sketch/Path
  sketch/Registrar
  sketch/Resource
  sketch/Shape
  sketch/NodeGroupPhraseContent
  sketch/SubphraseGenerator
  sketch/json/jsonResource
  sketch/queries/SelectionFootprint
)

set(operators
  Create
  CreateGroup
  CreatePath
  Read
  SetName
  Write
)

set(exercises)

## 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 _step4SolvedDependencies ${headerName})
endforeach()
add_custom_target(step4SolvedGenHeaders DEPENDS ${_step4SolvedDependencies})

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

# These are needed for ApplicationConfiguration since it inherits QObject:
set(CMAKE_AUTOMOC 1)
set(CMAKE_AUTOUIC 1)
set(CMAKE_AUTORCC 1)

add_library(sketchStep4_solved
  ${sources} ${headers}
)
smtk_export_header(sketchStep4_solved sketch/Exports.h)
target_link_libraries(sketchStep4_solved
  PUBLIC
    smtkCore
    vtkSMTKGeometryExt
    smtkPQComponentsExt
    VTK::CommonDataModel
    Qt5::Core # Needed for ApplicationConfiguration
    Qt5::Widgets # Needed for ApplicationConfiguration
)
target_include_directories(sketchStep4_solved
  PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
)
# Ensure that changes to operation SBT files cause the library to rebuild:
add_dependencies(sketchStep4_solved step4SolvedGenHeaders)

# 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.sketchstep4_solved.xml"
  AUTOLOAD ${paraview_plugins}
  INSTALL_EXPORT SketchStep4SolvedPlugins
  CMAKE_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
  ADD_INSTALL_RPATHS ON
  TARGET sketchStep4_solved_paraview_plugins
)

# exercises(
#   LABEL "Step4"
#   SOURCES ${exercises}
#   LIBRARIES sketchStep4_solved smtkCore
# )
