set(adhSrcs
  ExportBoundaryConditions.cxx
  ExportHotStartFile.cxx
  ExportVegetation.cxx
)

set(adhHeaders
  ExportBoundaryConditions.h
  ExportHotStartFile.h
  ExportVegetation.h
)

set(operatorsPyXML
  CTB
)

# For each SBT file used by a python operator, process include-directives
# and store the output inside the build-tree's python module:
set(operatorsGeneratedPython)
foreach(operatorPyXML ${operatorsPyXML})
  set(_moduleFilename "${PROJECT_BINARY_DIR}/smtksimulationadh/${operatorPyXML}_xml.py")
  list(APPEND adh_pymodulefiles "${_moduleFilename}")
  set(_operatorXML "${CMAKE_CURRENT_SOURCE_DIR}/operators/${operatorPyXML}.sbt")
  smtk_encode_file("${_operatorXML}"
    PYTHON
    TYPE "_xml"
    NAME "description"
    DESTINATION "${_moduleFilename}"
  )
  list(APPEND operatorsGeneratedPython ${_operatorXML})
endforeach()

# Note that adding operatorsGeneratedPython ensures that modifying
# the input file will update the output.
add_library(smtkADHSimulation ${adhSrcs} ${operatorsGeneratedPython})

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

set(moab_libs ${MOAB_LIBRARIES})
if(WIN32)
  set(moab_libs "MOAB")
endif()

target_link_libraries(smtkADHSimulation
  LINK_PUBLIC
    smtkCore
    smtkADHMesh
  LINK_PRIVATE
    smtkIOVTK
    Boost::boost
    Boost::filesystem
    ${moab_libs}
    pybind11::embed
)

install(
  FILES ExportBoundaryConditions.h ExportHotStartFile.h
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${PROJECT_VERSION}/smtk/simulation/adh")

install(
  TARGETS smtkADHSimulation
  EXPORT  ${PROJECT_NAME}
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

smtk_export_header(smtkADHSimulation Exports.h)


set(adhPySrcs
  adhcommon.py
  operators/CTB.py
)

set(adh_pymodulefiles)

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/smtksimulationadh)

foreach(pyfile ${adhPySrcs})
  get_filename_component(filename ${pyfile} NAME)
  configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/${pyfile}"
    "${PROJECT_BINARY_DIR}/smtksimulationadh/${filename}"
    COPYONLY
    )
  list(APPEND adh_pymodulefiles "${PROJECT_BINARY_DIR}/smtksimulationadh/${filename}")
endforeach()
install(
  FILES ${adh_pymodulefiles}
  DESTINATION "${PYTHON_MODULEDIR}/smtksimulationadh"
  )

add_subdirectory(pybind11)
