CMakeLists.txt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. set(libs
  2. ${mbedtls_target}
  3. )
  4. find_library(FUZZINGENGINE_LIB FuzzingEngine)
  5. if(FUZZINGENGINE_LIB)
  6. project(fuzz CXX)
  7. endif()
  8. set(executables_no_common_c
  9. fuzz_pubkey
  10. fuzz_x509crl
  11. fuzz_x509crt
  12. fuzz_x509csr
  13. fuzz_pkcs7
  14. )
  15. set(executables_with_common_c
  16. fuzz_privkey
  17. fuzz_client
  18. fuzz_dtlsclient
  19. fuzz_dtlsserver
  20. fuzz_server
  21. )
  22. foreach(exe IN LISTS executables_no_common_c executables_with_common_c)
  23. set(exe_sources ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
  24. if(NOT FUZZINGENGINE_LIB)
  25. list(APPEND exe_sources onefile.c)
  26. endif()
  27. # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3
  28. list(FIND executables_with_common_c ${exe} exe_index)
  29. if(${exe_index} GREATER -1)
  30. list(APPEND exe_sources common.c)
  31. endif()
  32. add_executable(${exe} ${exe_sources})
  33. target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
  34. if (NOT FUZZINGENGINE_LIB)
  35. target_link_libraries(${exe} ${libs})
  36. else()
  37. target_link_libraries(${exe} ${libs} FuzzingEngine)
  38. SET_TARGET_PROPERTIES(${exe} PROPERTIES LINKER_LANGUAGE CXX)
  39. endif()
  40. endforeach()