diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..50e5810 --- /dev/null +++ b/CMakeLists.txt @@ -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/" + "$" + COMMENT "Copying DLLs to build directory..." +) \ No newline at end of file diff --git a/README.md b/README.md index 3a6a217..7ae50ca 100644 --- a/README.md +++ b/README.md @@ -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/` 目录。)* ### 打包 (可选)