blob: c389029bca9326be86ac7b97b3899a6659d1ece8 [file] [log] [blame]
Philippe Antoine72333522018-05-03 16:40:24 +02001set(libs
Raef Coles995c66f2020-10-13 16:30:41 +01002 ${mbedtls_target}
Paul Elliott4068c7e2023-12-15 17:14:34 +00003 ${CMAKE_THREAD_LIBS_INIT}
Philippe Antoine72333522018-05-03 16:40:24 +02004)
5
Philippe Antoine81496272019-06-04 14:47:58 +02006find_library(FUZZINGENGINE_LIB FuzzingEngine)
Ronald Cronbfd45f12020-06-05 11:15:31 +02007if(FUZZINGENGINE_LIB)
Philippe Antoine81496272019-06-04 14:47:58 +02008 project(fuzz CXX)
Philippe Antoine81496272019-06-04 14:47:58 +02009endif()
Ronald Cronbfd45f12020-06-05 11:15:31 +020010
11set(executables_no_common_c
Ronald Cronbfd45f12020-06-05 11:15:31 +020012 fuzz_pubkey
13 fuzz_x509crl
14 fuzz_x509crt
15 fuzz_x509csr
Nayna Jain106a0af2020-11-03 21:07:21 +000016 fuzz_pkcs7
Ronald Cronbfd45f12020-06-05 11:15:31 +020017)
18
19set(executables_with_common_c
Manuel Pégourié-Gonnard6ff9ef52021-06-16 12:37:10 +020020 fuzz_privkey
Ronald Cronbfd45f12020-06-05 11:15:31 +020021 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
David Browna8e309e2020-11-18 15:07:24 -070029 set(exe_sources ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
30 if(NOT FUZZINGENGINE_LIB)
31 list(APPEND exe_sources onefile.c)
Ronald Cronbfd45f12020-06-05 11:15:31 +020032 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)
David Browna8e309e2020-11-18 15:07:24 -070036 if(${exe_index} GREATER -1)
37 list(APPEND exe_sources common.c)
38 endif()
39
40 add_executable(${exe} ${exe_sources})
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010041 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
David Browna8e309e2020-11-18 15:07:24 -070042
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)
Ronald Cronbfd45f12020-06-05 11:15:31 +020048 endif()
49
50endforeach()