forked from grimm-co/killerbeez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
136 lines (117 loc) · 5.03 KB
/
CMakeLists.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
cmake_minimum_required (VERSION 2.8.8)
project (killerbeez)
include(ExternalProject)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") # for _DEBUG ifdefs in utils.h
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfatal-errors") # quit after first error
endif (UNIX)
if (APPLE)
set(CMAKE_MACOSX_RPATH 1) # https://github.com/liballeg/allegro5/issues/532#issuecomment-170338164
endif (APPLE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug) # for gcc -g
message("WARNING: Building with debug options; performance will be impacted. Try cmake -DCMAKE_BUILD_TYPE=Release ..")
endif()
if (WIN32)
# windows/visual studio build convention eg build/X86/Debug
SET ( BUILD_DIRECTORY ${CMAKE_SOURCE_DIR}/build/${CMAKE_C_COMPILER_ARCHITECTURE_ID}/${CMAKE_BUILD_TYPE} )
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_DEPRECATION_DISABLE -D_CRT_NONSTDC_NO_DEPRECATE)
else (WIN32)
SET ( BUILD_DIRECTORY ${CMAKE_BINARY_DIR} )
endif (WIN32)
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY}/killerbeez/ )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILD_DIRECTORY}/killerbeez/ )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIRECTORY}/killerbeez/ )
# Make linux builds relocatable
SET(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
SET(CMAKE_INSTALL_RPATH "$ORIGIN")
# add headers for utils from utils source folder/repo
include_directories (jansson/)
include_directories (utils/)
# IWYU. Pass -DNO_IWYU=1 to disable, -DNO_IWYU= to re-enable (or regenerate cache)
if (UNIX AND NOT NO_IWYU)
find_program(iwyu_path NAMES include-what-you-use iwyu)
if(NOT iwyu_path)
# can be installed with sudo apt install iwyu -y
message(STATUS "Could not find include-what-you-use, continuing without it")
else()
message(STATUS "Found include-what-you-use, displaying its suggestions")
set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${iwyu_path})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
endif()
else()
message(STATUS "include-what-you-use disabled")
endif()
add_subdirectory(jansson/)
# The general mutator library with the common functionality
add_subdirectory(mutators)
add_subdirectory(corpus) # test programs
add_subdirectory(fuzzer) # instantiates & coordinates other parts
add_subdirectory(driver) # starts program, feeds input, determines when program is done
add_subdirectory(instrumentation) # inserts instructions to program to tell whether an input makes the binary take a new path
add_subdirectory(merger) # merges instrumentation data between fuzzer nodes
add_subdirectory(tracer) # runs through program and records basic block edges
if (WIN32)
add_subdirectory(picker) # picks which libraries of a target program are being used, and worth fuzzing
add_subdirectory(winafl) # parts ripped from winafl for dynamorio
endif (WIN32)
### RELEASE ZIP CONFIG ###
# Choose what to install into the release zip
install(DIRECTORY ${BUILD_DIRECTORY}/killerbeez DESTINATION . USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${BUILD_DIRECTORY}/mutators DESTINATION . USE_SOURCE_PERMISSIONS)
### BOINC wrapper ###
# If on Windows, include prebuilt BOINC wrapper
if (WIN32)
SET(BOINC_WRAPPER C:/killerbeez/wrapper_26014_windows_x86_64.exe)
endif ()
# If on Linux, we can build our own BOINC wrapper
if (UNIX AND (NOT APPLE))
SET(BOINC_WRAPPER ${CMAKE_SOURCE_DIR}/server/boinc/samples/wrapper/wrapper)
ExternalProject_Add(boinc-wrapper
SOURCE_DIR ${CMAKE_SOURCE_DIR}/server/boinc
DOWNLOAD_COMMAND cd ${CMAKE_SOURCE_DIR} && git submodule update --init server/boinc
BUILD_IN_SOURCE true
CONFIGURE_COMMAND ./_autosetup
COMMAND ./configure --disable-server --disable-client --disable-manager --enable-boinczip
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
COMMAND ${CMAKE_MAKE_PROGRAM} -C samples/wrapper
INSTALL_COMMAND ""
)
endif ()
install(PROGRAMS ${BOINC_WRAPPER} DESTINATION server/skel)
### radamsa ###
set(RADAMSA_URL https://gitlab.com/akihe/radamsa.git)
ExternalProject_Add(radamsa
GIT_REPOSITORY ${RADAMSA_URL}
GIT_TAG develop
BUILD_IN_SOURCE true
CONFIGURE_COMMAND ""
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL true
)
ExternalProject_Get_Property(radamsa SOURCE_DIR)
install(DIRECTORY ${SOURCE_DIR}/bin DESTINATION radamsa USE_SOURCE_PERMISSIONS)
install(FILES ${SOURCE_DIR}/LICENCE DESTINATION radamsa)
# Set up CPack to generate the release zip
SET(CPACK_GENERATOR "ZIP")
# TODO: might want some kind of versioning or architecture in this name
SET(CPACK_PACKAGE_FILE_NAME "killerbeez-${CMAKE_SYSTEM_NAME}")
SET(CPACK_SOURCE_GENERATOR "ZIP")
SET(CPACK_SOURCE_IGNORE_FILES "/build/;/server/boinc/")
SET(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR};killerbeez")
include (CPack)
# Special `release` target to ensure boinc-wrapper is built before package
add_custom_target(release
${CMAKE_MAKE_PROGRAM} package)
if (UNIX)
if (APPLE)
# macOS can't build the boinc wrapper right now, maybe we can patch
# things up in the future to make this possible, but for now we're
# just not building it.
add_dependencies(release radamsa)
else ()
add_dependencies(release radamsa boinc-wrapper)
endif ()
endif ()