include(CheckSymbolExists)
check_symbol_exists(__aarch64__ "" __CHECK_AARCH64)
check_symbol_exists(__x86_64__ "" __CHECK_X86_64)
if(USE_CCE_RT)
  message("-- Build with cce runtime")
  add_definitions(-DUSE_CCE_RT=1)
  
  if(NOT __CHECK_AARCH64 AND NOT __CHECK_X86_64)
    message(FATAL_ERROR "runtime only support aarch64 and x86_64")
  endif()

  if(DEFINED ENV{ASCEND_CUSTOM_PATH})
    set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH})
  else()
    set(ASCEND_DIR /usr/local/Ascend)
  endif()

  set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64)
  set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common)
  set(ASCEND_DRIVER_SHARE_DIR ${ASCEND_DIR}/driver/lib64/share)
  set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64)

  set(TVM_RUNTIME_LINKER_LIBS libruntime.so)
  link_directories(${ASCEND_RUNTIME_DIR})
elseif(USE_KC_AIR)
  message("-- Build with kc air")
  add_definitions(-DUSE_CCE_RT=1)
  add_definitions(-DUSE_KC_AIR=1)

  if(NOT __CHECK_AARCH64 AND NOT __CHECK_X86_64)
    message(FATAL_ERROR "-- now kc air only support amd64 and x86_64")
  endif()

  set(TVM_RUNTIME_LINKER_LIBS kc_air)
  link_directories("${CMAKE_CURRENT_BINARY_DIR}")
else()
  message("-- Build without runtime support")
  add_definitions(-DUSE_CCE_RT=1)
endif()
