mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-09 18:02:52 +08:00
build: 迁移项目构建系统至 CMake
- 新增 CMakeLists.txt 文件,定义项目构建规则、依赖和编译选项。 - 更新 README.md 文档,推荐使用 CMake 进行构建,并说明新旧构建方式。 - 保留原有的 Makefile 支持以保持向后兼容。
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(PathEditor C)
|
||||
|
||||
# Compile flags and definitions
|
||||
add_compile_options(-Wall -O2 -fexec-charset=UTF-8)
|
||||
add_compile_definitions(_WIN32 UNICODE _UNICODE)
|
||||
|
||||
# Include directories
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libs/iup-3.31_Win64_dllw6_lib/include
|
||||
)
|
||||
|
||||
# Source files
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/utils.c
|
||||
src/registry.c
|
||||
src/callbacks.c
|
||||
src/ui.c
|
||||
src/globals.c
|
||||
)
|
||||
|
||||
# Resource file
|
||||
set(RESOURCES
|
||||
ico/resources.rc
|
||||
)
|
||||
|
||||
# Library directories
|
||||
link_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libs/iup-3.31_Win64_dllw6_lib
|
||||
)
|
||||
|
||||
# Create WIN32 executable (automatically adds -mwindows and handles .rc files)
|
||||
add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${RESOURCES})
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
iup
|
||||
iupcd
|
||||
gdi32
|
||||
comdlg32
|
||||
comctl32
|
||||
uuid
|
||||
ole32
|
||||
advapi32
|
||||
)
|
||||
|
||||
# Copy DLLs to the build directory after building
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libs/iup-3.31_Win64_dllw6_lib/"
|
||||
"$<TARGET_FILE_DIR:${PROJECT_NAME}>"
|
||||
COMMENT "Copying DLLs to build directory..."
|
||||
)
|
||||
@@ -54,11 +54,13 @@
|
||||
|
||||
* Windows 操作系统
|
||||
* GCC 编译器 (推荐 MinGW-w64)
|
||||
* Make 工具
|
||||
* CMake 工具 (推荐使用 CMake 构建)
|
||||
* IUP 库 (已包含在 `libs` 目录下)
|
||||
* Inno Setup 6 (仅打包需要)
|
||||
|
||||
### 编译步骤
|
||||
### 编译步骤 (推荐使用 CMake)
|
||||
|
||||
本项目已迁移至 CMake 构建系统,支持生成更标准的构建文件并集成到各大 IDE。
|
||||
|
||||
1. 克隆仓库:
|
||||
|
||||
@@ -67,14 +69,20 @@
|
||||
cd PathEditor
|
||||
```
|
||||
|
||||
2. 编译项目:
|
||||
2. 使用 CMake 配置和编译:
|
||||
|
||||
```bash
|
||||
mingw32-make
|
||||
# 生成构建系统 (以 MinGW 为例)
|
||||
cmake -B build -G "MinGW Makefiles"
|
||||
|
||||
# 编译项目
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
3. 运行:
|
||||
编译成功后,可执行文件位于 `bin/PathEditor.exe`。
|
||||
编译成功后,可执行文件位于 `build/PathEditor.exe`。
|
||||
|
||||
*(注:项目依然保留了传统的 `mingw32-make` 方式,您可以直接在根目录运行 `mingw32-make` 进行编译,产物位于 `bin/` 目录。)*
|
||||
|
||||
### 打包 (可选)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user