Files
envi-code/SourceCode/Code2026/cmakelists.txt
T
company-desktop ecb8436720 feat: 移植 cad_mcp_plugins,并对齐中望平台的符号与依赖
插件工程在 CadProject/src/cad_mcp_plugins(8 个 cpp/h),本次一并整合进 code2026。

移植改动:
- 源码拷到 SourceCode/Code2026/cad_mcp_plugins/;cadsdk.h -> KTCad.h
- 输出是普通 DLL(.dll),由 cad_mcp_frame 运行时 LoadLibrary,不注册 ARX 命令
- 新增 cad_mcp_plugins/cmakelists.txt:按 code2026 惯例
  (target_set_name_and_suffix ".dll" / target_link_objectarx / 预编译头 / SUB_ARX)
- mcp_plugin_api.h 从 cad_mcp_frame/inc 上移到 SourceCode/Code2026/inc:
  frame 与 plugins 共用,且在 ShsGlobalIncludes 的 include 路径里两边都可见;
  frame 的 CMake 去掉已删除的本地 inc 目录
- 顶层在同一个 C++11+ 条件里挂载 add_custom_module_2(cad_mcp_plugins CadMcpPlugins)
- 中望适配:源码里的 #pragma comment(lib,"rxapi.lib") 在中望下没有这个库(叫 ZwRx.lib),
  该 pragma 与导出名都按 #ifdef ZWCAD 分开(中望导出 zcrxGetApiVersion);
  frame 里 GetProcAddress 查插件版本号的函数名同样按平台分

验证:
- R230:cad_mcp_frame.arx 826 KB + cad_mcp_plugins.dll 866 KB,已自动部署
- Z2026:cad_mcp_frame.zrx 825 KB + cad_mcp_plugins.dll 864 KB,已自动部署
- 配置里 16 个 c++_dll 工具的工厂函数(CreateXxxTool)全部出现在 dll 导出表里
- 所有 .cpp/.h 为 UTF-8 with BOM

未做:没有在 CAD 里实跑。另外配置文件本身没有随构建部署(set_debug_post_build 只拷产物),
需要把 cad-mcp-frame.json(或改名 mcp_config.json)与 LISP 目录放到部署目录,
否则 frame 起来后 LoadAndRegister 失败会直接自关。详见 cad_mcp_frame-review.md。
2026-10-29 00:16:37 +08:00

