You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 1.2 kB

123456789101112131415161718192021222324252627282930313233343536
  1. # https://cmake.org/cmake/help/v3.0/command/add_test.html
  2. # https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
  3. enable_language(CXX)
  4. set (CMAKE_CXX_STANDARD 11)
  5. include_directories(PUBLIC ${CMAKE_SOURCE_DIR})
  6. include_directories(PUBLIC ${PROJECT_BINARY_DIR})
  7. # This sets up either the standalone runner or the user supplied libfuzzing
  8. # engine. We're using the standalone runner for unit testing alone at the
  9. # moment to make the sure the fuzzer builds and runs appropriately.
  10. if(DEFINED ENV{LIB_FUZZING_ENGINE})
  11. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{LIB_FUZZING_ENGINE}")
  12. set(FUZZING_ENGINE "")
  13. else()
  14. add_library(fuzzing_engine standalone_runner.cc)
  15. set(FUZZING_ENGINE fuzzing_engine)
  16. endif()
  17. foreach(FUZZERNAME
  18. tokener_parse_ex_fuzzer)
  19. add_executable(${FUZZERNAME} ${FUZZERNAME}.cc)
  20. target_link_libraries(${FUZZERNAME}
  21. json-c
  22. ${FUZZING_ENGINE})
  23. file(GLOB TESTFILES "${CMAKE_SOURCE_DIR}/fuzz/tests/*.json")
  24. foreach(TESTFILE ${TESTFILES})
  25. get_filename_component(FILENAME ${TESTFILE} NAME_WE)
  26. add_test(NAME test_${FUZZERNAME}_${FILENAME}
  27. COMMAND ${CMAKE_BINARY_DIR}/fuzz/${FUZZERNAME}
  28. ${TESTFILE})
  29. endforeach(TESTFILE)
  30. endforeach(FUZZERNAME)