summaryrefslogtreecommitdiffstats
path: root/src/server/CMakeLists.txt
diff options
context:
space:
mode:
authorManuel Bentele2020-10-20 15:31:52 +0200
committerManuel Bentele2020-10-20 15:31:52 +0200
commit85c3fe47292f4e4e47a1f58f1347cb1f6d03b37e (patch)
treed8d7cf3d229bec1ec0b94747b5f427fd6bd6f063 /src/server/CMakeLists.txt
parent[BUILD] do not stop Release build if repository is dirty but warn (diff)
downloaddnbd3-85c3fe47292f4e4e47a1f58f1347cb1f6d03b37e.tar.gz
dnbd3-85c3fe47292f4e4e47a1f58f1347cb1f6d03b37e.tar.xz
dnbd3-85c3fe47292f4e4e47a1f58f1347cb1f6d03b37e.zip
[BUILD] add option to build the dnbd3-server with afl-fuzz support
The afl-fuzz support for the dnbd3-server requires an AFL C compiler like afl-gcc and can be enabled with the CMake option DNBD3_SERVER_AFL.
Diffstat (limited to 'src/server/CMakeLists.txt')
-rw-r--r--src/server/CMakeLists.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
index 1855d91..aa981f6 100644
--- a/src/server/CMakeLists.txt
+++ b/src/server/CMakeLists.txt
@@ -13,9 +13,27 @@ endif(NOT JANSSON_FOUND)
add_definitions(-D_GNU_SOURCE)
if(DNBD3_SERVER_AFL)
+ # check if DNBD3_RELEASE_HARDEN is disabled
+ if(DNBD3_RELEASE_HARDEN)
+ message(FATAL_ERROR "DNBD3_SERVER_AFL can only be enabled if DNBD3_RELEASE_HARDEN is disabled")
+ endif(DNBD3_RELEASE_HARDEN)
+
# build dnbd3-server with AFL support
message(STATUS "Building dnbd3-server with AFL support")
add_definitions(-DDNBD3_SERVER_AFL)
+
+ # change compiler for dnbd3-server sources if AFL enabled
+ include(CheckAFLCCompiler)
+ check_afl_c_compiler(AFL_C_COMPILER AFL_C_COMPILER_NAME ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ID})
+ if(AFL_C_COMPILER)
+ message(STATUS "Check for working AFL C compiler: ${AFL_C_COMPILER} - done")
+ # change C compiler to a corresponding AFL C compiler
+ set(CMAKE_C_COMPILER "${AFL_C_COMPILER}")
+ else(AFL_C_COMPILER)
+ # no corresponding AFL C compiler found
+ message(STATUS "Check for working AFL C compiler: ${AFL_C_COMPILER_NAME} - failed")
+ message(FATAL_ERROR "No corresponding AFL C compiler ${AFL_C_COMPILER_NAME} was found for the C compiler ${CMAKE_C_COMPILER}!")
+ endif(AFL_C_COMPILER)
endif(DNBD3_SERVER_AFL)
add_executable(dnbd3-server ${CMAKE_CURRENT_SOURCE_DIR}/altservers.c