# Unlike mlir_float16_utils, mlir_c_runner_utils, etc, we do *not* make
# this a shared library: because doing so causes issues when building
# on Windows.  In particular, various functions take/return `std::vector`
# but that class is not designed with dllimport/dllexport pragma,
# therefore it cannot be safely/correctly used across DLL boundaries.
# Consequently, we avoid using the "mlir_xxx_utils" naming scheme, since
# that is reserved/intended for shared libraries only.
add_library(akg_ascend_launch_runtime
  SHARED
  CceWrapper.cpp
  AKGAscendLaunchRuntime.cpp
  AscendMemoryManager.cpp
  logger.cpp
  RuntimeErrorCodes.cpp
)
set_property(TARGET akg_ascend_launch_runtime PROPERTY CXX_STANDARD 17)
target_link_libraries(akg_ascend_launch_runtime glog dl nlohmann_json::nlohmann_json)

check_cxx_compiler_flag(-Wweak-vtables
  COMPILER_SUPPORTS_WARNING_WEAK_VTABLES)
if(COMPILER_SUPPORTS_WARNING_WEAK_VTABLES)
  target_compile_options(akg_ascend_launch_runtime PUBLIC "-Wweak-vtables")
endif()
target_compile_definitions(akg_ascend_launch_runtime PRIVATE akg_ascend_launch_runtime_EXPORTS)

find_package(pybind11 REQUIRED)
pybind11_add_module(akgAscendLaunch AKGAscendLaunch.cpp)
target_link_libraries(akgAscendLaunch PRIVATE akg_ascend_launch_runtime)
set_target_properties(akgAscendLaunch PROPERTIES BUILD_RPATH $ORIGIN)
set_target_properties(akgAscendLaunch PROPERTIES INSTALL_RPATH $ORIGIN)
pybind11_add_module(akgProfileMgr ProfileMgr.cpp)
target_link_libraries(akgProfileMgr PRIVATE akg_ascend_launch_runtime)
set_target_properties(akgProfileMgr PROPERTIES BUILD_RPATH $ORIGIN)
set_target_properties(akgProfileMgr PROPERTIES INSTALL_RPATH $ORIGIN)