go-libwebp

Experimental translation from libwebp to Go source.
Log | Files | Refs | README | LICENSE

CMakeLists.txt (2414B)


      1 #  Copyright (c) 2024 Google LLC
      2 #
      3 #  Use of this source code is governed by a BSD-style license
      4 #  that can be found in the LICENSE file in the root of the source
      5 #  tree. An additional intellectual property rights grant can be found
      6 #  in the file PATENTS.  All contributing project authors may
      7 #  be found in the AUTHORS file in the root of the source tree.
      8 
      9 # Adds a fuzztest from file TEST_NAME.cc located in the gtest folder. Extra
     10 # arguments are considered as extra source files.
     11 
     12 if(CMAKE_VERSION VERSION_LESS "3.19.0")
     13   return()
     14 endif()
     15 
     16 macro(add_webp_fuzztest TEST_NAME)
     17   add_executable(${TEST_NAME} ${TEST_NAME}.cc)
     18   # FuzzTest bundles GoogleTest so no need to link to gtest libraries.
     19   target_link_libraries(${TEST_NAME} PRIVATE fuzz_utils webp ${ARGN})
     20   target_include_directories(${TEST_NAME} PRIVATE ${CMAKE_BINARY_DIR}/src)
     21   link_fuzztest(${TEST_NAME})
     22   add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
     23   set_property(
     24     TEST ${TEST_NAME}
     25     PROPERTY ENVIRONMENT "TEST_DATA_DIRS=${CMAKE_CURRENT_SOURCE_DIR}/data/")
     26 endmacro()
     27 
     28 enable_language(CXX)
     29 set(CMAKE_CXX_STANDARD 17)
     30 set(CMAKE_CXX_STANDARD_REQUIRED ON)
     31 
     32 include(FetchContent)
     33 
     34 set(FETCHCONTENT_QUIET FALSE)
     35 set(fuzztest_SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/fuzztest-src)
     36 FetchContent_Declare(
     37   fuzztest
     38   GIT_REPOSITORY https://github.com/google/fuzztest.git
     39   GIT_TAG 078ea0871cc96d3a69bad406577f176a4fa14ae9
     40   GIT_PROGRESS TRUE
     41   PATCH_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/patch.sh)
     42 
     43 FetchContent_MakeAvailable(fuzztest)
     44 
     45 fuzztest_setup_fuzzing_flags()
     46 
     47 add_library(fuzz_utils fuzz_utils.h fuzz_utils.cc img_alpha.h img_grid.h
     48                        img_peak.h)
     49 target_link_libraries(fuzz_utils PUBLIC webpdecoder)
     50 link_fuzztest(fuzz_utils)
     51 
     52 add_webp_fuzztest(advanced_api_fuzzer webpdecode webpdspdecode webputilsdecode)
     53 add_webp_fuzztest(dec_fuzzer)
     54 add_webp_fuzztest(enc_dec_fuzzer)
     55 add_webp_fuzztest(enc_fuzzer imagedec)
     56 add_webp_fuzztest(huffman_fuzzer webpdecode webpdspdecode webputilsdecode)
     57 add_webp_fuzztest(imageio_fuzzer imagedec)
     58 add_webp_fuzztest(simple_api_fuzzer)
     59 
     60 if(WEBP_BUILD_LIBWEBPMUX)
     61   add_webp_fuzztest(animation_api_fuzzer webpdemux)
     62   add_webp_fuzztest(animdecoder_fuzzer imageioutil webpdemux)
     63   add_webp_fuzztest(animencoder_fuzzer libwebpmux)
     64   add_webp_fuzztest(mux_demux_api_fuzzer libwebpmux webpdemux)
     65 endif()
     66 
     67 if(WEBP_BUILD_WEBPINFO)
     68   add_webp_fuzztest(webp_info_fuzzer imageioutil)
     69 endif()