Development
开发环境配置
欢迎访问PFCSU软件文档。
开发环境配置
Msys2 安装
基本工具链
pacman -Syu
pacman -S unzip
pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-nsis
pacman -S mingw-w64-x86_64-dlfcn
Msys2 环境配置
VSCode
setting.json配置 // 设置Msys2环境变量,使得右键菜单打开的终端也能够使用Msys2环境并切换至选定的工作目录
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": []
},
"Git Bash": {
"source": "Git Bash"
},
"MSYS64 (MinGW64)": {
"path": "cmd.exe",
"args": [
"/c",
"C:\\path\\to\\msys64\\msys2_shell.cmd -defterm -here -no-start -mingw64 -shell bash"
],
"env": {
"MSYSTEM": "MINGW64",
"PATH": "/mingw64/bin:/usr/bin:/usr/local/bin:/bin:${env:PATH}"
}
}
}
QT Creator (集成开发环境)
官网为https://www.qt.io/, 下载开源版本。下载后按照提示安装即可。安装版本建议以6.4版本为主。
QT (桌面开发环境及发布)
QT环境
pacman -S mingw-w64-x86_64-qt6
pacman -S mingw-w64-x86_64-qt6-tools
pacman -S mingw-w64-x86_64-qt6-translations
打包工具
pacman -S mingw-w64-x86_64-nsis
第三方库的安装
脚本功能
- 在3rd目录下创建
codes和src目录,前者用于存放第三方库的源代码的压缩文件,后者用于存放解压后的源代码。 - 用户在没有网络的条件下,可以在
codes目录下放置第三方库的源代码压缩文件,然后CMake会自动解压并编译。 - 用户在运行CMake时可以使用
-DSKIP_DOWNLOAD_CHECK=ON选项跳过下载检查,这样可以加快CMake的运行速度。
3rd/CMakeLists.txt# 3rd/CMakeLists.txt
set(dep_names
"strutil"
"json"
"fmt"
"spdlog"
"cxxopts"
"secondwatch"
"pepper"
"googletest"
"yamlcpp"
CACHE INTERNAL ""
)
set(dep_urls
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/zjdev/strutil-v1.1.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/3rd/json-3.11.2.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/3rd/fmt-10.0.0.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/3rd/spdlog-1.12.0.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/3rd/cxxopts-3.0.0.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/3rd/secondwatch-v1.0.1.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/zjdev/pepper-v1.0.2.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/3rd/googletest-release-1.12.1.zip"
"https://ppm-code.oss-cn-shenzhen.aliyuncs.com/3rd/yaml-cpp-master-2023-07-22.zip"
CACHE INTERNAL ""
)
if (POLICY CMP0135)
# Allow CMake 3.13+ to override options when using FetchContent / add_subdirectory.
cmake_policy(SET CMP0135 NEW)
endif ()
# if cmake is less than 3.17, than fail and say it lound
if (${CMAKE_VERSION} VERSION_LESS "3.17.0")
message(FATAL_ERROR "CMake version must be at least 3.17.0")
# skip the rest of the file
return()
endif ()
option(SKIP_DOWNLOAD_CHECK "Skip checking for downloaded files" OFF)
message(STATUS "Skip download check: ${SKIP_DOWNLOAD_CHECK}")
if (NOT SKIP_DOWNLOAD_CHECK)
message(STATUS "Checking for downloaded files")
foreach(name url IN ZIP_LISTS dep_names dep_urls)
message(STATUS "The dependency <name = ${name}> is: ${url}")
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/3rd/codes/${name}.zip")
message(STATUS "${name}.zip does not exist")
file(DOWNLOAD
${url}
${PROJECT_SOURCE_DIR}/3rd/codes/${name}.zip
)
endif()
endforeach()
set(SPDLOG_FMT_EXTERNAL ON)
set(ENABLE_CCHI_TOOL ON)
foreach(name url IN ZIP_LISTS dep_names dep_urls)
message(STATUS "The dependency <name = ${name}> is: ${url}")
FetchContent_Declare(${name} URL ${PROJECT_SOURCE_DIR}/3rd/codes/${name}.zip
SOURCE_DIR ${PROJECT_SOURCE_DIR}/3rd/src/${name}-src
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}-bin
)
FetchContent_MakeAvailable(${name})
endforeach()
endif()
if (SKIP_DOWNLOAD_CHECK)
message(STATUS "Skipping downloading files")
set(SPDLOG_FMT_EXTERNAL ON)
set(ENABLE_CCHI_TOOL ON)
foreach(name url IN ZIP_LISTS dep_names dep_urls)
message(STATUS "The dependency <name = ${name}> is: ${url}")
add_subdirectory(${PROJECT_SOURCE_DIR}/3rd/src/${name}-src)
endforeach()
endif()