# Next two lines are used for development
set(WORKFLOW_DIRECTORY  "${CMAKE_SOURCE_DIR}/simulation-workflows")
add_compile_definitions(WORKFLOW_DIRECTORY="${WORKFLOW_DIRECTORY}")
add_subdirectory(qt)
set(ace3p_sources
  JobsManifest.cxx
  Metadata.cxx
  Registrar.cxx
  Project.cxx
  utility/AttributeUtils.cxx
)

set(ace3p_headers
  JobsManifest.h
  Metadata.h
  Registrar.h
  Project.h
  utility/AttributeUtils.h
)

set(operations
  Create
  Export
  Read
  Write
  NewAnalysis
)

# Operations which have XML descriptions in separate files
# need to have it encoded as a string in a header.
foreach (operation ${operations})
  smtk_encode_file("${CMAKE_CURRENT_SOURCE_DIR}/operations/${operation}.sbt"
  INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/simulation-workflows/internal
  HEADER_OUTPUT header_name)
  list(APPEND ace3p_sources operations/${operation}.cxx)
  list(APPEND ace3p_headers operations/${operation}.h)
  list(APPEND operation_dependencies ${header_name})
endforeach()

# Additional dependencies for Export operation
list(APPEND operation_dependencies
  "${CMAKE_SOURCE_DIR}/simulation-workflows/internal/ace3p-export.sbt"
  "${CMAKE_SOURCE_DIR}/simulation-workflows/internal/ace3p-submit.xml"
)

add_custom_target(ace3p_generated_headers DEPENDS ${operation_dependencies})

add_library(smtkACE3P ${ace3p_sources})

add_dependencies(smtkACE3P ace3p_generated_headers)

target_link_libraries(smtkACE3P
  LINK_PUBLIC
    smtkCore
    ${__dependencies}
    nlohmann_json
    ${Boost_LIBRARIES}
)

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

generate_export_header(smtkACE3P EXPORT_FILE_NAME Exports.h)

# Install the header files
smtk_get_kit_name(name dir_prefix)

smtk_export_header(smtkACE3P Exports.h)

smtk_install_library(smtkACE3P)

if (SMTK_ENABLE_PYTHON_WRAPPING)
  add_subdirectory(pybind11)
endif()

if (ENABLE_TESTING)
  add_subdirectory(testing)
endif()
