1*4e03265bSMatthias Ringwaldcmake_minimum_required (VERSION 3.18) 2*4e03265bSMatthias Ringwald 3*4e03265bSMatthias Ringwaldproject(BTstack-windows-h4) 4*4e03265bSMatthias Ringwald 5*4e03265bSMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..) 6*4e03265bSMatthias Ringwald 7*4e03265bSMatthias Ringwald# extra compiler warnings 8*4e03265bSMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*") 9*4e03265bSMatthias Ringwald # using Clang 10*4e03265bSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror") 11*4e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 12*4e03265bSMatthias Ringwald # using GCC 13*4e03265bSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror") 14*4e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") 15*4e03265bSMatthias Ringwald # using Intel C++ 16*4e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 17*4e03265bSMatthias Ringwald # using Visual Studio C++ 18*4e03265bSMatthias Ringwaldendif() 19*4e03265bSMatthias Ringwald 20*4e03265bSMatthias Ringwald# to find generated .h from .gatt files 21*4e03265bSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 22*4e03265bSMatthias Ringwald 23*4e03265bSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 24*4e03265bSMatthias Ringwaldinclude_directories(.) 25*4e03265bSMatthias Ringwald 26*4e03265bSMatthias Ringwald 27*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/micro-ecc) 28*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include) 29*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include) 30*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lc3-google/include) 31*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/md5) 32*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player) 33*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player/mod) 34*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lwip/core/src/include) 35*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server) 36*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/rijndael) 37*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/yxml) 38*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/tinydir) 39*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/src) 40*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/bcm) 41*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/csr) 42*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/cc256x) 43*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/em9301) 44*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/realtek) 45*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/tc3566x) 46*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/stlc2500d) 47*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/zephyr) 48*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/embedded) 49*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/lwip) 50*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/lwip/port) 51*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/windows) 52*4e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/posix) 53*4e03265bSMatthias Ringwald 54*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_SRC "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/sco_demo_util.c") 55*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLE "${BTSTACK_ROOT}/src/ble/*.c") 56*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c") 57*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "${BTSTACK_ROOT}/src/classic/*.c") 58*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_MESH "${BTSTACK_ROOT}/src/mesh/*.c") 59*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_GATT "${BTSTACK_ROOT}/src/ble/gatt-service/*.c") 60*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_UECC "${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c") 61*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "${BTSTACK_ROOT}/3rd-party/hxcmod-player/*.c" "${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/*.c") 62*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_MD5 "${BTSTACK_ROOT}/3rd-party/md5/md5.c") 63*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c") 64*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_YXML "${BTSTACK_ROOT}/3rd-party/yxml/yxml.c") 65*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS "${BTSTACK_ROOT}/platform/windows/*.c" ${BTSTACK_ROOT}/platform/posix/wav_util.c) 66*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_BCM "${BTSTACK_ROOT}/chipset/bcm/*.c") 67*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_CSR "${BTSTACK_ROOT}/chipset/csr/*.c") 68*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_EM9301 "${BTSTACK_ROOT}/chipset/em9301/*.c") 69*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_STLC2500D "${BTSTACK_ROOT}/chipset/stlc2500d/*.c") 70*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_TC2566X "${BTSTACK_ROOT}/chipset/tc3566x/*.c") 71*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_REALTEK "${BTSTACK_ROOT}/chipset/realtek/*.c") 72*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "${BTSTACK_ROOT}/chipset/zephyr/*.c") 73*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "${BTSTACK_ROOT}/3rd-party/lc3-google/src/*.c") 74*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_PORT "*.c") 75*4e03265bSMatthias Ringwald 76*4e03265bSMatthias Ringwaldset(LWIP_CORE_SRC 77*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c 78*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c 79*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c 80*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c 81*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c 82*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c 83*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c 84*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c 85*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c 86*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c 87*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c 88*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c 89*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c 90*4e03265bSMatthias Ringwald ) 91*4e03265bSMatthias Ringwaldset (LWIP_IPV4_SRC 92*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c 93*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c 94*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c 95*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c 96*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c 97*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c 98*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c 99*4e03265bSMatthias Ringwald ) 100*4e03265bSMatthias Ringwaldset (LWIP_NETIF_SRC 101*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c 102*4e03265bSMatthias Ringwald ) 103*4e03265bSMatthias Ringwaldset (LWIP_HTTPD 104*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c 105*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c 106*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c 107*4e03265bSMatthias Ringwald ) 108*4e03265bSMatthias Ringwaldset (LWIP_DHCPD 109*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c 110*4e03265bSMatthias Ringwald ) 111*4e03265bSMatthias Ringwaldset (LWIP_PORT 112*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c 113*4e03265bSMatthias Ringwald ${BTSTACK_ROOT}//platform/lwip/bnep_lwip.c 114*4e03265bSMatthias Ringwald ) 115*4e03265bSMatthias Ringwaldset (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT}) 116*4e03265bSMatthias Ringwald 117*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "${BTSTACK_ROOT}/src/ble/le_device_db_memory.c") 118*4e03265bSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 119*4e03265bSMatthias Ringwald 120*4e03265bSMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "${BTSTACK_ROOT}/platform/posix/le_device_db_fs.c") 121*4e03265bSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 122*4e03265bSMatthias Ringwald 123*4e03265bSMatthias Ringwaldset(SOURCES 124*4e03265bSMatthias Ringwald ${SOURCES_BLE} 125*4e03265bSMatthias Ringwald ${SOURCES_BCM} 126*4e03265bSMatthias Ringwald ${SOURCES_BLUEDROID} 127*4e03265bSMatthias Ringwald ${SOURCES_CLASSIC} 128*4e03265bSMatthias Ringwald ${SOURCES_CSR} 129*4e03265bSMatthias Ringwald ${SOURCES_EM9301} 130*4e03265bSMatthias Ringwald ${SOURCES_GATT} 131*4e03265bSMatthias Ringwald ${SOURCES_HXCMOD} 132*4e03265bSMatthias Ringwald ${SOURCES_HXCMOD} 133*4e03265bSMatthias Ringwald ${SOURCES_LIBUSB} 134*4e03265bSMatthias Ringwald ${SOURCES_MD5} 135*4e03265bSMatthias Ringwald ${SOURCES_PORT} 136*4e03265bSMatthias Ringwald ${SOURCES_REALTEK} 137*4e03265bSMatthias Ringwald ${SOURCES_RIJNDAEL} 138*4e03265bSMatthias Ringwald ${SOURCES_SRC} 139*4e03265bSMatthias Ringwald ${SOURCES_CC256X} 140*4e03265bSMatthias Ringwald ${SOURCES_CSR} 141*4e03265bSMatthias Ringwald ${SOURCES_STLC2500D} 142*4e03265bSMatthias Ringwald ${SOURCES_TC2566X} 143*4e03265bSMatthias Ringwald ${SOURCES_UECC} 144*4e03265bSMatthias Ringwald ${SOURCES_WINDOWS} 145*4e03265bSMatthias Ringwald ${SOURCES_YXML} 146*4e03265bSMatthias Ringwald ${SOURCES_ZEPHYR} 147*4e03265bSMatthias Ringwald) 148*4e03265bSMatthias Ringwaldlist(SORT SOURCES) 149*4e03265bSMatthias Ringwald 150*4e03265bSMatthias Ringwald# create static lib 151*4e03265bSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 152*4e03265bSMatthias Ringwald 153*4e03265bSMatthias Ringwald# Add CC256x Support and specify init script 154*4e03265bSMatthias Ringwaldset (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c) 155*4e03265bSMatthias Ringwaldinclude(${BTSTACK_ROOT}/chipset/cc256x/cc256x.cmake) 156*4e03265bSMatthias Ringwald 157*4e03265bSMatthias Ringwald# Add BCM Support and download PatchRAM files 158*4e03265bSMatthias Ringwaldinclude(${BTSTACK_ROOT}/chipset/bcm/bcm.cmake) 159*4e03265bSMatthias Ringwald 160*4e03265bSMatthias Ringwald# get list of examples, skipping mesh_node_demo 161*4e03265bSMatthias Ringwaldinclude(../../example/CMakeLists.txt) 162*4e03265bSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE}) 163*4e03265bSMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES) 164*4e03265bSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo") 165*4e03265bSMatthias Ringwald 166*4e03265bSMatthias Ringwald# create targets 167*4e03265bSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES}) 168*4e03265bSMatthias Ringwald # get c file 169*4e03265bSMatthias Ringwald file(GLOB EXAMPLE_FILE "${BTSTACK_ROOT}/example/${EXAMPLE}.c") 170*4e03265bSMatthias Ringwald set (SOURCE_FILES ${EXAMPLE_FILE}) 171*4e03265bSMatthias Ringwald 172*4e03265bSMatthias Ringwald # add GATT DB creation 173*4e03265bSMatthias Ringwald if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} ) 174*4e03265bSMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 175*4e03265bSMatthias Ringwald add_custom_command( 176*4e03265bSMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 177*4e03265bSMatthias Ringwald DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt 178*4e03265bSMatthias Ringwald COMMAND python3 179*4e03265bSMatthias Ringwald ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 180*4e03265bSMatthias Ringwald ) 181*4e03265bSMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 182*4e03265bSMatthias Ringwald else() 183*4e03265bSMatthias Ringwald message("example ${EXAMPLE}") 184*4e03265bSMatthias Ringwald endif() 185*4e03265bSMatthias Ringwald add_executable(${EXAMPLE} ${SOURCE_FILES} ) 186*4e03265bSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 187*4e03265bSMatthias Ringwaldendforeach(EXAMPLE) 188