build: only build the fuzzer when appropriate

This is a test binary, only build it if testing is enabled.
This commit is contained in:
Saleem Abdulrasool
2024-01-04 15:27:11 -08:00
parent 8b51fc28d0
commit 4fe1fd64f8
2 changed files with 12 additions and 9 deletions

View File

@@ -176,12 +176,3 @@ endif()
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
if(CMARK_LIB_FUZZER)
add_executable(cmark-fuzz ../test/cmark-fuzz.c ${LIBRARY_SOURCES})
target_link_libraries(cmark-fuzz "${CMAKE_LIB_FUZZER_PATH}")
# cmark is written in C but the libFuzzer runtime is written in C++ which
# needs to link against the C++ runtime.
set_target_properties(cmark-fuzz PROPERTIES
LINKER_LANGUAGE CXX)
endif()

View File

@@ -92,3 +92,15 @@ else(Python3_Interpreter_FOUND)
message(WARNING "A python 3 interpreter is required to run the spec tests")
endif(Python3_Interpreter_FOUND)
if(CMARK_LIB_FUZZER)
add_executable(cmark-fuzz cmark-fuzz.c)
target_link_libraries(cmark-fuzz PRIVATE
libcmark-gfm_static
"${CMAKE_LIB_FUZZER_PATH}")
# cmark is written in C but the libFuzzer runtime is written in C++ which
# needs to link against the C++ runtime.
set_target_properties(cmark-fuzz PROPERTIES
LINKER_LANGUAGE CXX)
endif()