cmake: tests: provide umdns-san binary
authorPetr Štetiar <ynezz@true.cz>
Tue, 13 Oct 2020 12:40:14 +0000 (14:40 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 13 Oct 2020 13:27:49 +0000 (15:27 +0200)
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>
CMakeLists.txt

index 80d1cf5be3524079f166cbb4443bfc45610671fa..f1bc8f0e9dfe24e660dd04a7f7d9a70c2fec014b 100644 (file)
@@ -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