Skip to content

Commit 76d0da4

Browse files
committed
Ensure CFLAGS and CXXFLAGS are passed through to CMake
1 parent 956edd9 commit 76d0da4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ add_dependencies(curl_external nghttp2_external ${OPENSSL_DEP} zlib_external)
236236

237237
# Now it's time for the main targets!
238238
#
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+
239243
# Paths to curl install (adjust as needed)
240244
set(CURL_INCLUDE_DIRS
241245
${CURL_INSTALL_DIR}/include
@@ -265,7 +269,7 @@ endif()
265269

266270
# Common sources and flags
267271
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)
269273
set(COMMON_LINK_LIBS
270274
${CURL_LIB_DIR}/libcurl.a
271275
${NGHTTP2_STATIC_LIB}
@@ -275,20 +279,23 @@ set(COMMON_LINK_LIBS
275279
pthread
276280
m
277281
)
282+
set(COMMON_LINK_OPTIONS ${LIB_FUZZING_ENGINE_FLAG})
278283

279284
# Helper macro to define a fuzzer target
280285
macro(add_curl_fuzzer name proto)
281286
add_executable(${name} ${COMMON_SOURCES})
282287
target_compile_options(${name} PRIVATE ${COMMON_FLAGS} -DFUZZ_PROTOCOLS_${proto})
283288
target_include_directories(${name} PRIVATE ${CURL_INCLUDE_DIRS})
284289
target_link_libraries(${name} PRIVATE ${COMMON_LINK_LIBS} ${LIB_FUZZING_ENGINE})
290+
target_link_options(${name} PRIVATE ${COMMON_LINK_OPTIONS})
285291
endmacro()
286292

287293
# Main fuzzer (all protocols)
288294
add_executable(curl_fuzzer ${COMMON_SOURCES})
289295
target_compile_options(curl_fuzzer PRIVATE ${COMMON_FLAGS} -DFUZZ_PROTOCOLS_ALL)
290296
target_include_directories(curl_fuzzer PRIVATE ${CURL_INCLUDE_DIRS})
291297
target_link_libraries(curl_fuzzer PRIVATE ${COMMON_LINK_LIBS} ${LIB_FUZZING_ENGINE})
298+
target_link_options(curl_fuzzer PRIVATE ${COMMON_LINK_OPTIONS})
292299

293300
# Protocol-specific fuzzers
294301
add_curl_fuzzer(curl_fuzzer_dict DICT)
@@ -311,18 +318,21 @@ add_executable(curl_fuzzer_bufq fuzz_bufq.cc)
311318
target_compile_options(curl_fuzzer_bufq PRIVATE ${COMMON_FLAGS})
312319
target_include_directories(curl_fuzzer_bufq PRIVATE ${CURL_INCLUDE_DIRS})
313320
target_link_libraries(curl_fuzzer_bufq PRIVATE ${COMMON_LINK_LIBS})
321+
target_link_options(curl_fuzzer_bufq PRIVATE ${COMMON_LINK_OPTIONS})
314322

315323
# URL fuzzer
316324
add_executable(fuzz_url fuzz_url.cc)
317325
target_compile_options(fuzz_url PRIVATE ${COMMON_FLAGS})
318326
target_include_directories(fuzz_url PRIVATE ${CURL_INCLUDE_DIRS})
319327
target_link_libraries(fuzz_url PRIVATE ${COMMON_LINK_LIBS})
328+
target_link_options(fuzz_url PRIVATE ${COMMON_LINK_OPTIONS})
320329

321330
# Unit test fuzzer
322331
add_executable(curl_fuzzer_fnmatch fuzz_fnmatch.cc)
323332
target_compile_options(curl_fuzzer_fnmatch PRIVATE ${COMMON_FLAGS})
324333
target_include_directories(curl_fuzzer_fnmatch PRIVATE ${CURL_INCLUDE_DIRS})
325334
target_link_libraries(curl_fuzzer_fnmatch PRIVATE ${COMMON_LINK_LIBS})
335+
target_link_options(curl_fuzzer_fnmatch PRIVATE ${COMMON_LINK_OPTIONS})
326336

327337
# Add dependencies so fuzzers build after curl
328338
add_dependencies(curl_fuzzer curl_external)

ossfuzz.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ scripts/create_zip.sh
5353
# Copy the fuzzers over.
5454
for TARGET in $FUZZ_TARGETS
5555
do
56-
cp -v ${TARGET} ${TARGET}_seed_corpus.zip $OUT/
56+
cp -v build/${TARGET} ${TARGET}_seed_corpus.zip $OUT/
5757
done
5858

5959
# Copy dictionary and options file to $OUT.

0 commit comments

Comments
 (0)