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