rev: set up cross compiling to develop in both linux and windows

This commit is contained in:
2026-06-26 22:01:27 +01:00
parent 09064420b0
commit 24fec4db32
4 changed files with 72 additions and 10 deletions
+18 -9
View File
@@ -1,15 +1,24 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.20)
project(wh0revshell CXX) project(wh0loader LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(wh0revshell "src/wh0revshell.cpp") add_executable(wh0loader
src/wh0loader.cpp
)
# Explicitly link Windows socket library # Windows libs
target_link_libraries(wh0revshell PRIVATE ws2_32) if(WIN32)
target_link_libraries(wh0loader PRIVATE ws2_32)
# Force Static Linking endif()
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # Static runtime (GCC MinGW)
if(MINGW)
target_link_options(wh0loader PRIVATE
-static
-static-libgcc
-static-libstdc++
-pthread
)
endif() endif()
+37
View File
@@ -0,0 +1,37 @@
{
"version": 6,
"configurePresets": [
{
"name": "linux",
"displayName": "Linux → Windows (MinGW)",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/bin",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchains/mingw-w64.cmake"
}
},
{
"name": "windows",
"displayName": "Windows (MinGW)",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/bin",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "linux",
"configurePreset": "linux"
},
{
"name": "windows",
"configurePreset": "windows"
}
]
}
+16
View File
@@ -0,0 +1,16 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
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)
+1 -1
View File
@@ -3,7 +3,7 @@
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <ws2def.h> #include <ws2def.h>
#include <Windows.h> #include <windows.h>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>