• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if(NOT ENABLE_STATIC)
2  message(FATAL_ERROR "Fuzz targets require static libraries.")
3endif()
4if(NOT WITH_TURBOJPEG)
5  message(FATAL_ERROR "Fuzz targets require the TurboJPEG API library.")
6endif()
7
8set(FUZZ_BINDIR "" CACHE PATH
9  "Directory into which fuzz targets should be installed")
10if(NOT FUZZ_BINDIR)
11  message(FATAL_ERROR "FUZZ_BINDIR must be specified.")
12endif()
13message(STATUS "FUZZ_BINDIR = ${FUZZ_BINDIR}")
14
15set(FUZZ_LIBRARY "" CACHE STRING
16  "Path to fuzzer library or flags necessary to link with it")
17if(NOT FUZZ_LIBRARY)
18  message(FATAL_ERROR "FUZZ_LIBRARY must be specified.")
19endif()
20message(STATUS "FUZZ_LIBRARY = ${FUZZ_LIBRARY}")
21
22enable_language(CXX)
23
24set(EFFECTIVE_CXX_FLAGS
25  "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
26message(STATUS "C++ Compiler flags = ${EFFECTIVE_CXX_FLAGS}")
27
28add_executable(cjpeg_fuzzer${FUZZER_SUFFIX} cjpeg.cc ../cdjpeg.c ../rdbmp.c
29  ../rdgif.c ../rdppm.c ../rdswitch.c ../rdtarga.c)
30set_property(TARGET cjpeg_fuzzer${FUZZER_SUFFIX} PROPERTY COMPILE_FLAGS
31  ${COMPILE_FLAGS})
32target_link_libraries(cjpeg_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY} jpeg-static)
33install(TARGETS cjpeg_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
34  ${FUZZ_BINDIR})
35
36macro(add_fuzz_target target source_file)
37  add_executable(${target}_fuzzer${FUZZER_SUFFIX} ${source_file})
38  target_link_libraries(${target}_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY}
39    turbojpeg-static)
40  install(TARGETS ${target}_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
41    ${FUZZ_BINDIR})
42endmacro()
43
44add_fuzz_target(compress compress.cc)
45
46add_fuzz_target(compress_yuv compress_yuv.cc)
47
48# NOTE: This target is named libjpeg_turbo_fuzzer instead of decompress_fuzzer
49# in order to preserve the corpora from Google's OSS-Fuzz target for
50# libjpeg-turbo, which this target replaces.
51add_fuzz_target(libjpeg_turbo decompress.cc)
52
53add_fuzz_target(decompress_yuv decompress_yuv.cc)
54
55add_fuzz_target(transform transform.cc)
56