Return LIB_PROTO_MUTATOR_FUZZER_LIBRARIES as it's used by OSS-fuzz
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e8d9c43..c018d45 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,7 @@
option(LIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF
"Automatically download working protobuf" OFF)
option(LIB_PROTO_MUTATOR_WITH_ASAN "Enable address sanitizer" OFF)
+set(LIB_PROTO_MUTATOR_FUZZER_LIBRARIES "" CACHE STRING "Fuzzing engine libs")
# External dependencies
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/external)
@@ -77,12 +78,15 @@
endif()
endif()
-if (LIB_PROTO_MUTATOR_HAS_SANITIZE_FUZZER)
- set(FUZZING_FLAGS "-fsanitize=fuzzer-no-link")
- set(FUZZING_FLAGS_BINARY "-fsanitize=fuzzer")
-endif()
-if (LIB_PROTO_MUTATOR_HAS_SANITIZE_NO_FUZZER)
- set(NO_FUZZING_FLAGS "-fno-sanitize=fuzzer")
+# Assume CFLAGS has coverage options if LIB_PROTO_MUTATOR_FUZZER_LIBRARIES was set
+if ("${LIB_PROTO_MUTATOR_FUZZER_LIBRARIES}" STREQUAL "")
+ if (LIB_PROTO_MUTATOR_HAS_SANITIZE_FUZZER)
+ set(FUZZING_FLAGS "-fsanitize=fuzzer-no-link")
+ set(FUZZING_FLAGS_BINARY "-fsanitize=fuzzer")
+ endif()
+ if (LIB_PROTO_MUTATOR_HAS_SANITIZE_NO_FUZZER)
+ set(NO_FUZZING_FLAGS "-fno-sanitize=fuzzer")
+ endif()
endif()
if (LIB_PROTO_MUTATOR_HAS_NO_COVERAGE)
set(NO_FUZZING_FLAGS "${NO_FUZZING_FLAGS} -fsanitize-coverage=0")
@@ -118,7 +122,8 @@
add_subdirectory(src)
-if (NOT "${FUZZING_FLAGS}" STREQUAL "")
+if (NOT "${LIB_PROTO_MUTATOR_FUZZER_LIBRARIES}" STREQUAL "" OR
+ NOT "${FUZZING_FLAGS}" STREQUAL "")
add_subdirectory(examples EXCLUDE_FROM_ALL)
endif()
diff --git a/examples/expat/CMakeLists.txt b/examples/expat/CMakeLists.txt
index 1edb457..f2031f5 100644
--- a/examples/expat/CMakeLists.txt
+++ b/examples/expat/CMakeLists.txt
@@ -20,6 +20,7 @@
expat_example.cc)
target_link_libraries(expat_example
protobuf-mutator-xml
+ ${LIB_PROTO_MUTATOR_FUZZER_LIBRARIES}
${EXPAT_LIBRARIES})
set_property(TARGET expat_example
PROPERTY COMPILE_FLAGS ${FUZZING_FLAGS})
diff --git a/examples/libfuzzer/CMakeLists.txt b/examples/libfuzzer/CMakeLists.txt
index 18eaf89..dc39177 100644
--- a/examples/libfuzzer/CMakeLists.txt
+++ b/examples/libfuzzer/CMakeLists.txt
@@ -33,7 +33,8 @@
add_executable(${fuzzer} ${fuzzer}.cc)
target_link_libraries(${fuzzer}
fuzzer-example-proto
- protobuf-mutator-libfuzzer)
+ protobuf-mutator-libfuzzer
+ ${LIB_PROTO_MUTATOR_FUZZER_LIBRARIES})
set_property(TARGET ${fuzzer}
PROPERTY COMPILE_FLAGS ${FUZZING_FLAGS})
set_property(TARGET ${fuzzer}
diff --git a/examples/libxml2/CMakeLists.txt b/examples/libxml2/CMakeLists.txt
index 7097303..cf9f8a2 100644
--- a/examples/libxml2/CMakeLists.txt
+++ b/examples/libxml2/CMakeLists.txt
@@ -19,6 +19,7 @@
libxml2_example.cc)
target_link_libraries(libxml2_example
protobuf-mutator-xml
+ ${LIB_PROTO_MUTATOR_FUZZER_LIBRARIES}
${LIBXML2_LIBRARIES}
${ZLIB_LIBRARIES}
${LIBLZMA_LIBRARIES})