################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from           #
# compiler/src/iree/compiler/API/Internal/BUILD.bazel                          #
#                                                                              #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary   #
# CMake-only content.                                                          #
#                                                                              #
# To disable autogeneration for this file entirely, delete this header.        #
################################################################################

iree_add_all_subdirs()

iree_cc_library(
  NAME
    CompilerDriver
  HDRS
    "Diagnostics.h"
  SRCS
    "CompilerDriver.cpp"
    "Diagnostics.cpp"
  DEPS
    LLVMSupport
    MLIRBuiltinToLLVMIRTranslation
    MLIRBytecodeWriter
    MLIRCAPIIR
    MLIRDebug
    MLIRIR
    MLIRParser
    MLIRSupport
    iree::compiler::ConstEval
    iree::compiler::Dialect::VM::Target::Bytecode
    iree::compiler::Dialect::VM::Target::C
    iree::compiler::Dialect::VM::Target::init_targets
    iree::compiler::Pipelines
    iree::compiler::PluginAPI
    iree::compiler::PluginAPI::PluginManager
    iree::compiler::Tools::init_llvmir_translations
    iree::compiler::Tools::init_passes_and_dialects
    iree::compiler::Tools::version
    iree::compiler::Utils
    iree::compiler::bindings::c::headers
  PUBLIC
)

iree_cc_library(
  NAME
    IREECompileToolEntryPoint
  SRCS
    "IREECompileToolEntryPoint.cpp"
  DEPS
    iree::compiler::Tools::iree_compile_lib
    iree::compiler::bindings::c::headers
  PUBLIC
)

iree_cc_library(
  NAME
    IREEMLIRLSPServerToolEntryPoint
  SRCS
    "IREEMLIRLSPServerToolEntryPoint.cpp"
  DEPS
    MLIRIR
    MLIRLspServerLib
    MLIRSupport
    iree::compiler::Tools::init_passes_and_dialects
    iree::compiler::bindings::c::headers
  PUBLIC
)

iree_cc_library(
  NAME
    IREEOptToolEntryPoint
  SRCS
    "IREEOptToolEntryPoint.cpp"
  DEPS
    LLVMSupport
    MLIRDebug
    MLIRIR
    MLIROptLib
    MLIRPass
    MLIRSupport
    iree::compiler::Dialect::HAL::Target
    iree::compiler::Dialect::VM::Target::init_targets
    iree::compiler::PluginAPI::PluginManager
    iree::compiler::Tools::init_llvmir_translations
    iree::compiler::Tools::init_passes_and_dialects
    iree::compiler::bindings::c::headers
  PUBLIC
)

iree_cc_library(
  NAME
    IREEReduceToolEntryPoint
  SRCS
    "IREEReduceToolEntryPoint.cpp"
  DEPS
    LLVMSupport
    MLIRBytecodeWriter
    MLIRIR
    MLIRParser
    MLIRPass
    MLIRSupport
    iree::compiler::Reducer::iree_reduce_lib
    iree::compiler::Tools::init_passes_and_dialects
    iree::compiler::bindings::c::headers
  PUBLIC
)

iree_cc_library(
  NAME
    IREECodegenDialectCAPI
  SRCS
    "IREECodegenDialectCAPI.cpp"
  DEPS
    IREELLVMIncludeSetup
    MLIRCAPIIR
    MLIRIR
    iree::compiler::Codegen::Dialect::Codegen::IR::IREECodegenDialect
    iree::compiler::Codegen::Utils
    iree::compiler::bindings::c::headers
  PUBLIC
)

iree_cc_library(
  NAME
    IREEGPUDialectCAPI
  SRCS
    "IREEGPUDialectCAPI.cpp"
  DEPS
    IREELLVMIncludeSetup
    MLIRCAPIIR
    MLIRIR
    iree::compiler::Codegen::Dialect::GPU::IR::IREEGPUDialect
    iree::compiler::bindings::c::headers
  PUBLIC
)

### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###

set(_lld_copts)
set(_lld_deps)

# TODO(#14086): implement linking in the installed-LLVM case.
if(IREE_BUILD_BUNDLED_LLVM)
  # Use generator expressions to conditionally include LLD targets, providing
  # a compiler definition if not available.
  macro(_add_dependent_lld_target target not_definition)
    list(APPEND _lld_deps
      $<TARGET_NAME_IF_EXISTS:${target}>
      $<IF:$<TARGET_EXISTS:${target}>,lldCommon,>
    )
    list(APPEND _lld_copts
      $<IF:$<TARGET_EXISTS:${target}>,,-D${not_definition}>)
  endmacro()
  _add_dependent_lld_target(lldCOFF IREE_COMPILER_LLD_COFF_DISABLED)
  _add_dependent_lld_target(lldELF IREE_COMPILER_LLD_ELF_DISABLED)
  _add_dependent_lld_target(lldMachO IREE_COMPILER_LLD_MACHO_DISABLED)
  _add_dependent_lld_target(lldWasm IREE_COMPILER_LLD_WASM_DISABLED)
else()
  list(APPEND _lld_copts -DIREE_COMPILER_LLD_DISABLED)
endif()

iree_cc_library(
  NAME
    LLDToolEntryPoint
  SRCS
    "LLDToolEntryPoint.cpp"
  COPTS
    ${_lld_copts}
  DEPS
    LLVMSupport
    LLVMTargetParser
    iree::compiler::bindings::c::headers
    ${_lld_deps}
  PUBLIC
)
