blob: c7fcd356bcd7ba754d378d92920a65d5df85f7ec [file] [log] [blame]
Philippe Antoine72333522018-05-03 16:40:24 +02001set(libs
Raef Coles995c66f2020-10-13 16:30:41 +01002 ${mbedtls_target}
Philippe Antoine72333522018-05-03 16:40:24 +02003)
4
Philippe Antoine81496272019-06-04 14:47:58 +02005find_library(FUZZINGENGINE_LIB FuzzingEngine)
Ronald Cronbfd45f12020-06-05 11:15:31 +02006if(FUZZINGENGINE_LIB)
Philippe Antoine81496272019-06-04 14:47:58 +02007 project(fuzz CXX)
Philippe Antoine81496272019-06-04 14:47:58 +02008endif()
Ronald Cronbfd45f12020-06-05 11:15:31 +02009
10set(executables_no_common_c
Ronald Cronbfd45f12020-06-05 11:15:31 +020011 fuzz_pubkey
12 fuzz_x509crl
13 fuzz_x509crt
14 fuzz_x509csr
15)
16
17set(executables_with_common_c
Manuel Pégourié-Gonnard6ff9ef52021-06-16 12:37:10 +020018 fuzz_privkey
Ronald Cronbfd45f12020-06-05 11:15:31 +020019 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
David Browna8e309e2020-11-18 15:07:24 -070027 set(exe_sources ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
28 if(NOT FUZZINGENGINE_LIB)
29 list(APPEND exe_sources onefile.c)
Ronald Cronbfd45f12020-06-05 11:15:31 +020030 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)
David Browna8e309e2020-11-18 15:07:24 -070034 if(${exe_index} GREATER -1)
35 list(APPEND exe_sources common.c)
36 endif()
37
38 add_executable(${exe} ${exe_sources})
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010039 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
David Browna8e309e2020-11-18 15:07:24 -070040
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)
Ronald Cronbfd45f12020-06-05 11:15:31 +020046 endif()
47
48endforeach()