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})

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

add_onnx_mlir_library(OMPIMAccel
  PimAccelerator.cpp
  Transforms/PimBufferizationPass.cpp
  Pass/CountInstructionPass.cpp
  Pass/EmitPimJsonPass.cpp
  Pass/MessagePass.cpp

  EXCLUDE_FROM_OM_LIBS

  INCLUDE_DIRS PUBLIC
  ${ONNX_MLIR_SRC_ROOT}/include
  ${ONNX_MLIR_SRC_ROOT}
  ${PIM_ONNX_MLIR_SRC_ROOT}
  ${PIM_SRC_ROOT}
  ${PIM_BIN_ROOT}
  ${PIM_INCLUDE_PATH}

  LINK_LIBS PUBLIC
  onnx
  OMAccelerator
  OMPimCompilerUtils
  OMCompilerUtils
  OMONNXOps
  SpatialOps
  PimOps
  OMONNXToSpatial
  OMSpatialToGraphviz
  OMSpatialToPIM
  OMPIMCommon
)