xref: /btstack/test/fuzz/CMakeLists.txt (revision eddac6153de8d96d8ed96881eb05d000d35be81b)
11f805efeSMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
21f805efeSMatthias Ringwald
31f805efeSMatthias Ringwaldset(CMAKE_C_COMPILER clang)
41f805efeSMatthias Ringwaldset(CMAKE_CXX_COMPILER clang)
51f805efeSMatthias Ringwald
61f805efeSMatthias Ringwaldproject(BTstack)
71f805efeSMatthias Ringwald
81f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
91f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include)
101f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include)
111f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/md5)
121f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
131f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
141f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/lwip/core/src/include)
151f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/lwip/dhcp-server)
161f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
171f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/yxml)
181f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/tinydir)
191f805efeSMatthias Ringwaldinclude_directories(../../src)
201f805efeSMatthias Ringwaldinclude_directories(../../platform/posix)
211f805efeSMatthias Ringwaldinclude_directories(../../platform/embedded)
221f805efeSMatthias Ringwaldinclude_directories(../../platform/lwip)
231f805efeSMatthias Ringwaldinclude_directories(../../platform/lwip/port)
241f805efeSMatthias Ringwaldinclude_directories(.)
251f805efeSMatthias Ringwald
261f805efeSMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c" "../../example/sco_demo_util.c")
271f805efeSMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
281f805efeSMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
291f805efeSMatthias Ringwaldfile(GLOB SOURCES_CLASSIC   "../../src/classic/*.c")
301f805efeSMatthias Ringwaldfile(GLOB SOURCES_MESH      "../../src/mesh/*.c")
311f805efeSMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c")
321f805efeSMatthias Ringwaldfile(GLOB SOURCES_MD5       "../../3rd-party/md5/md5.c")
331f805efeSMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
341f805efeSMatthias Ringwaldfile(GLOB SOURCES_YXML      "../../3rd-party/yxml/yxml.c")
351f805efeSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
361f805efeSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
371f805efeSMatthias Ringwaldfile(GLOB SOURCES_POSIX     "../../platform/posix/*.c")
381f805efeSMatthias Ringwaldfile(GLOB SOURCES_LIBUSB    "../../port/libusb/*.c" "../../platform/libusb/*.c")
391f805efeSMatthias Ringwald
401f805efeSMatthias Ringwaldset(LWIP_CORE_SRC
411f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/def.c
421f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/inet_chksum.c
431f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/init.c
441f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ip.c
451f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/mem.c
461f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/memp.c
471f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/netif.c
481f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/pbuf.c
491f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/tcp.c
501f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/tcp_in.c
511f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/tcp_out.c
521f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/timeouts.c
531f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/udp.c
541f805efeSMatthias Ringwald        )
551f805efeSMatthias Ringwaldset (LWIP_IPV4_SRC
561f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ipv4/acd.c
571f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ipv4/dhcp.c
581f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ipv4/etharp.c
591f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ipv4/icmp.c
601f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ipv4/ip4.c
611f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ipv4/ip4_addr.c
621f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/core/ipv4/ip4_frag.c
631f805efeSMatthias Ringwald        )
641f805efeSMatthias Ringwaldset (LWIP_NETIF_SRC
651f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/netif/ethernet.c
661f805efeSMatthias Ringwald        )
671f805efeSMatthias Ringwaldset (LWIP_HTTPD
681f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c
691f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/apps/http/fs.c
701f805efeSMatthias Ringwald        ../../3rd-party/lwip/core/src/apps/http/httpd.c
711f805efeSMatthias Ringwald        )
721f805efeSMatthias Ringwaldset (LWIP_DHCPD
731f805efeSMatthias Ringwald        ../../3rd-party/lwip/dhcp-server/dhserver.c
741f805efeSMatthias Ringwald        )
751f805efeSMatthias Ringwaldset (LWIP_PORT
761f805efeSMatthias Ringwald        ../../platform/lwip/port/sys_arch.c
771f805efeSMatthias Ringwald        ../../platform/lwip/bnep_lwip.c
781f805efeSMatthias Ringwald        )
791f805efeSMatthias Ringwald
801f805efeSMatthias Ringwaldset (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT})
811f805efeSMatthias Ringwald
821f805efeSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
831f805efeSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
841f805efeSMatthias Ringwald
851f805efeSMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c")
861f805efeSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF})
871f805efeSMatthias Ringwald
881f805efeSMatthias Ringwaldset(SOURCES
891f805efeSMatthias Ringwald        ${SOURCES_MD5}
901f805efeSMatthias Ringwald        ${SOURCES_YXML}
911f805efeSMatthias Ringwald        ${SOURCES_BLUEDROID}
921f805efeSMatthias Ringwald        ${SOURCES_POSIX}
931f805efeSMatthias Ringwald        ${SOURCES_RIJNDAEL}
941f805efeSMatthias Ringwald        ${SOURCES_SRC}
951f805efeSMatthias Ringwald        ${SOURCES_BLE}
961f805efeSMatthias Ringwald        ${SOURCES_GATT}
971f805efeSMatthias Ringwald        ${SOURCES_MESH}
981f805efeSMatthias Ringwald        ${SOURCES_CLASSIC}
991f805efeSMatthias Ringwald        ${SOURCES_UECC}
1001f805efeSMatthias Ringwald        ${SOURCES_HXCMOD}
1011f805efeSMatthias Ringwald        )
1021f805efeSMatthias Ringwaldlist(SORT SOURCES)
1031f805efeSMatthias Ringwald
104*eddac615SMatthias Ringwaldadd_compile_options( -fsanitize=fuzzer,address -fprofile-instr-generate -fcoverage-mapping)
105*eddac615SMatthias Ringwaldadd_link_options( -fsanitize=fuzzer,address)
106*eddac615SMatthias Ringwald
1071f805efeSMatthias Ringwald# create static lib
1081f805efeSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
1091f805efeSMatthias Ringwald
1101f805efeSMatthias Ringwald# create fuzz targets
1111f805efeSMatthias Ringwaldfile(GLOB TARGETS_C "fuzz_*.c")
1121f805efeSMatthias Ringwald
1131f805efeSMatthias Ringwald# create targets
1141f805efeSMatthias Ringwaldforeach(TARGET_FILE ${TARGETS_C})
1151f805efeSMatthias Ringwald    get_filename_component(EXAMPLE ${TARGET_FILE} NAME_WE)
1161f805efeSMatthias Ringwald    add_executable(${EXAMPLE} ${TARGET_FILE} )
1171f805efeSMatthias Ringwald    target_link_libraries(${EXAMPLE} btstack)
1181f805efeSMatthias Ringwaldendforeach(TARGET_FILE)
119