set(rggSrcs
  Assembly.cxx
  Core.cxx
  Duct.cxx
  Material.cxx
  Pin.cxx
  rggPhraseModel.cxx
  Registrar.cxx
  Resource.cxx
  Session.cxx
  json/jsonAssembly.cxx
  json/jsonAssyExportParameters.cxx
  json/jsonCore.cxx
  json/jsonCoreExportParameters.cxx
  json/jsonDuct.cxx
  json/jsonPin.cxx
  meshkit/AssyExportParameters.cxx
  meshkit/CoreExportParameters.cxx
  operators/AddMaterial.cxx
  operators/CreateModel.cxx
  operators/Delete.cxx
  operators/EditAssembly.cxx
  operators/EditCore.cxx
  operators/EditDuct.cxx
  operators/EditMaterial.cxx
  operators/EditPin.cxx
  operators/ExportInp.cxx
  operators/OperationHelper.cxx
  operators/Read.cxx
  operators/ReadRXFFile.cxx
  operators/ReadRXFFileHelper.cxx
  operators/RemoveMaterial.cxx
  operators/Write.cxx
  )

set(rggHeaders
  Assembly.h
  Core.h
  Duct.h
  Material.h
  Pin.h
  rggPhraseModel.cxx
  Registrar.h
  Resource.h
  Session.h
  json/jsonAssembly.h
  json/jsonAssyExportParameters.h
  json/jsonCore.h
  json/jsonCoreExportParameters.h
  json/jsonDuct.h
  json/jsonPin.h
  meshkit/AssyExportParameters.h
  meshkit/CoreExportParameters.h
  operators/AddMaterial.h
  operators/CreateModel.h
  operators/Delete.h
  operators/EditAssembly.h
  operators/EditCore.h
  operators/EditDuct.h
  operators/EditMaterial.h
  operators/EditPin.h
  operators/ExportInp.h
  operators/OperationHelper.h
  operators/ReadRXFFile.h
  operators/ReadRXFFileHelper.h
  operators/RemoveMaterial.h
  )

add_library(smtkRGGSession SHARED ${rggSrcs})

target_link_libraries(smtkRGGSession
  PUBLIC
    smtkCore
    Boost::boost
    Boost::filesystem
  PRIVATE
    ${__dependencies}
    vtkSMTKSourceExt # vtkCmbLayeredConeSource
)

target_include_directories(smtkRGGSession PUBLIC
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
  $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${PROJECT_VERSION}>
  PRIVATE
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/thirdparty>
)

generate_export_header(smtkRGGSession EXPORT_FILE_NAME Exports.h)

# Operators which have XML descriptions in separate files
# need to have it encoded as a string in a header.
# We do not need the path to the generated header (appended
# to rggOperatorXML) since the operators themselves include
# the header in their implementations.
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/AddMaterial.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateModel.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Delete.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/EditAssembly.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/EditCore.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/EditDuct.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/EditMaterial.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/EditPin.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/ExportInp.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Read.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/ReadRXFFile.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/RemoveMaterial.sbt" rggOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Write.sbt" rggOperatorXML)

if ( ParaView_FOUND AND Qt5_FOUND AND TARGET smtkQtExt)
  add_subdirectory(qt)
endif()

if (ENABLE_PYTHON_WRAPPING)
  set(rggPySrcs
    operators/generate_mesh.py
    )

  set(rgg_pymodulefiles)
  set(rgg_pyxmlfiles)

  smtk_pyoperation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/generate_mesh.sbt" rgg_pyxmlfiles)

  set(relativedir "rggsession/session")
  foreach(pyfile ${rggPySrcs})
    get_filename_component(filename ${pyfile} NAME)
    configure_file(
      "${CMAKE_CURRENT_SOURCE_DIR}/${pyfile}"
      "${CMAKE_BINARY_DIR}/${relativedir}/${filename}" @ONLY
      )
    list(APPEND rgg_pymodulefiles "${CMAKE_BINARY_DIR}/${relativedir}/${filename}")
  endforeach()

  foreach(pyfile ${rgg_pyxmlfiles})
    get_filename_component(filename ${pyfile} NAME)
    configure_file(
      "${pyfile}"
      "${PROJECT_BINARY_DIR}/${relativedir}/${filename}" @ONLY
      )
    list(APPEND rgg_pymodulefiles "${PROJECT_BINARY_DIR}/${relativedir}/${filename}")
  endforeach()

  file(RELATIVE_PATH relativedir ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
  install(
    FILES ${rgg_pymodulefiles}
    DESTINATION "${PYTHON_MODULEDIR}/${relativedir}"
    )

  add_subdirectory(pybind11)
endif()

smtk_get_kit_name(name dir_prefix)

# Install the header files
install(
  FILES
    ${rggHeaders}
    ${CMAKE_CURRENT_BINARY_DIR}/Exports.h
  DESTINATION
    ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${PROJECT_VERSION}/${dir_prefix})

# Install the library and exports
install(
  TARGETS smtkRGGSession
  EXPORT  ${PROJECT_NAME}
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${PROJECT_VERSION}/${dir_prefix})


if (ENABLE_TESTING)
  add_subdirectory(testing)
endif()
