-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
62 lines (51 loc) · 1.88 KB
/
CMakeLists.txt
File metadata and controls
62 lines (51 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
cmake_minimum_required(VERSION 3.20)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(BeaconObjectFileLibrary LANGUAGES CXX)
endif()
set(BOF_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Core ${CMAKE_CURRENT_SOURCE_DIR}/Core/base)
set(BOF_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bofs)
file(MAKE_DIRECTORY ${BOF_OUTPUT_DIR})
set(BOF_TARGETS
WhoAmI
EnumDeviceDrivers
GetSystemDirectory
Ipconfig
FileExfiltrationUrlEncoded
RegistryPersistence
TimeStomp
)
# Release: compile-only BOF object files
set(BOF_COPY_COMMANDS)
foreach(BOF_NAME ${BOF_TARGETS})
add_library(${BOF_NAME} OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/${BOF_NAME}/bof.cpp)
target_include_directories(${BOF_NAME} PRIVATE ${BOF_INCLUDE_DIRS})
target_compile_options(${BOF_NAME} PRIVATE /GS- /EHsc)
list(APPEND BOF_COPY_COMMANDS
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:${BOF_NAME}> ${BOF_OUTPUT_DIR}/${BOF_NAME}.obj
)
endforeach()
add_custom_target(bofs ALL
${BOF_COPY_COMMANDS}
DEPENDS ${BOF_TARGETS}
COMMENT "Copying BOF object files to ${BOF_OUTPUT_DIR}"
)
# Debug: standalone executables with mocked Beacon APIs
option(BUILD_DEBUG_EXES "Build debug executables for BOFs" OFF)
if(BUILD_DEBUG_EXES)
set(MOCK_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/Core/base/mock.cpp
)
foreach(BOF_NAME ${BOF_TARGETS})
add_executable(${BOF_NAME}_debug
${CMAKE_CURRENT_SOURCE_DIR}/${BOF_NAME}/bof.cpp
${MOCK_SOURCES}
)
target_include_directories(${BOF_NAME}_debug PRIVATE ${BOF_INCLUDE_DIRS})
target_compile_definitions(${BOF_NAME}_debug PRIVATE _DEBUG)
target_compile_options(${BOF_NAME}_debug PRIVATE /EHsc /std:c++20)
set_target_properties(${BOF_NAME}_debug PROPERTIES
OUTPUT_NAME ${BOF_NAME}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/debug
)
endforeach()
endif()