From 384258577776707545cf5673e1b5a932f114d657 Mon Sep 17 00:00:00 2001 From: xiaozhou233 Date: Wed, 12 Aug 2026 09:49:34 +0800 Subject: [PATCH] Build: Add MinGW cross-compilation support --- .gitignore | 1 + CMakePresets.json | 12 ++++++++++++ includes/ReflectiveDLLInjection/ReflectiveLoader.h | 2 +- toolchains/x86_64-w64-mingw32.cmake | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 toolchains/x86_64-w64-mingw32.cmake diff --git a/.gitignore b/.gitignore index 554d92a..1cf9bf7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ debug/* UserDir/* CMakeCache.txt examples/loop/loop.class +build-mingw/* diff --git a/CMakePresets.json b/CMakePresets.json index 2a43189..7b54461 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -17,6 +17,18 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + }, + { + "name": "mingw-release", + "inherits": "ninja-release", + "binaryDir": "${sourceDir}/build-mingw", + "toolchainFile": "${sourceDir}/toolchains/x86_64-w64-mingw32.cmake" + }, + { + "name": "mingw-debug", + "inherits": "ninja-debug", + "binaryDir": "${sourceDir}/build-mingw", + "toolchainFile": "${sourceDir}/toolchains/x86_64-w64-mingw32.cmake" } ] } diff --git a/includes/ReflectiveDLLInjection/ReflectiveLoader.h b/includes/ReflectiveDLLInjection/ReflectiveLoader.h index 83a1731..fec3781 100644 --- a/includes/ReflectiveDLLInjection/ReflectiveLoader.h +++ b/includes/ReflectiveDLLInjection/ReflectiveLoader.h @@ -30,7 +30,7 @@ #define WIN32_LEAN_AND_MEAN -#include +#include #include #include diff --git a/toolchains/x86_64-w64-mingw32.cmake b/toolchains/x86_64-w64-mingw32.cmake new file mode 100644 index 0000000..6ae5202 --- /dev/null +++ b/toolchains/x86_64-w64-mingw32.cmake @@ -0,0 +1,14 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR amd64) + +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)