diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a4803e545..787e30037 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -283,6 +283,10 @@ if(ENABLE_COVERAGE) message(STATUS "nDPI: Enable Coverage") set(NDPI_ADDITIONAL_ARGS "${NDPI_ADDITIONAL_ARGS} --enable-code-coverage") endif() +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "") + message(STATUS "nDPI: Enable Debug Build") + set(NDPI_ADDITIONAL_ARGS "${NDPI_ADDITIONAL_ARGS} --enable-debug-build --enable-debug-messages") +endif() execute_process( COMMAND git describe --tags @@ -308,7 +312,9 @@ if(CMAKE_CROSSCOMPILING) add_definitions("-DCROSS_COMPILATION=1") endif() if(ENABLE_MEMORY_PROFILING) - message(WARNING "ENABLE_MEMORY_PROFILING should not be used in production environments.") + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CMAKE_BUILD_TYPE STREQUAL "") + message(WARNING "ENABLE_MEMORY_PROFILING should not be used in production environments.") + endif() add_definitions("-DENABLE_MEMORY_PROFILING=1" "-Duthash_malloc=nDPIsrvd_uthash_malloc" "-Duthash_free=nDPIsrvd_uthash_free") @@ -442,6 +448,24 @@ target_link_libraries(nDPId-test "${STATIC_LIBNDPI_LIB}" "${STATIC_PFRING_LIB}" "${GCRYPT_LIBRARY}" "${GCRYPT_ERROR_LIBRARY}" "${PCAP_LIBRARY}" "${LIBM_LIB}" "${PF_RING_LIB}" "-pthread") +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + add_executable(fuzz_ndpi_process_packet test/fuzz_ndpi_process_packet.c) + if(BUILD_NDPI) + add_dependencies(fuzz_ndpi_process_packet libnDPI) + endif() + target_compile_options(fuzz_ndpi_process_packet PRIVATE "-Wno-unused-function" "-fsanitize=fuzzer" "-pthread") + target_compile_definitions(fuzz_ndpi_process_packet PRIVATE -D_GNU_SOURCE=1 + -DPKG_VERSION=\"${PKG_VERSION}\" -DGIT_VERSION=\"${GIT_VERSION}\" + ${NDPID_DEFS} ${EPOLL_DEFS} ${ZLIB_DEFS} ${PFRING_DEFS}) + target_include_directories(fuzz_ndpi_process_packet PRIVATE "${STATIC_LIBNDPI_INC}" "${DEFAULT_NDPI_INCLUDE}" + ${NDPID_DEPS_INC} ${PFRING_KERNEL_INC} ${PFRING_INC}) + target_link_libraries(fuzz_ndpi_process_packet "${STATIC_LIBNDPI_LIB}" "${STATIC_PFRING_LIB}" "${pkgcfg_lib_PCAP_pcap}" "${pkgcfg_lib_NDPI_ndpi}" + "${pkgcfg_lib_PCRE_pcre2-8}" "${pkgcfg_lib_MAXMINDDB_maxminddb}" "${pkgcfg_lib_ZLIB_z}" + "${GCRYPT_LIBRARY}" "${GCRYPT_ERROR_LIBRARY}" "${PCAP_LIBRARY}" "${LIBM_LIB}" "${PF_RING_LIB}" + "-pthread") + target_link_options(fuzz_ndpi_process_packet PRIVATE "-fsanitize=fuzzer") +endif() + if(BUILD_EXAMPLES) add_executable(nDPIsrvd-collectd examples/c-collectd/c-collectd.c utils.c) if(BUILD_NDPI) @@ -610,3 +634,6 @@ if(NOT NDPI_NO_PKGCONFIG) message(STATUS "- pkgcfg_lib_NDPI_ndpi...: ${pkgcfg_lib_NDPI_ndpi}") endif() message(STATUS "--------------------------") +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") +message(STATUS "Fuzzing enabled") +endif() |