Files
desktop-plugin/windows/runner/CMakeLists.txt
T
dzc fb399ae8f6 fix(windows): 全量代码审查修复——中文乱码风险/Inno 兼容/ffi 布局自检/部署说明
系统性把 mac 踩过的坑逐一在 Windows 对应路径排查后修复四处:

1. runner 加 /utf-8 编译选项(高危):MSVC 默认按系统代码页(中文 Windows=GBK)
   解析 UTF-8 源码,main.cpp 的 L"资安信插件助手" 窗口标题会乱码
2. installer.iss 的 x64compatible → x64:前者需 Inno 6.3+,旧版 iscc 直接报错
3. PavoApi 构造加结构体布局 assert(80/32/16/48 字节,对齐 C# 实机验证值),
   Windows 首跑(debug)即暴露 ffi 对齐差异
4. README 补 Windows 部署注意:VC++ Redistributable(PavoApiW_x64.dll 可能
   动态依赖 vcruntime140.dll)、SmartScreen 未签名提示、Inno 6.x 要求

其余复查项确认无问题:reg 命令引号(空格路径安全)、Dart/Inno 的 Run 键名
一致(ZaxDesktopPlugin)、vendor DLL 拷贝用生成器表达式(Debug/Release 通用)、
pavo 全部 ffi 调用在 Isolate.run、scheme 注册表路径拼接、关窗拦截走
window_manager 的 WM_CLOSE 主路径(无 mac 的 _close: 私有 selector 问题)。
2026-09-21 14:22:16 +08:00

57 lines
2.6 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.14)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
"utils.cpp"
"win32_window.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
"Runner.rc"
"runner.exe.manifest"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# 源文件为 UTF-8:MSVC 默认按系统代码页(中文系统 GBK)解析源码,
# main.cpp 的中文宽字符串(窗口标题"资安信插件助手")会乱码,必须显式声明
target_compile_options(${BINARY_NAME} PRIVATE "/utf-8")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
# HiTi PavoApi SDK(windows/vendor/)拷到可执行文件旁:
# Dart 侧 DynamicLibrary.open('PavoApiW_x64.dll') 按可执行文件目录查找;
# heatthcd.bin 为 SDK 运行数据,与其余 DLL 一并部署
add_custom_command(TARGET ${BINARY_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/../vendor/PavoApiW_x64.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../vendor/PavoCardSDK_x64.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../vendor/HeatTB3.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../vendor/heatthcd.bin"
$<TARGET_FILE_DIR:${BINARY_NAME}>
)