14e03265bSMatthias Ringwaldcmake_minimum_required (VERSION 3.18) 24e03265bSMatthias Ringwald 34e03265bSMatthias Ringwaldproject(BTstack-windows-h4) 44e03265bSMatthias Ringwald 54e03265bSMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..) 64e03265bSMatthias Ringwald 74e03265bSMatthias Ringwald# extra compiler warnings 84e03265bSMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*") 94e03265bSMatthias Ringwald # using Clang 104e03265bSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror") 114e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 124e03265bSMatthias Ringwald # using GCC 134e03265bSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror") 144e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") 154e03265bSMatthias Ringwald # using Intel C++ 164e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 174e03265bSMatthias Ringwald # using Visual Studio C++ 184e03265bSMatthias Ringwaldendif() 194e03265bSMatthias Ringwald 2042c5c558SMatthias Ringwald 2102bddf72SMatthias Ringwald# to generate .h from .gatt files 2202bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter) 234e03265bSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 244e03265bSMatthias Ringwald 254e03265bSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 264e03265bSMatthias Ringwaldinclude_directories(.) 274e03265bSMatthias Ringwald 284e03265bSMatthias Ringwald 294e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/micro-ecc) 304e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include) 314e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include) 324e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lc3-google/include) 334e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/md5) 344e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player) 354e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player/mod) 364e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lwip/core/src/include) 374e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server) 384e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/rijndael) 394e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/yxml) 404e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/tinydir) 414e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/src) 424e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/bcm) 434e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/csr) 444e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/cc256x) 454e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/em9301) 464e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/realtek) 474e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/tc3566x) 484e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/stlc2500d) 494e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/zephyr) 504e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/embedded) 514e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/lwip) 524e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/lwip/port) 534e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/windows) 544e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/posix) 554e03265bSMatthias Ringwald 564e03265bSMatthias Ringwaldfile(GLOB SOURCES_SRC "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/sco_demo_util.c") 574e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLE "${BTSTACK_ROOT}/src/ble/*.c") 584e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c") 594e03265bSMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "${BTSTACK_ROOT}/src/classic/*.c") 604e03265bSMatthias Ringwaldfile(GLOB SOURCES_MESH "${BTSTACK_ROOT}/src/mesh/*.c") 614e03265bSMatthias Ringwaldfile(GLOB SOURCES_GATT "${BTSTACK_ROOT}/src/ble/gatt-service/*.c") 624e03265bSMatthias Ringwaldfile(GLOB SOURCES_UECC "${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c") 634e03265bSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "${BTSTACK_ROOT}/3rd-party/hxcmod-player/*.c" "${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/*.c") 644e03265bSMatthias Ringwaldfile(GLOB SOURCES_MD5 "${BTSTACK_ROOT}/3rd-party/md5/md5.c") 654e03265bSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c") 664e03265bSMatthias Ringwaldfile(GLOB SOURCES_YXML "${BTSTACK_ROOT}/3rd-party/yxml/yxml.c") 674e03265bSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS "${BTSTACK_ROOT}/platform/windows/*.c" ${BTSTACK_ROOT}/platform/posix/wav_util.c) 684e03265bSMatthias Ringwaldfile(GLOB SOURCES_BCM "${BTSTACK_ROOT}/chipset/bcm/*.c") 694e03265bSMatthias Ringwaldfile(GLOB SOURCES_CSR "${BTSTACK_ROOT}/chipset/csr/*.c") 704e03265bSMatthias Ringwaldfile(GLOB SOURCES_EM9301 "${BTSTACK_ROOT}/chipset/em9301/*.c") 714e03265bSMatthias Ringwaldfile(GLOB SOURCES_STLC2500D "${BTSTACK_ROOT}/chipset/stlc2500d/*.c") 724e03265bSMatthias Ringwaldfile(GLOB SOURCES_TC2566X "${BTSTACK_ROOT}/chipset/tc3566x/*.c") 734e03265bSMatthias Ringwaldfile(GLOB SOURCES_REALTEK "${BTSTACK_ROOT}/chipset/realtek/*.c") 744e03265bSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "${BTSTACK_ROOT}/chipset/zephyr/*.c") 754e03265bSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "${BTSTACK_ROOT}/3rd-party/lc3-google/src/*.c") 764e03265bSMatthias Ringwaldfile(GLOB SOURCES_PORT "*.c") 774e03265bSMatthias Ringwald 784e03265bSMatthias Ringwaldset(LWIP_CORE_SRC 794e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c 804e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c 814e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c 824e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c 834e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c 844e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c 854e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c 864e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c 874e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c 884e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c 894e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c 904e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c 914e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c 924e03265bSMatthias Ringwald ) 934e03265bSMatthias Ringwaldset (LWIP_IPV4_SRC 944e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c 954e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c 964e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c 974e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c 984e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c 994e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c 1004e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c 1014e03265bSMatthias Ringwald ) 1024e03265bSMatthias Ringwaldset (LWIP_NETIF_SRC 1034e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c 1044e03265bSMatthias Ringwald ) 1054e03265bSMatthias Ringwaldset (LWIP_HTTPD 1064e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c 1074e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c 1084e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c 1094e03265bSMatthias Ringwald ) 1104e03265bSMatthias Ringwaldset (LWIP_DHCPD 1114e03265bSMatthias Ringwald ${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c 1124e03265bSMatthias Ringwald ) 1134e03265bSMatthias Ringwaldset (LWIP_PORT 1144e03265bSMatthias Ringwald ${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c 1154e03265bSMatthias Ringwald ${BTSTACK_ROOT}//platform/lwip/bnep_lwip.c 1164e03265bSMatthias Ringwald ) 1174e03265bSMatthias Ringwaldset (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT}) 1184e03265bSMatthias Ringwald 1194e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "${BTSTACK_ROOT}/src/ble/le_device_db_memory.c") 1204e03265bSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 1214e03265bSMatthias Ringwald 1224e03265bSMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "${BTSTACK_ROOT}/platform/posix/le_device_db_fs.c") 1234e03265bSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 1244e03265bSMatthias Ringwald 1254e03265bSMatthias Ringwaldset(SOURCES 1264e03265bSMatthias Ringwald ${SOURCES_BLE} 1274e03265bSMatthias Ringwald ${SOURCES_BCM} 1284e03265bSMatthias Ringwald ${SOURCES_BLUEDROID} 1294e03265bSMatthias Ringwald ${SOURCES_CLASSIC} 1304e03265bSMatthias Ringwald ${SOURCES_CSR} 1314e03265bSMatthias Ringwald ${SOURCES_EM9301} 1324e03265bSMatthias Ringwald ${SOURCES_GATT} 1334e03265bSMatthias Ringwald ${SOURCES_HXCMOD} 1344e03265bSMatthias Ringwald ${SOURCES_HXCMOD} 1354e03265bSMatthias Ringwald ${SOURCES_LIBUSB} 1364e03265bSMatthias Ringwald ${SOURCES_MD5} 1374e03265bSMatthias Ringwald ${SOURCES_PORT} 1384e03265bSMatthias Ringwald ${SOURCES_REALTEK} 1394e03265bSMatthias Ringwald ${SOURCES_RIJNDAEL} 1404e03265bSMatthias Ringwald ${SOURCES_SRC} 1414e03265bSMatthias Ringwald ${SOURCES_CC256X} 1424e03265bSMatthias Ringwald ${SOURCES_CSR} 1434e03265bSMatthias Ringwald ${SOURCES_STLC2500D} 1444e03265bSMatthias Ringwald ${SOURCES_TC2566X} 1454e03265bSMatthias Ringwald ${SOURCES_UECC} 1464e03265bSMatthias Ringwald ${SOURCES_WINDOWS} 1474e03265bSMatthias Ringwald ${SOURCES_YXML} 1484e03265bSMatthias Ringwald ${SOURCES_ZEPHYR} 1494e03265bSMatthias Ringwald) 1504e03265bSMatthias Ringwaldlist(SORT SOURCES) 1514e03265bSMatthias Ringwald 1524e03265bSMatthias Ringwald# create static lib 1534e03265bSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 1544e03265bSMatthias Ringwald 15557f681c0SMatthias Ringwald# pkgconfig 156*caeaa206SMatthias Ringwaldfind_package(PkgConfig) 15757f681c0SMatthias Ringwald 15857f681c0SMatthias Ringwald# portaudio 15957f681c0SMatthias Ringwaldif (PkgConfig_FOUND) 160*caeaa206SMatthias Ringwald pkg_check_modules(PORTAUDIO portaudio-2.0) 16157f681c0SMatthias Ringwald if(PORTAUDIO_FOUND) 16257f681c0SMatthias Ringwald message("HAVE_PORTAUDIO") 16357f681c0SMatthias Ringwald include_directories(${PORTAUDIO_INCLUDE_DIRS}) 16457f681c0SMatthias Ringwald link_directories(${PORTAUDIO_LIBRARY_DIRS}) 16557f681c0SMatthias Ringwald link_libraries(${PORTAUDIO_LIBRARIES}) 166*caeaa206SMatthias Ringwald add_compile_definitions(HAVE_PORTAUDIO) 16757f681c0SMatthias Ringwald endif() 16857f681c0SMatthias Ringwaldendif() 16957f681c0SMatthias Ringwald 1704e03265bSMatthias Ringwald# Add CC256x Support and specify init script 1714e03265bSMatthias Ringwaldset (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c) 1724e03265bSMatthias Ringwaldinclude(${BTSTACK_ROOT}/chipset/cc256x/cc256x.cmake) 1734e03265bSMatthias Ringwald 1744e03265bSMatthias Ringwald# Add BCM Support and download PatchRAM files 1754e03265bSMatthias Ringwaldinclude(${BTSTACK_ROOT}/chipset/bcm/bcm.cmake) 1764e03265bSMatthias Ringwald 1774e03265bSMatthias Ringwald# get list of examples, skipping mesh_node_demo 1784e03265bSMatthias Ringwaldinclude(../../example/CMakeLists.txt) 1794e03265bSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE}) 1804e03265bSMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES) 1814e03265bSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo") 1824e03265bSMatthias Ringwald 1834e03265bSMatthias Ringwald# create targets 1844e03265bSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES}) 1854e03265bSMatthias Ringwald # get c file 1861e0ee29bSMatthias Ringwald set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c) 1874e03265bSMatthias Ringwald 1884e03265bSMatthias Ringwald # add GATT DB creation 1894e03265bSMatthias Ringwald if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} ) 1904e03265bSMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 1914e03265bSMatthias Ringwald add_custom_command( 1924e03265bSMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 1934e03265bSMatthias Ringwald DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt 19402bddf72SMatthias Ringwald COMMAND ${Python_EXECUTABLE} 1954e03265bSMatthias Ringwald ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 1964e03265bSMatthias Ringwald ) 197bbce5facSMatthias Ringwald list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 1984e03265bSMatthias Ringwald else() 1994e03265bSMatthias Ringwald message("example ${EXAMPLE}") 2004e03265bSMatthias Ringwald endif() 2011e0ee29bSMatthias Ringwald add_executable(${EXAMPLE} ${SOURCES_EXAMPLE}) 2024e03265bSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 2034e03265bSMatthias Ringwaldendforeach(EXAMPLE) 204