blob: 7747744cd116cf821f1a2c037c04da7416a45dfa [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
Nayna Jain106a0af2020-11-03 21:07:21 +000015 fuzz_pkcs7
Ronald Cronbfd45f12020-06-05 11:15:31 +020016)
17
18set(executables_with_common_c
Manuel Pégourié-Gonnard6ff9ef52021-06-16 12:37:10 +020019 fuzz_privkey
Ronald Cronbfd45f12020-06-05 11:15:31 +020020 fuzz_client
21 fuzz_dtlsclient
22 fuzz_dtlsserver
23 fuzz_server
24)
25
26foreach(exe IN LISTS executables_no_common_c executables_with_common_c)
27
David Browna8e309e2020-11-18 15:07:24 -070028 set(exe_sources ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
29 if(NOT FUZZINGENGINE_LIB)
30 list(APPEND exe_sources onefile.c)
Ronald Cronbfd45f12020-06-05 11:15:31 +020031 endif()
32
33 # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3
34 list(FIND executables_with_common_c ${exe} exe_index)
David Browna8e309e2020-11-18 15:07:24 -070035 if(${exe_index} GREATER -1)
36 list(APPEND exe_sources common.c)
37 endif()
38
39 add_executable(${exe} ${exe_sources})
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010040 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
David Browna8e309e2020-11-18 15:07:24 -070041
42 if (NOT FUZZINGENGINE_LIB)
43 target_link_libraries(${exe} ${libs})
44 else()
45 target_link_libraries(${exe} ${libs} FuzzingEngine)
46 SET_TARGET_PROPERTIES(${exe} PROPERTIES LINKER_LANGUAGE CXX)
Ronald Cronbfd45f12020-06-05 11:15:31 +020047 endif()
48
49endforeach()