# -----------------------------------------------------------------------------------------------------------
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
# CANN Open Software License Agreement Version 2.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# -----------------------------------------------------------------------------------------------------------
# ----dump Proto generate ----
set(PROTO_LIST
        "${METADEF_PROTO_DIR}/op_mapping.proto"
        "${METADEF_PROTO_DIR}/dump_task.proto"
        )

generate_cann_protobuf(dump_proto PROTO_SRCS PROTO_HDRS ${PROTO_LIST} "--proto_path=${METADEF_PROTO_DIR}" TARGET)

add_library(profiler_stub SHARED src/profiler_stub.cc src/dump_stub.cc ${PROTO_SRCS})

# Use the test dump implementation when runner targets are built for LLT.
foreach(runner_target ge_runner ge_runner_v2)
    if (TARGET ${runner_target})
        get_target_property(runner_link_libraries ${runner_target} LINK_LIBRARIES)
        list(REMOVE_ITEM runner_link_libraries ascend_dump)
        list(APPEND runner_link_libraries profiler_stub)
        set_target_properties(${runner_target} PROPERTIES
            LINK_LIBRARIES "${runner_link_libraries}"
        )
    endif()
endforeach()

add_dependencies(profiler_stub
        dump_proto
        )

target_compile_definitions(profiler_stub PRIVATE
        google=ascend_private
        )

target_link_libraries(profiler_stub
    PRIVATE
        intf_llt_pub
        runtime_headers
        c_sec
        ascend_protobuf
        mmpa
    PUBLIC
        msprof_headers
        adump_headers
)
target_include_directories(profiler_stub SYSTEM PRIVATE
        ${AIR_CODE_DIR}/inc/framework
        ${METADEF_DIR}/inc/external
        )

stub_module(profapi_share profiler_stub)
stub_module(msprofiler_fwk_share profiler_stub)
stub_module(ascend_dump profiler_stub)
stub_module(adump_server profiler_stub)
stub_module(adcore profiler_stub)