set(PIM_ENABLED 1 BOOL PARENT_SCOPE)

set(PIM_SRC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(PIM_BIN_ROOT "${CMAKE_CURRENT_BINARY_DIR}")

set(PIM_LIBRARY_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(PIM_RUNTIME_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(PIM_INCLUDE_PATH ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})

set(PIM_ONNX_MLIR_SRC_ROOT ${ONNX_MLIR_SRC_ROOT})
set(PIM_ONNX_MLIR_BIN_ROOT ${ONNX_MLIR_BIN_ROOT})

set(PIM_PUBLIC_INCLUDE_DIRS
  ${ONNX_MLIR_SRC_ROOT}/include
  ${ONNX_MLIR_SRC_ROOT}
  ${PIM_ONNX_MLIR_SRC_ROOT}
  ${PIM_SRC_ROOT}
  ${PIM_BIN_ROOT}
  ${PIM_INCLUDE_PATH}
)

set(PIM_COMPILER_INCLUDE_DIRS
  ${PIM_SRC_ROOT}
  ${PIM_BIN_ROOT}
  ${PIM_ONNX_MLIR_SRC_ROOT}
  ${PIM_ONNX_MLIR_BIN_ROOT}
)

set(PIM_ACCEL_INCLUDE_DIRS
  ${PIM_ONNX_MLIR_SRC_ROOT}
  ${PIM_ONNX_MLIR_BIN_ROOT}
)

set(PIM_GENERATED_INCLUDE_DIRS
  ${PIM_INCLUDE_PATH}
)

function(add_pim_library name)
  add_onnx_mlir_library(${name} STATIC ${ARGN})
endfunction()

add_subdirectory(Dialect)
add_subdirectory(Common)
add_subdirectory(Pass)
add_subdirectory(Compiler)
add_subdirectory(Conversion)

add_pim_library(OMPIMAccel
  PimAccelerator.cpp

  EXCLUDE_FROM_OM_LIBS

  INCLUDE_DIRS PUBLIC
  ${PIM_PUBLIC_INCLUDE_DIRS}

  LINK_LIBS PUBLIC
  onnx
  OMAccelerator
  OMPimCompilerUtils
  OMPimPasses
  OMONNXOps
  SpatialOps
  PimOps
  OMONNXToSpatial
  OMSpatialToGraphviz
  OMSpatialToPim
  OMPimCommon
  OMPimBufferization
  MLIRTensorInferTypeOpInterfaceImpl
)
