semiproper cmake build configuration

This commit is contained in:
17ms 2023-12-29 21:36:08 +02:00
parent 89d042fb45
commit d2ae162332
5 changed files with 47 additions and 44 deletions

3
.gitignore vendored
View File

@ -50,3 +50,6 @@ modules.order
Module.symvers Module.symvers
Mkfile.old Mkfile.old
dkms.conf dkms.conf
# CMAke generated makefiles
build/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "concord"]
path = concord
url = https://github.com/Cogmasters/concord

41
CMakeLists.txt Normal file
View File

@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.11)
project(airborne)
include(FetchContent)
if(NOT CMAKE_SYSTEM_NAME MATCHES Windows)
message(FATAL_ERROR "Use a cross compilation suitable toolchain with CMAKE_SYSTEM_NAME set to Windows")
endif()
if(NOT MSVC)
add_compile_options("-Wall")
else()
# Level 4 warnings
add_compile_options("-W4")
endif()
# Discord API wrapper dependency
FetchContent_Declare(
concord
GIT_REPOSITORY https://github.com/Cogmasters/concord
GIT_TAG 769bdb7 # v2.2.1 release
)
FetchContent_MakeAvailable(concord)
# *) Reflective loader (DLL)
add_library(reflective_loader SHARED reflective_loader/loader.c reflective_loader/loader.h)
# *) Payload (DLL)
add_library(payload SHARED payload/payload.c)
# *) Injector (EXE)
add_executable(injector injector/injector.c)
target_link_libraries(injector PRIVATE concord)
# *) Shellcode generator (EXE)
add_executable(shellcode_generator shellcode_generator/generator.c)
target_link_libraries(shellcode_generator PRIVATE concord)
# Include directories
target_include_directories(injector PRIVATE concord)
target_include_directories(shellcode_generator PRIVATE concord)

View File

@ -1,22 +0,0 @@
# Usage:
# *) Install cross-compiler: `sudo apt install mingw-w64`
# *) cmake -DCMAKE_TOOLCHAIN_FILE=macos-mingw-w64-x86_64.cmake -B build -S .
# *) make -C build
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
# Cross-compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
# Target environment on the build host system (with Homebrew)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
# Search for programs in the build host directories (modifying default behavior of FIND_XXX())
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_C_FLAGS "${CMAKE_C_FLAGS} -static -Os")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -Os")

View File

@ -1,22 +0,0 @@
# Usage:
# *) Install cross-compiler: `brew install mingw-w64`
# *) cmake -DCMAKE_TOOLCHAIN_FILE=macos-mingw-w64-x86_64.cmake -B build -S .
# *) make -C build
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
# Cross-compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
# Target environment on the build host system (with Homebrew)
set(CMAKE_FIND_ROOT_PATH /opt/homebrew/Cellar/mingw-w64/11.0.1/toolchain-x86_64/${TOOLCHAIN_PREFIX})
# Search for programs in the build host directories (modifying default behavior of FIND_XXX())
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_C_FLAGS "${CMAKE_C_FLAGS} -static -Os")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -Os")