summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Štetiar2020-10-13 12:40:14 +0000
committerPetr Štetiar2020-10-13 13:27:49 +0000
commitbe687257ee0bef2a06c37de71664fbc74122ff6c (patch)
tree17166c5af36d0a5269e9c6607135e359553ce3f2
parentbf01f2dd0089fd4a77a792ecf9f0fa45dbd66b50 (diff)
downloadmdnsd-be687257ee0bef2a06c37de71664fbc74122ff6c.tar.gz
cmake: tests: provide umdns-san binary
Which is compiled with clang UB, address and leak sanitizers which is handy for example with fuzzing directly over network. Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r--CMakeLists.txt13
1 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 80d1cf5..f1bc8f0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,19 @@ TARGET_LINK_LIBRARIES(umdns umdns-lib)
IF(UNIT_TESTING)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
+
+ IF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ ADD_LIBRARY(umdns-lib-san STATIC ${SOURCES})
+ TARGET_COMPILE_OPTIONS(umdns-lib-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
+ TARGET_LINK_OPTIONS(umdns-lib-san PRIVATE -fsanitize=undefined,address,leak)
+ TARGET_LINK_LIBRARIES(umdns-lib-san ${LIBS})
+
+ ADD_EXECUTABLE(umdns-san main.c ${SOURCES})
+ TARGET_COMPILE_OPTIONS(umdns-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
+ TARGET_LINK_OPTIONS(umdns-san PRIVATE -fsanitize=undefined,address,leak)
+ TARGET_LINK_LIBRARIES(umdns-san umdns-lib-san)
+ ENDIF()
+
ENDIF()
INSTALL(TARGETS umdns