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