cmake_minimum_required(VERSION 3.16)

project(CadMcpPlugins)

set(SOURCES
    "mcp_plugins.cpp"
    "dwg_review_common.cpp"
    "dwg_review_overview.cpp"
    "dwg_review_query.cpp"
    "dwg_review_frame.cpp"
    "dwg_review_check.cpp"
    "dwg_review_view.cpp"
    "dwg_review_ui.cpp"
    "find_collisions.cpp"
    "dwg_annotate_common.cpp"
    "dwg_annotate_draw.cpp"
    "dwg_annotate_edit.cpp"
    "StdAfx.cpp"
)

add_library(CadMcpPlugins SHARED ${SOURCES})

target_precompile_headers(CadMcpPlugins PRIVATE StdAfx.h)

# 插件是普通 DLL（由 cad_mcp_frame 在运行时 LoadLibrary），不是 .arx
target_set_name_and_suffix(CadMcpPlugins "cad_mcp_plugins" ".dll")

target_link_objectarx(CadMcpPlugins CADMCPPLUGINS_EXPORT)

target_compile_definitions(CadMcpPlugins PRIVATE
    AECRXBASE_EXPORT
    EARTHWORM_EXPORT
)

# 与 cad_mcp_frame 相同：原工程由 CadProject 的 cmake 注入 SUB_ARX（中望没有子版本）
if (IS_ZWCAD)
    target_compile_definitions(CadMcpPlugins PRIVATE SUB_ARX=0)
else()
    target_compile_definitions(CadMcpPlugins PRIVATE SUB_ARX=${CAD_SDK_SUBVERSION})
endif()

# nlohmann/json 通过 DEP_INC_ROOT 可见；插件不需要链接 AecRxBase
set_debug_post_build(CadMcpPlugins "cad_mcp_plugins" ".dll")
