xref: /aosp_15_r20/external/mbedtls/programs/fuzz/CMakeLists.txt (revision 62c56f9862f102b96d72393aff6076c951fb8148)
1set(libs
2    ${mbedtls_target}
3)
4
5find_library(FUZZINGENGINE_LIB FuzzingEngine)
6if(FUZZINGENGINE_LIB)
7    project(fuzz CXX)
8endif()
9
10set(executables_no_common_c
11    fuzz_pubkey
12    fuzz_x509crl
13    fuzz_x509crt
14    fuzz_x509csr
15    fuzz_pkcs7
16)
17
18set(executables_with_common_c
19    fuzz_privkey
20    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
28    set(exe_sources ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
29    if(NOT FUZZINGENGINE_LIB)
30        list(APPEND exe_sources onefile.c)
31    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)
35    if(${exe_index} GREATER -1)
36        list(APPEND exe_sources common.c)
37    endif()
38
39    add_executable(${exe} ${exe_sources})
40    target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
41
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)
47    endif()
48
49endforeach()
50