@@ -236,6 +236,10 @@ add_dependencies(curl_external nghttp2_external ${OPENSSL_DEP} zlib_external)
236
236
237
237
# Now it's time for the main targets!
238
238
#
239
+ # Read environment variables for compiler flags
240
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS} " )
241
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXXFLAGS} " )
242
+
239
243
# Paths to curl install (adjust as needed)
240
244
set (CURL_INCLUDE_DIRS
241
245
${CURL_INSTALL_DIR} /include
@@ -265,7 +269,7 @@ endif()
265
269
266
270
# Common sources and flags
267
271
set (COMMON_SOURCES curl_fuzzer.cc curl_fuzzer_tlv.cc curl_fuzzer_callback.cc )
268
- set (COMMON_FLAGS -g -DCURL_DISABLE_DEPRECATION ${LIB_FUZZING_ENGINE_FLAG} )
272
+ set (COMMON_FLAGS -g -DCURL_DISABLE_DEPRECATION )
269
273
set (COMMON_LINK_LIBS
270
274
${CURL_LIB_DIR} /libcurl.a
271
275
${NGHTTP2_STATIC_LIB}
@@ -275,20 +279,23 @@ set(COMMON_LINK_LIBS
275
279
pthread
276
280
m
277
281
)
282
+ set (COMMON_LINK_OPTIONS ${LIB_FUZZING_ENGINE_FLAG} )
278
283
279
284
# Helper macro to define a fuzzer target
280
285
macro (add_curl_fuzzer name proto )
281
286
add_executable (${name} ${COMMON_SOURCES} )
282
287
target_compile_options (${name} PRIVATE ${COMMON_FLAGS} -DFUZZ_PROTOCOLS_${proto} )
283
288
target_include_directories (${name} PRIVATE ${CURL_INCLUDE_DIRS} )
284
289
target_link_libraries (${name} PRIVATE ${COMMON_LINK_LIBS} ${LIB_FUZZING_ENGINE} )
290
+ target_link_options (${name} PRIVATE ${COMMON_LINK_OPTIONS} )
285
291
endmacro ()
286
292
287
293
# Main fuzzer (all protocols)
288
294
add_executable (curl_fuzzer ${COMMON_SOURCES} )
289
295
target_compile_options (curl_fuzzer PRIVATE ${COMMON_FLAGS} -DFUZZ_PROTOCOLS_ALL )
290
296
target_include_directories (curl_fuzzer PRIVATE ${CURL_INCLUDE_DIRS} )
291
297
target_link_libraries (curl_fuzzer PRIVATE ${COMMON_LINK_LIBS} ${LIB_FUZZING_ENGINE} )
298
+ target_link_options (curl_fuzzer PRIVATE ${COMMON_LINK_OPTIONS} )
292
299
293
300
# Protocol-specific fuzzers
294
301
add_curl_fuzzer (curl_fuzzer_dict DICT )
@@ -311,18 +318,21 @@ add_executable(curl_fuzzer_bufq fuzz_bufq.cc)
311
318
target_compile_options (curl_fuzzer_bufq PRIVATE ${COMMON_FLAGS} )
312
319
target_include_directories (curl_fuzzer_bufq PRIVATE ${CURL_INCLUDE_DIRS} )
313
320
target_link_libraries (curl_fuzzer_bufq PRIVATE ${COMMON_LINK_LIBS} )
321
+ target_link_options (curl_fuzzer_bufq PRIVATE ${COMMON_LINK_OPTIONS} )
314
322
315
323
# URL fuzzer
316
324
add_executable (fuzz_url fuzz_url.cc )
317
325
target_compile_options (fuzz_url PRIVATE ${COMMON_FLAGS} )
318
326
target_include_directories (fuzz_url PRIVATE ${CURL_INCLUDE_DIRS} )
319
327
target_link_libraries (fuzz_url PRIVATE ${COMMON_LINK_LIBS} )
328
+ target_link_options (fuzz_url PRIVATE ${COMMON_LINK_OPTIONS} )
320
329
321
330
# Unit test fuzzer
322
331
add_executable (curl_fuzzer_fnmatch fuzz_fnmatch.cc )
323
332
target_compile_options (curl_fuzzer_fnmatch PRIVATE ${COMMON_FLAGS} )
324
333
target_include_directories (curl_fuzzer_fnmatch PRIVATE ${CURL_INCLUDE_DIRS} )
325
334
target_link_libraries (curl_fuzzer_fnmatch PRIVATE ${COMMON_LINK_LIBS} )
335
+ target_link_options (curl_fuzzer_fnmatch PRIVATE ${COMMON_LINK_OPTIONS} )
326
336
327
337
# Add dependencies so fuzzers build after curl
328
338
add_dependencies (curl_fuzzer curl_external )
0 commit comments