diff options
author | Arjun <36335769+0x34d@users.noreply.github.com> | 2022-07-25 22:16:01 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 12:46:01 -0400 |
commit | 6f831426e00ec8c42d2cc45ec03b652d491b320f (patch) | |
tree | 38a009eebd84197a1f3175858c1216e5618bd046 /CMakeLists.txt | |
parent | cc7e1578856b1bc6bbb10e67242bfefa473a8ed7 (diff) | |
download | rabbitmq-c-6f831426e00ec8c42d2cc45ec03b652d491b320f.tar.gz |
fuzzer deployment (#734)
* fuzzer deployment
Signed-off-by: 0x34d <ajsinghyadav00@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cd33223..1170675 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,8 @@ option(BUILD_TOOLS "Build Tools (requires POPT Library)" OFF) cmake_dependent_option(BUILD_TOOLS_DOCS "Build man pages for tools (requires xmlto)" OFF "BUILD_TOOLS" OFF) option(BUILD_API_DOCS "Build Doxygen API docs" OFF) option(RUN_SYSTEM_TESTS "Run system tests (i.e. tests requiring an accessible RabbitMQ server instance on localhost)" OFF) +option(BUILD_LIBFUZZ "Build LibFuzzer" OFF) +option(BUILD_AFLFUZZ "Build AFLFuzzer" OFF) if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) message(FATAL_ERROR "One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS must be set to ON to build") @@ -142,6 +144,27 @@ endif() set(targets_export_name rabbitmq-targets) +if(BUILD_LIBFUZZ) + if (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") + message(FATAL_ERROR "Need clang for libFuzzer support") + endif() + if (NOT BUILD_STATIC_LIBS) + message(FATAL_ERROR "LibFuzzer can only be built against static libraries " "(set BUILD_STATIC_LIBS=ON)") + endif () + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link,address,undefined") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined") +endif () + +if(BUILD_AFLFUZZ) + if (NOT BUILD_STATIC_LIBS) + message(FATAL_ERROR "AFL-Fuzzer can only be built against static libraries " "(set BUILD_STATIC_LIBS=ON)") + endif () + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,undefined") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined") +endif () + add_subdirectory(librabbitmq) if(BUILD_EXAMPLES) @@ -168,6 +191,10 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests) endif () +if(BUILD_LIBFUZZ OR BUILD_AFLFUZZ) + add_subdirectory(fuzz) +endif () + if (BUILD_API_DOCS) find_package(Doxygen REQUIRED) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile @ONLY) |