11f805efeSMatthias Ringwaldcmake_minimum_required (VERSION 3.5) 21f805efeSMatthias Ringwald 31f805efeSMatthias Ringwaldset(CMAKE_C_COMPILER clang) 41f805efeSMatthias Ringwaldset(CMAKE_CXX_COMPILER clang) 51f805efeSMatthias Ringwald 6*de36a6ebSMatthias Ringwaldproject(BTstack-Fuzzer) 71f805efeSMatthias Ringwald 868894c74SMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..) 968894c74SMatthias Ringwald 101f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 111f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include) 121f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include) 131f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/md5) 141faf2c16SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 151f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 161f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 171f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/lwip/core/src/include) 181f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/lwip/dhcp-server) 191f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 201f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/yxml) 211f805efeSMatthias Ringwaldinclude_directories(../../3rd-party/tinydir) 221f805efeSMatthias Ringwaldinclude_directories(../../src) 231f805efeSMatthias Ringwaldinclude_directories(../../platform/posix) 241f805efeSMatthias Ringwaldinclude_directories(../../platform/embedded) 251f805efeSMatthias Ringwaldinclude_directories(../../platform/lwip) 261f805efeSMatthias Ringwaldinclude_directories(../../platform/lwip/port) 271f805efeSMatthias Ringwaldinclude_directories(.) 281f805efeSMatthias Ringwald 291f805efeSMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../example/sco_demo_util.c") 301f805efeSMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 311f805efeSMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 321f805efeSMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "../../src/classic/*.c") 331f805efeSMatthias Ringwaldfile(GLOB SOURCES_MESH "../../src/mesh/*.c") 341f805efeSMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c") 351f805efeSMatthias Ringwaldfile(GLOB SOURCES_MD5 "../../3rd-party/md5/md5.c") 361f805efeSMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 371f805efeSMatthias Ringwaldfile(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") 381f805efeSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 391f805efeSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 401f805efeSMatthias Ringwaldfile(GLOB SOURCES_POSIX "../../platform/posix/*.c") 411f805efeSMatthias Ringwaldfile(GLOB SOURCES_LIBUSB "../../port/libusb/*.c" "../../platform/libusb/*.c") 421faf2c16SMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 431f805efeSMatthias Ringwald 441f805efeSMatthias Ringwaldset(LWIP_CORE_SRC 451f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/def.c 461f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/inet_chksum.c 471f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/init.c 481f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ip.c 491f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/mem.c 501f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/memp.c 511f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/netif.c 521f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/pbuf.c 531f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/tcp.c 541f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/tcp_in.c 551f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/tcp_out.c 561f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/timeouts.c 571f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/udp.c 581f805efeSMatthias Ringwald ) 591f805efeSMatthias Ringwaldset (LWIP_IPV4_SRC 601f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ipv4/acd.c 611f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ipv4/dhcp.c 621f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ipv4/etharp.c 631f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ipv4/icmp.c 641f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ipv4/ip4.c 651f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ipv4/ip4_addr.c 661f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/core/ipv4/ip4_frag.c 671f805efeSMatthias Ringwald ) 681f805efeSMatthias Ringwaldset (LWIP_NETIF_SRC 691f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/netif/ethernet.c 701f805efeSMatthias Ringwald ) 711f805efeSMatthias Ringwaldset (LWIP_HTTPD 721f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c 731f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/apps/http/fs.c 741f805efeSMatthias Ringwald ../../3rd-party/lwip/core/src/apps/http/httpd.c 751f805efeSMatthias Ringwald ) 761f805efeSMatthias Ringwaldset (LWIP_DHCPD 771f805efeSMatthias Ringwald ../../3rd-party/lwip/dhcp-server/dhserver.c 781f805efeSMatthias Ringwald ) 791f805efeSMatthias Ringwaldset (LWIP_PORT 801f805efeSMatthias Ringwald ../../platform/lwip/port/sys_arch.c 811f805efeSMatthias Ringwald ../../platform/lwip/bnep_lwip.c 821f805efeSMatthias Ringwald ) 831f805efeSMatthias Ringwald 841f805efeSMatthias Ringwaldset (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT}) 851f805efeSMatthias Ringwald 861f805efeSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 871f805efeSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 881f805efeSMatthias Ringwald 891f805efeSMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c") 901f805efeSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 911f805efeSMatthias Ringwald 921f805efeSMatthias Ringwaldset(SOURCES 931f805efeSMatthias Ringwald ${SOURCES_MD5} 941f805efeSMatthias Ringwald ${SOURCES_YXML} 951f805efeSMatthias Ringwald ${SOURCES_BLUEDROID} 961f805efeSMatthias Ringwald ${SOURCES_POSIX} 971f805efeSMatthias Ringwald ${SOURCES_RIJNDAEL} 981f805efeSMatthias Ringwald ${SOURCES_SRC} 991f805efeSMatthias Ringwald ${SOURCES_BLE} 1001f805efeSMatthias Ringwald ${SOURCES_GATT} 1011f805efeSMatthias Ringwald ${SOURCES_MESH} 1021f805efeSMatthias Ringwald ${SOURCES_CLASSIC} 1031f805efeSMatthias Ringwald ${SOURCES_UECC} 1041f805efeSMatthias Ringwald ${SOURCES_HXCMOD} 1051faf2c16SMatthias Ringwald ${SOURCES_LC3_GOOGLE} 1061f805efeSMatthias Ringwald ) 1071f805efeSMatthias Ringwaldlist(SORT SOURCES) 1081f805efeSMatthias Ringwald 109bba538e5SMatthias Ringwaldadd_compile_options( -g -fsanitize=fuzzer,address -fprofile-instr-generate -fcoverage-mapping) 1103d576343SMatthias Ringwaldadd_link_options( -fsanitize=fuzzer,address -fprofile-instr-generate -fcoverage-mapping) 111eddac615SMatthias Ringwald 1121f805efeSMatthias Ringwald# create static lib 1131f805efeSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 1141f805efeSMatthias Ringwald 1151f805efeSMatthias Ringwald# create fuzz targets 1161f805efeSMatthias Ringwaldfile(GLOB TARGETS_C "fuzz_*.c") 1171f805efeSMatthias Ringwald 1181f805efeSMatthias Ringwald# create targets 1191f805efeSMatthias Ringwaldforeach(TARGET_FILE ${TARGETS_C}) 1201f805efeSMatthias Ringwald get_filename_component(EXAMPLE ${TARGET_FILE} NAME_WE) 12168894c74SMatthias Ringwald 12268894c74SMatthias Ringwald if ( "fuzz_l2cap" MATCHES ${EXAMPLE} ) 12368894c74SMatthias Ringwald add_executable(${EXAMPLE} ${TARGET_FILE} 12468894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/l2cap.c 12568894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/l2cap_signaling.c 12668894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/btstack_run_loop.c 12768894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/btstack_util.c 12868894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/btstack_linked_list.c 12968894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/btstack_memory.c 13068894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/btstack_memory_pool.c 13168894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/hci_cmd.c 13268894c74SMatthias Ringwald ${BTSTACK_ROOT}/src/hci_dump.c 13368894c74SMatthias Ringwald ${SOURCES_POSIX} 13468894c74SMatthias Ringwald ) 13568894c74SMatthias Ringwald else() 1361f805efeSMatthias Ringwald add_executable(${EXAMPLE} ${TARGET_FILE} ) 1371f805efeSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 13868894c74SMatthias Ringwald endif() 1391f805efeSMatthias Ringwaldendforeach(TARGET_FILE) 140