182 lines
6.4 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
cmake_minimum_required(VERSION 3.21)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_SYSTEM_VERSION "${WIN11_SDK}" CACHE STRING "Specify Windows SDK version" FORCE)
project(SHS_Code2026 VERSION 1.0.0 LANGUAGES CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(functions)
IsZWCAD(IS_ZWCAD)
get_sdk_version(SDK_VERSION)
include(ThirdPartyDeps)
if(MSVC)
string(REGEX REPLACE "[/-]D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "[/-]D_DEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REGEX REPLACE "[/-]RTC[a-zA-Z0-9]+" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "[/-]RTC[a-zA-Z0-9]+" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
endif()
if (IS_ZWCAD)
if (CAD_SDK_VERSION GREATER 2021)
message(STATUS ">>> 检测到现代 ZRX SDK (${CAD_SDK_VERSION}),自动提权至 C++14 标准")
set(CMAKE_CXX_STANDARD 14)
endif()
else()
if(CAD_SDK_VERSION GREATER 25)
message(STATUS ">>> 检测到现代 ARX SDK (${CAD_SDK_VERSION}),自动提权至 C++20 标准")
set(CMAKE_CXX_STANDARD 20)
elseif (CAD_SDK_VERSION GREATER_EQUAL 20)
message(STATUS ">>> 检测到现代 ARX SDK (${CAD_SDK_VERSION}),自动提权至 C++14 标准")
set(CMAKE_CXX_STANDARD 14)
elseif (CAD_SDK_VERSION GREATER 19)
message(STATUS ">>> 检测到现代 ARX SDK (${CAD_SDK_VERSION}),自动提权至 C++03 标准")
set(CMAKE_CXX_STANDARD 03)
else()
message(STATUS ">>> 检测到传统 ARX SDK (${CAD_SDK_VERSION}),保持 C++98 标准")
set(CMAKE_CXX_STANDARD 98)
endif()
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(REQUIRED_VARS
CAD_SDK_ROOT
DEP_LIB_ROOT
DEP_INC_ROOT
CAD_SDK_VERSION)
if (NOT IS_ZWCAD)
list(APPEND REQUIRED_VARS CAD_SDK_SUBVERSION)
endif()
foreach(VAR_NAME IN LISTS REQUIRED_VARS)
if(NOT DEFINED ${VAR_NAME})
message(FATAL_ERROR "【严重错误】缺少必要的配置变量: ${VAR_NAME}!请在 CMakePresets.json 中提供。")
endif()
endforeach()
if(MSVC)
add_compile_options(/MP)
add_compile_definitions(
UNICODE
_UNICODE
$<$<CONFIG:Release>:NDEBUG>
_CRT_SECURE_NO_WARNINGS
)
if (IS_ZWCAD)
message(STATUS ">>> 编译中望CAD版本")
add_compile_definitions(ZWCAD)
endif()
add_compile_options(/Zc:forScope-)
add_compile_options(/wd4819 /wd4996)
endif()
get_filename_component(GLOBAL_BIN_DIR "${GENERATE_BIN_DIR}" ABSOLUTE)
get_filename_component(GLOBAL_LIB_DIR "${GENERATE_LIB_DIR}" ABSOLUTE)
if (IS_ZWCAD)
set(GENERATE_DIR_TAG "Z${CAD_SDK_VERSION}")
else()
set(GENERATE_DIR_TAG "R${CAD_SDK_VERSION}${CAD_SDK_SUBVERSION}")
endif()
message(STATUS ">>> 当前输出版本标签: ${GENERATE_DIR_TAG}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${GLOBAL_BIN_DIR}/Debug-x64-${GENERATE_DIR_TAG}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${GLOBAL_BIN_DIR}/Release-x64-${GENERATE_DIR_TAG}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${GLOBAL_LIB_DIR}/Debug-x64-${GENERATE_DIR_TAG}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${GLOBAL_LIB_DIR}/Release-x64-${GENERATE_DIR_TAG}")
message(STATUS ">>> 正在构建 Code2026 业务树...")
add_custom_module(MFCCtrl "SH/Global_Libraries")
add_custom_module(sqliteserver "SH/Global_Libraries")
add_custom_module(AdsXRx "SH/ThunderProof")
add_custom_module(ThunderProof "SH/ThunderProof")
add_custom_module(AecRxBase "SH/Core")
add_custom_module(CoreImplement "SH/Core")
add_subdirectory(CoreLibrary)
add_subdirectory(CoreCommand)
add_custom_module(shsTK "SH/Other")
add_custom_module(Dimension "SH/Other")
add_custom_module(EarthWormMain "SH/Other")
add_custom_module(EarthWormCmd "SH/Other")
add_custom_module(PipelineCmd "SH/Pipe")
add_custom_module(pool3dcmd "SH/Pipe")
add_custom_module(PIDLineCmd "SH/Pipe")
add_custom_module_2(ISODraft ISODraftCmd "SH/Pipe")
add_custom_module(PipelineSpecCmd "SH/Pipe")
add_custom_module_2(PipeHanger PipeHangerCmd "SH/Pipe")
add_custom_module(PlumbingCmd "SH/Pipe")
add_custom_module(ElecCmd "SH/Structures")
add_custom_module(HvacCmd "SH/Structures")
add_custom_module(ArchCmd "SH/Structures")
add_custom_module(SPLDCmd "SH/Structures")
# cad_mcp_frame 依赖 nlohmann/json 与 ghc::filesystem,二者都需要 C++11+
# R180/R190 是 C++98,跳过;中望的现代 SDK 都是 C++14,可以编
if (IS_ZWCAD OR CAD_SDK_VERSION GREATER_EQUAL 20)
add_custom_module_2(cad_mcp_frame CadMcpFrame "SH/Other")
add_custom_module_2(cad_mcp_plugins CadMcpPlugins "SH/Other")
else()
message(STATUS ">>> 跳过 cad_mcp_frame:需要 C++11+(当前 preset 为 C++98)")
endif()
add_custom_module(tg_shs/shs_ximage/zlib "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_ximage/tiff "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_ximage/png "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_ximage/RAW "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_ximage/mng "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_ximage/Jpeg "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_ximage/jbig "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_ximage/jasper "TG/Global_Libraries/image")
add_custom_module_2(tg_shs/shs_ximage/ximage shs_ximage "TG/Global_Libraries/image")
add_custom_module(tg_shs/shs_dbf "TG/Global_Libraries")
add_custom_module(tg_shs/shs_sqlite "TG/Global_Libraries")
add_custom_module(tg_shs/shs_GeLib "TG/Core")
add_custom_module(tg_shs/shs_subgeLib "TG/Core")
add_custom_module_2(tg_shs/shs_kernal wfK "TG/Core")
add_custom_module_2(tg_shs/shs_annotate wfA "TG/Other")
add_custom_module_2(tg_shs/shs_blklib wfB "TG/Other")
add_custom_module_2(tg_shs/shs_siteplan wfS "TG/Other")
add_custom_module_2(tg_shs/shs_pipewire wfpipew "TG/Core")
add_custom_module_2(tg_shs/shs_twtkernal wfKernal "TG/Core")
add_custom_module_2(tg_shs/shs_twtanotate wfAnotate "TG/Other")
add_custom_module_2(tg_shs/shs_outdoor wfoutdoor "TG/Other")
add_custom_target(Build_TG)
add_dependencies(Build_TG
wfA
wfB
wfS
wfAnotate
wfoutdoor
)
add_custom_target(Build_SH_CORE)
add_dependencies(Build_SH_CORE
AecRxBase
CoreCommand_TRIAL_YEAR
CoreCommand_BAL_REMOTE
)
add_custom_target(Build_SH_GLOBAL)
add_dependencies(Build_SH_GLOBAL
MFCCtrl
sqliteserver
AdsXRx
ThunderProof
)