From 85c3fe47292f4e4e47a1f58f1347cb1f6d03b37e Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Tue, 20 Oct 2020 15:31:52 +0200 Subject: [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. --- cmake/CheckAFLCCompiler.cmake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cmake/CheckAFLCCompiler.cmake (limited to 'cmake') diff --git a/cmake/CheckAFLCCompiler.cmake b/cmake/CheckAFLCCompiler.cmake new file mode 100644 index 0000000..249248b --- /dev/null +++ b/cmake/CheckAFLCCompiler.cmake @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2020 Manuel Bentele +# + +# check if corresponding AFL C Compiler form original C compiler is available +# if an AFL C compiler is available, then the path to the AFL C compiler is returned in AFL_C_COMPILER +macro(check_afl_c_compiler AFL_C_COMPILER AFL_C_COMPILER_NAME C_COMPILER_PATH C_COMPILER_ID) + # determine AFL C compiler suffix from original C compiler ID + if(${C_COMPILER_ID} MATCHES "GNU") + set(AFL_C_COMPILER_SUFFIX "gcc") + elseif(${C_COMPILER_ID} MATCHES "Clang") + set(AFL_C_COMPILER_SUFFIX "clang") + else(${C_COMPILER_ID} MATCHES "Clang") + get_filename_component(AFL_C_COMPILER_SUFFIX ${C_COMPILER_PATH} NAME) + endif(${C_COMPILER_ID} MATCHES "GNU") + + # define search file name and search for AFL C compiler program + set(AFL_C_COMPILER_SEARCH_NAME "afl-${AFL_C_COMPILER_SUFFIX}") + find_program(${AFL_C_COMPILER} NAMES ${AFL_C_COMPILER_SEARCH_NAME}) + + # return the AFL C compiler name to the caller + set(${AFL_C_COMPILER_NAME} ${AFL_C_COMPILER_SEARCH_NAME}) +endmacro(check_afl_c_compiler) \ No newline at end of file -- cgit v1.2.3-55-g7522