blob: d5995aa194b79beca0fd59fa569771b0243a5476 [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_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)
Gilles Peskine5dab92e2024-09-14 12:13:16 +020017add_dependencies(${programs_target} ${executables_no_common_c})
Ronald Cronbfd45f12020-06-05 11:15:31 +020018
19set(executables_with_common_c
20 fuzz_client
21 fuzz_dtlsclient
22 fuzz_dtlsserver
23 fuzz_server
24)
Gilles Peskine5dab92e2024-09-14 12:13:16 +020025add_dependencies(${programs_target} ${executables_with_common_c})
Ronald Cronbfd45f12020-06-05 11:15:31 +020026
27foreach(exe IN LISTS executables_no_common_c executables_with_common_c)
28
Ronald Crond5331ff2024-11-22 19:09:27 +010029 set(exe_sources
30 ${exe}.c
31 $<TARGET_OBJECTS:mbedtls_test_helpers>
Ronald Cron5096b4c2024-12-06 10:09:33 +010032 $<TARGET_OBJECTS:mbedtls_test>)
David Browna8e309e2020-11-18 15:07:24 -070033 if(NOT FUZZINGENGINE_LIB)
Ben Taylor60a5b322025-06-04 10:45:15 +010034 list(APPEND exe_sources ${MBEDTLS_DIR}/tf-psa-crypto/programs/fuzz/fuzz_onefile.c)
Ronald Cronbfd45f12020-06-05 11:15:31 +020035 endif()
36
37 # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3
38 list(FIND executables_with_common_c ${exe} exe_index)
David Browna8e309e2020-11-18 15:07:24 -070039 if(${exe_index} GREATER -1)
Ben Taylorc7c480a2025-06-04 08:29:58 +010040 list(APPEND exe_sources ${MBEDTLS_DIR}/tf-psa-crypto/programs/fuzz/fuzz_common.c)
David Browna8e309e2020-11-18 15:07:24 -070041 endif()
42
43 add_executable(${exe} ${exe_sources})
Ronald Cronb2478982024-10-07 16:17:07 +020044 set_base_compile_options(${exe})
David Horstmannd2cabf22024-11-04 13:52:37 +000045 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include
Ben Taylorc7c480a2025-06-04 08:29:58 +010046 ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/programs/fuzz/
David Horstmannd2cabf22024-11-04 13:52:37 +000047 ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
David Browna8e309e2020-11-18 15:07:24 -070048
49 if (NOT FUZZINGENGINE_LIB)
50 target_link_libraries(${exe} ${libs})
51 else()
52 target_link_libraries(${exe} ${libs} FuzzingEngine)
53 SET_TARGET_PROPERTIES(${exe} PROPERTIES LINKER_LANGUAGE CXX)
Ronald Cronbfd45f12020-06-05 11:15:31 +020054 endif()
55
56endforeach()