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