blob: a0eba0fd0f8e57f6857418bc0fd3aa998642c3d5 [file] [log] [blame]
Paul Elliott4068c7e2023-12-15 17:14:34 +00001find_package(Threads)
2
Philippe Antoine72333522018-05-03 16:40:24 +02003set(libs
Raef Coles995c66f2020-10-13 16:30:41 +01004 ${mbedtls_target}
Paul Elliott4068c7e2023-12-15 17:14:34 +00005 ${CMAKE_THREAD_LIBS_INIT}
Philippe Antoine72333522018-05-03 16:40:24 +02006)
7
Philippe Antoine81496272019-06-04 14:47:58 +02008find_library(FUZZINGENGINE_LIB FuzzingEngine)
Ronald Cronbfd45f12020-06-05 11:15:31 +02009if(FUZZINGENGINE_LIB)
Philippe Antoine81496272019-06-04 14:47:58 +020010 project(fuzz CXX)
Philippe Antoine81496272019-06-04 14:47:58 +020011endif()
Ronald Cronbfd45f12020-06-05 11:15:31 +020012
13set(executables_no_common_c
Ronald Cronbfd45f12020-06-05 11:15:31 +020014 fuzz_pubkey
15 fuzz_x509crl
16 fuzz_x509crt
17 fuzz_x509csr
Nayna Jain106a0af2020-11-03 21:07:21 +000018 fuzz_pkcs7
Ronald Cronbfd45f12020-06-05 11:15:31 +020019)
20
21set(executables_with_common_c
Manuel Pégourié-Gonnard6ff9ef52021-06-16 12:37:10 +020022 fuzz_privkey
Ronald Cronbfd45f12020-06-05 11:15:31 +020023 fuzz_client
24 fuzz_dtlsclient
25 fuzz_dtlsserver
26 fuzz_server
27)
28
29foreach(exe IN LISTS executables_no_common_c executables_with_common_c)
30
David Browna8e309e2020-11-18 15:07:24 -070031 set(exe_sources ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
32 if(NOT FUZZINGENGINE_LIB)
33 list(APPEND exe_sources onefile.c)
Ronald Cronbfd45f12020-06-05 11:15:31 +020034 endif()
35
36 # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3
37 list(FIND executables_with_common_c ${exe} exe_index)
David Browna8e309e2020-11-18 15:07:24 -070038 if(${exe_index} GREATER -1)
39 list(APPEND exe_sources common.c)
40 endif()
41
42 add_executable(${exe} ${exe_sources})
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010043 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
David Browna8e309e2020-11-18 15:07:24 -070044
45 if (NOT FUZZINGENGINE_LIB)
46 target_link_libraries(${exe} ${libs})
47 else()
48 target_link_libraries(${exe} ${libs} FuzzingEngine)
49 SET_TARGET_PROPERTIES(${exe} PROPERTIES LINKER_LANGUAGE CXX)
Ronald Cronbfd45f12020-06-05 11:15:31 +020050 endif()
51
52endforeach()