1*cb97e8fbSMatthias Ringwaldcmake_minimum_required (VERSION 3.5) 2*cb97e8fbSMatthias Ringwald 3*cb97e8fbSMatthias Ringwaldproject(BTstack-windows-h4-zephyr) 4*cb97e8fbSMatthias Ringwald 5*cb97e8fbSMatthias Ringwald# extra compiler warnings 6*cb97e8fbSMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*") 7*cb97e8fbSMatthias Ringwald # using Clang 8*cb97e8fbSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror") 9*cb97e8fbSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 10*cb97e8fbSMatthias Ringwald # using GCC 11*cb97e8fbSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror") 12*cb97e8fbSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") 13*cb97e8fbSMatthias Ringwald # using Intel C++ 14*cb97e8fbSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 15*cb97e8fbSMatthias Ringwald # using Visual Studio C++ 16*cb97e8fbSMatthias Ringwaldendif() 17*cb97e8fbSMatthias Ringwald 18*cb97e8fbSMatthias Ringwald# to find generated .h from .gatt files 19*cb97e8fbSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 20*cb97e8fbSMatthias Ringwald 21*cb97e8fbSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 22*cb97e8fbSMatthias Ringwaldinclude_directories(.) 23*cb97e8fbSMatthias Ringwald 24*cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 25*cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 26*cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/md5) 27*cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 28*cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 29*cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 30*cb97e8fbSMatthias Ringwaldinclude_directories(../../src) 31*cb97e8fbSMatthias Ringwaldinclude_directories(../../chipset/zephyr) 32*cb97e8fbSMatthias Ringwaldinclude_directories(../../platform/embedded) 33*cb97e8fbSMatthias Ringwaldinclude_directories(../../platform/windows) 34*cb97e8fbSMatthias Ringwald 35*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c") 36*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 37*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 38*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 39*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 40*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 41*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS "../../platform/windows/*.c") 42*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 43*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 44*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_PORT "*.c") 45*cb97e8fbSMatthias Ringwald 46*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 47*cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 48*cb97e8fbSMatthias Ringwald 49*cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS_OFF "../../platform/windows/hci_transport_h2_winusb.c") 50*cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_WINDOWS ${SOURCES_WINDOWS_OFF}) 51*cb97e8fbSMatthias Ringwald 52*cb97e8fbSMatthias Ringwald 53*cb97e8fbSMatthias Ringwaldset(SOURCES 54*cb97e8fbSMatthias Ringwald ${SOURCES_BLE} 55*cb97e8fbSMatthias Ringwald ${SOURCES_GATT} 56*cb97e8fbSMatthias Ringwald ${SOURCES_HXCMOD} 57*cb97e8fbSMatthias Ringwald ${SOURCES_PORT} 58*cb97e8fbSMatthias Ringwald ${SOURCES_RIJNDAEL} 59*cb97e8fbSMatthias Ringwald ${SOURCES_SRC} 60*cb97e8fbSMatthias Ringwald ${SOURCES_UECC} 61*cb97e8fbSMatthias Ringwald ${SOURCES_ZEPHYR} 62*cb97e8fbSMatthias Ringwald ${SOURCES_WINDOWS} 63*cb97e8fbSMatthias Ringwald) 64*cb97e8fbSMatthias Ringwaldlist(SORT SOURCES) 65*cb97e8fbSMatthias Ringwald 66*cb97e8fbSMatthias Ringwald# create static lib 67*cb97e8fbSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 68*cb97e8fbSMatthias Ringwald 69*cb97e8fbSMatthias Ringwald# get list of examples, skipping mesh_node_demo 70*cb97e8fbSMatthias Ringwaldinclude(../../example/CMakeLists.txt) 71*cb97e8fbSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL}) 72*cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo") 73*cb97e8fbSMatthias Ringwald 74*cb97e8fbSMatthias Ringwald# create targets 75*cb97e8fbSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES}) 76*cb97e8fbSMatthias Ringwald # get c file 77*cb97e8fbSMatthias Ringwald file(GLOB EXAMPLE_FILE "../../example/${EXAMPLE}.c") 78*cb97e8fbSMatthias Ringwald 79*cb97e8fbSMatthias Ringwald # add GATT DB creation 80*cb97e8fbSMatthias Ringwald if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} ) 81*cb97e8fbSMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 82*cb97e8fbSMatthias Ringwald add_custom_command( 83*cb97e8fbSMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 84*cb97e8fbSMatthias Ringwald DEPENDS ${CMAKE_SOURCE_DIR}/../../example/${EXAMPLE}.gatt 85*cb97e8fbSMatthias Ringwald COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py 86*cb97e8fbSMatthias Ringwald ARGS ${CMAKE_SOURCE_DIR}/../../example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 87*cb97e8fbSMatthias Ringwald ) 88*cb97e8fbSMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 89*cb97e8fbSMatthias Ringwald else() 90*cb97e8fbSMatthias Ringwald message("example ${EXAMPLE}") 91*cb97e8fbSMatthias Ringwald endif() 92*cb97e8fbSMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE} ) 93*cb97e8fbSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 94*cb97e8fbSMatthias Ringwaldendforeach(EXAMPLE) 95