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