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