In libjpeg-turbo 2.1.x and prior, the WITH_12BIT CMake variable was used to enable 12-bit JPEG support at compile time, because the libjpeg API library could not handle multiple JPEG data precisions at run time. The initial approach to handling multiple JPEG data precisions at run time (7fec5074f9) created a whole new API, library, and applications for 12-bit data precision, so it made sense to repurpose WITH_12BIT to allow 12-bit data precision to be disabled.e8b40f3c2bmade it so that the libjpeg API library can handle multiple JPEG data precisions at run time via a handful of straightforward API extensions. Referring to6c2bc901e2, it hasn't been possible to build libjpeg-turbo with both forward and backward libjpeg API/ABI compatibility since libjpeg-turbo 1.4.x. Thus, whereas we retain full backward API/ABI compatibility with libjpeg v6b-v8, forward libjpeg API/ABI compatibility ceased being realistic years ago, so it no longer makes sense to provide compile-time options that give a false sense of forward API/ABI compatibility by allowing some (but not all) of our libjpeg API extensions to be disabled. Such options are difficult to maintain and clutter the code with #ifdefs.
65 lines
2.3 KiB
CMake
65 lines
2.3 KiB
CMake
if(NOT ENABLE_STATIC)
|
|
message(FATAL_ERROR "Fuzz targets require static libraries.")
|
|
endif()
|
|
if(NOT WITH_TURBOJPEG)
|
|
message(FATAL_ERROR "Fuzz targets require the TurboJPEG API library.")
|
|
endif()
|
|
|
|
set(FUZZ_BINDIR "" CACHE PATH
|
|
"Directory into which fuzz targets should be installed")
|
|
if(NOT FUZZ_BINDIR)
|
|
message(FATAL_ERROR "FUZZ_BINDIR must be specified.")
|
|
endif()
|
|
message(STATUS "FUZZ_BINDIR = ${FUZZ_BINDIR}")
|
|
|
|
set(FUZZ_LIBRARY "" CACHE STRING
|
|
"Path to fuzzer library or flags necessary to link with it")
|
|
if(NOT FUZZ_LIBRARY)
|
|
message(FATAL_ERROR "FUZZ_LIBRARY must be specified.")
|
|
endif()
|
|
message(STATUS "FUZZ_LIBRARY = ${FUZZ_LIBRARY}")
|
|
|
|
enable_language(CXX)
|
|
|
|
set(EFFECTIVE_CXX_FLAGS
|
|
"${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
|
|
message(STATUS "C++ Compiler flags = ${EFFECTIVE_CXX_FLAGS}")
|
|
|
|
add_executable(cjpeg_fuzzer${FUZZER_SUFFIX} cjpeg.cc ../cdjpeg.c ../rdbmp.c
|
|
../rdgif.c ../rdppm.c ../rdswitch.c ../rdtarga.c)
|
|
set_property(TARGET cjpeg_fuzzer${FUZZER_SUFFIX} PROPERTY COMPILE_FLAGS
|
|
${COMPILE_FLAGS})
|
|
target_link_libraries(cjpeg_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY} jpeg-static)
|
|
install(TARGETS cjpeg_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
|
|
${FUZZ_BINDIR})
|
|
|
|
add_executable(cjpeg12_fuzzer${FUZZER_SUFFIX} cjpeg12.cc ../cdjpeg.c ../rdbmp.c
|
|
../rdgif.c ../rdppm.c ../rdswitch.c ../rdtarga.c)
|
|
set_property(TARGET cjpeg12_fuzzer${FUZZER_SUFFIX} PROPERTY COMPILE_FLAGS
|
|
${COMPILE_FLAGS})
|
|
target_link_libraries(cjpeg12_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY}
|
|
jpeg-static)
|
|
install(TARGETS cjpeg12_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
|
|
${FUZZ_BINDIR})
|
|
|
|
macro(add_fuzz_target target source_file)
|
|
add_executable(${target}_fuzzer${FUZZER_SUFFIX} ${source_file})
|
|
target_link_libraries(${target}_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY}
|
|
turbojpeg-static)
|
|
install(TARGETS ${target}_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
|
|
${FUZZ_BINDIR})
|
|
endmacro()
|
|
|
|
add_fuzz_target(compress compress.cc)
|
|
|
|
add_fuzz_target(compress_yuv compress_yuv.cc)
|
|
|
|
# NOTE: This target is named libjpeg_turbo_fuzzer instead of decompress_fuzzer
|
|
# in order to preserve the corpora from Google's OSS-Fuzz target for
|
|
# libjpeg-turbo, which this target replaces.
|
|
add_fuzz_target(libjpeg_turbo decompress.cc)
|
|
|
|
add_fuzz_target(decompress_yuv decompress_yuv.cc)
|
|
|
|
add_fuzz_target(transform transform.cc)
|