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