Files
envi-code/SourceCode/Code2026/cmakelists.txt
T
company-desktop 0d02d33f1d feat: 把 cad_mcp_frame 整合进 Code2026 的 CMake 体系
源工程在 d:\new-start\CadProject\src\cad_mcp_frame(vcpkg 独立工程),
本次按 code2026 的 preset/CMake 体系移植到 SourceCode/Code2026/cad_mcp_frame。

移植改动:
- 源码 + .def + .rc + res/ + cad-mcp-frame.json 拷入 cad_mcp_frame/;
  插件接口头 mcp_plugin_api.h 放到 cad_mcp_frame/inc/
- cadsdk.h -> KTCad.h(两者除尾部 4 个 include 与 using namespace MemOper 外完全一致)
- nlohmann/json 单头放 SourceCode/dep_inc/nlohmann/json.hpp,
  ghc::filesystem 单头放 SourceCode/dep_inc/ghc/filesystem.hpp;
  target_link_objectarx 已把 DEP_INC_ROOT 加进 include 路径,故无需额外配置
- 新增 cad_mcp_frame/cmakelists.txt:按 PipeHangerCmd 的写法
  (add_def_file_name / target_set_name_and_suffix .arx / target_link_objectarx /
  target_include_directories inc / set_debug_post_build)
- 补 SUB_ARX 宏:原工程由 CadProject 的 cmake 注入,code2026 只注入 ARX;
  在模块自己的 CMake 里补,不动共享 functions.cmake(中望给 0)
- 顶层挂载 add_custom_module_2(cad_mcp_frame CadMcpFrame "SH/Other"),
  并加条件:nlohmann/json 与 ghc::filesystem 都需要 C++11+,
  而 R180/R190 是 C++98,故只在 (IS_ZWCAD OR CAD_SDK_VERSION >= 20) 时编译
- 中望适配两处:_zrx.def 要导出 zcrxEntryPoint/zcrxGetApiVersion;
  代码里显式声明的 acrxGetApiVersion() 不会被 SDK 宏改名,
  改为 #ifdef ZWCAD 取 zcrxGetApiVersion()

验证:
- R230 Debug 编译通过,cad_mcp_frame.arx 818 KB,自动部署到
  c:\ShangHuaSoft\Envi3D-2026-M\R230\
- Z2026 Debug 编译通过,cad_mcp_frame.zrx 818 KB,自动部署到 ...\Z2026\
- R190/R180 按条件跳过(C++98 无法编译 nlohmann/json)
- 所有 .cpp/.h 均为 UTF-8 with BOM;cmakelists.txt 保持 ASCII 无 BOM

未做:没有在 CAD 里加载实测;配置文件仍是 cad-mcp-frame.json,
而代码里找的是 mcp_config.json,加载前需要统一(详见 cad_mcp_frame-review.md);
插件工程 cad_mcp_plugins 未移植(18 个工具里 16 个依赖它)。
2026-10-28 23:20:07 +08:00

181 lines
6.3 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")
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
)