Skip to content

Commit 2230f60

Browse files
committed
Check to see if LIB_FUZZING_ENGINE is a flag
1 parent 3c63aa9 commit 2230f60

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,27 @@ set(CURL_LIB_DIR ${CURL_INSTALL_DIR}/lib)
241241

242242
# Fuzzing engine
243243
if (DEFINED ENV{LIB_FUZZING_ENGINE})
244-
set(LIB_FUZZING_ENGINE $ENV{LIB_FUZZING_ENGINE})
244+
# Check to see if ENV{LIB_FUZZING_ENGINE} is a file. If so, use it directly.
245+
# Otherwise, assume it's a flag to the compiler.
246+
if (EXISTS $ENV{LIB_FUZZING_ENGINE})
247+
message(STATUS "Using LIB_FUZZING_ENGINE file: $ENV{LIB_FUZZING_ENGINE}")
248+
set(LIB_FUZZING_ENGINE $ENV{LIB_FUZZING_ENGINE})
249+
set(LIB_FUZZING_ENGINE_FLAG "")
250+
else()
251+
message(STATUS "Using LIB_FUZZING_ENGINE as a compiler flag: $ENV{LIB_FUZZING_ENGINE}")
252+
set(LIB_FUZZING_ENGINE_FLAG $ENV{LIB_FUZZING_ENGINE})
253+
endif()
254+
245255
else()
246256
add_library(standaloneengine STATIC standalone_fuzz_target_runner.cc)
247257
set_target_properties(standaloneengine PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
248258
set(LIB_FUZZING_ENGINE ${CMAKE_BINARY_DIR}/libstandaloneengine.a)
259+
set(LIB_FUZZING_ENGINE_FLAG "")
249260
endif()
250261

251262
# Common sources and flags
252263
set(COMMON_SOURCES curl_fuzzer.cc curl_fuzzer_tlv.cc curl_fuzzer_callback.cc)
253-
set(COMMON_FLAGS -g -DCURL_DISABLE_DEPRECATION)
264+
set(COMMON_FLAGS -g -DCURL_DISABLE_DEPRECATION ${LIB_FUZZING_ENGINE_FLAG})
254265
set(COMMON_LINK_LIBS
255266
${CURL_LIB_DIR}/libcurl.a
256267
${NGHTTP2_STATIC_LIB}

0 commit comments

Comments
 (0)