# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# MSIR Codegen only. This can be enabled independently of USE_<FRAMEWORK>_RUNTIME to enable
# compilation of MSIR modules without requiring FRAMEWORK to be installed. The compiled modules
# will only be able to be executed using a TVM built with USE_<FRAMEWORK>_RUNTIME=ON. wher <FRAMEWORK> can be TORCH,TENSORFLOW,MXNET,PADDLE

include (FindPackageHandleStandardArgs)

message(STATUS "Build with MSIR modules")

tvm_file_glob(GLOB COMPILER_MSIR_SRCS src/msir/*.cc src/msir/backend/*.cc)
list(APPEND COMPILER_SRCS ${COMPILER_MSIR_SRCS})

if(USE_TORCH_CODEGEN)
    message(STATUS "Build with MSIR-Torch codegen")
    tvm_file_glob(GLOB COMPILER_TORCH_SRCS src/msir/backend/torch/*.cc)
    set_source_files_properties(${COMPILER_TORCH_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
    list(APPEND COMPILER_SRCS ${COMPILER_TORCH_SRCS})
    tvm_file_glob(GLOB RUNTIME_TORCH_SRCS src/msir/runtime/torch/*.cc)
    list(APPEND COMPILER_SRCS ${RUNTIME_TORCH_SRCS})
endif()