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 QUIET) 22 23# portaudio 24if (PkgConfig_FOUND) 25 pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) 26 if(PORTAUDIO_FOUND) 27 message("HAVE_PORTAUDIO") 28 include_directories(${PORTAUDIO_INCLUDE_DIRS}) 29 link_directories(${PORTAUDIO_LIBRARY_DIRS}) 30 link_libraries(${PORTAUDIO_LIBRARIES}) 31 # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) 32 SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") 33 endif() 34endif() 35 36# to generate .h from .gatt files 37find_package (Python REQUIRED COMPONENTS Interpreter) 38include_directories(${CMAKE_CURRENT_BINARY_DIR}) 39 40# local dir for btstack_config.h after build dir to avoid using .h from Makefile 41include_directories(.) 42 43 44include_directories(${BTSTACK_ROOT}/3rd-party/micro-ecc) 45include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include) 46include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include) 47include_directories(${BTSTACK_ROOT}/3rd-party/lc3-google/include) 48include_directories(${BTSTACK_ROOT}/3rd-party/md5) 49include_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player) 50include_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player/mod) 51include_directories(${BTSTACK_ROOT}/3rd-party/lwip/core/src/include) 52include_directories(${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server) 53include_directories(${BTSTACK_ROOT}/3rd-party/rijndael) 54include_directories(${BTSTACK_ROOT}/3rd-party/yxml) 55include_directories(${BTSTACK_ROOT}/3rd-party/tinydir) 56include_directories(${BTSTACK_ROOT}/src) 57include_directories(${BTSTACK_ROOT}/chipset/bcm) 58include_directories(${BTSTACK_ROOT}/chipset/csr) 59include_directories(${BTSTACK_ROOT}/chipset/cc256x) 60include_directories(${BTSTACK_ROOT}/chipset/em9301) 61include_directories(${BTSTACK_ROOT}/chipset/realtek) 62include_directories(${BTSTACK_ROOT}/chipset/tc3566x) 63include_directories(${BTSTACK_ROOT}/chipset/stlc2500d) 64include_directories(${BTSTACK_ROOT}/chipset/zephyr) 65include_directories(${BTSTACK_ROOT}/platform/embedded) 66include_directories(${BTSTACK_ROOT}/platform/lwip) 67include_directories(${BTSTACK_ROOT}/platform/lwip/port) 68include_directories(${BTSTACK_ROOT}/platform/windows) 69include_directories(${BTSTACK_ROOT}/platform/posix) 70 71file(GLOB SOURCES_SRC "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/sco_demo_util.c") 72file(GLOB SOURCES_BLE "${BTSTACK_ROOT}/src/ble/*.c") 73file(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c") 74file(GLOB SOURCES_CLASSIC "${BTSTACK_ROOT}/src/classic/*.c") 75file(GLOB SOURCES_MESH "${BTSTACK_ROOT}/src/mesh/*.c") 76file(GLOB SOURCES_GATT "${BTSTACK_ROOT}/src/ble/gatt-service/*.c") 77file(GLOB SOURCES_UECC "${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c") 78file(GLOB SOURCES_HXCMOD "${BTSTACK_ROOT}/3rd-party/hxcmod-player/*.c" "${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/*.c") 79file(GLOB SOURCES_MD5 "${BTSTACK_ROOT}/3rd-party/md5/md5.c") 80file(GLOB SOURCES_RIJNDAEL "${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c") 81file(GLOB SOURCES_YXML "${BTSTACK_ROOT}/3rd-party/yxml/yxml.c") 82file(GLOB SOURCES_WINDOWS "${BTSTACK_ROOT}/platform/windows/*.c" ${BTSTACK_ROOT}/platform/posix/wav_util.c) 83file(GLOB SOURCES_BCM "${BTSTACK_ROOT}/chipset/bcm/*.c") 84file(GLOB SOURCES_CSR "${BTSTACK_ROOT}/chipset/csr/*.c") 85file(GLOB SOURCES_EM9301 "${BTSTACK_ROOT}/chipset/em9301/*.c") 86file(GLOB SOURCES_STLC2500D "${BTSTACK_ROOT}/chipset/stlc2500d/*.c") 87file(GLOB SOURCES_TC2566X "${BTSTACK_ROOT}/chipset/tc3566x/*.c") 88file(GLOB SOURCES_REALTEK "${BTSTACK_ROOT}/chipset/realtek/*.c") 89file(GLOB SOURCES_ZEPHYR "${BTSTACK_ROOT}/chipset/zephyr/*.c") 90file(GLOB SOURCES_LC3_GOOGLE "${BTSTACK_ROOT}/3rd-party/lc3-google/src/*.c") 91file(GLOB SOURCES_PORT "*.c") 92 93set(LWIP_CORE_SRC 94 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c 95 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c 96 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c 97 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c 98 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c 99 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c 100 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c 101 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c 102 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c 103 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c 104 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c 105 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c 106 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c 107 ) 108set (LWIP_IPV4_SRC 109 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c 110 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c 111 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c 112 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c 113 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c 114 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c 115 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c 116 ) 117set (LWIP_NETIF_SRC 118 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c 119 ) 120set (LWIP_HTTPD 121 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c 122 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c 123 ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c 124 ) 125set (LWIP_DHCPD 126 ${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c 127 ) 128set (LWIP_PORT 129 ${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c 130 ${BTSTACK_ROOT}//platform/lwip/bnep_lwip.c 131 ) 132set (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT}) 133 134file(GLOB SOURCES_BLE_OFF "${BTSTACK_ROOT}/src/ble/le_device_db_memory.c") 135list(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 136 137file(GLOB SOURCES_POSIX_OFF "${BTSTACK_ROOT}/platform/posix/le_device_db_fs.c") 138list(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 139 140set(SOURCES 141 ${SOURCES_BLE} 142 ${SOURCES_BCM} 143 ${SOURCES_BLUEDROID} 144 ${SOURCES_CLASSIC} 145 ${SOURCES_CSR} 146 ${SOURCES_EM9301} 147 ${SOURCES_GATT} 148 ${SOURCES_HXCMOD} 149 ${SOURCES_HXCMOD} 150 ${SOURCES_LIBUSB} 151 ${SOURCES_MD5} 152 ${SOURCES_PORT} 153 ${SOURCES_REALTEK} 154 ${SOURCES_RIJNDAEL} 155 ${SOURCES_SRC} 156 ${SOURCES_CC256X} 157 ${SOURCES_CSR} 158 ${SOURCES_STLC2500D} 159 ${SOURCES_TC2566X} 160 ${SOURCES_UECC} 161 ${SOURCES_WINDOWS} 162 ${SOURCES_YXML} 163 ${SOURCES_ZEPHYR} 164) 165list(SORT SOURCES) 166 167# create static lib 168add_library(btstack STATIC ${SOURCES}) 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