18b0cf348SMatthias Ringwaldcmake_minimum_required (VERSION 3.5) 28b0cf348SMatthias Ringwald 38b0cf348SMatthias Ringwaldproject(BTstack-windows-winusb) 48b0cf348SMatthias Ringwald 58b0cf348SMatthias Ringwald# extra compiler warnings 68b0cf348SMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*") 78b0cf348SMatthias Ringwald # using Clang 88b0cf348SMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror") 98b0cf348SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 108b0cf348SMatthias Ringwald # using GCC 118b0cf348SMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror") 128b0cf348SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") 138b0cf348SMatthias Ringwald # using Intel C++ 148b0cf348SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 158b0cf348SMatthias Ringwald # using Visual Studio C++ 168b0cf348SMatthias Ringwaldendif() 178b0cf348SMatthias Ringwald 18*02bddf72SMatthias Ringwald# to generate .h from .gatt files 19*02bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter) 208b0cf348SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 218b0cf348SMatthias Ringwald 228b0cf348SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 238b0cf348SMatthias Ringwaldinclude_directories(.) 248b0cf348SMatthias Ringwald 258b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include) 268b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include) 278b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 288b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 298b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/md5) 308b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 318b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 328b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 338b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/yxml) 348b0cf348SMatthias Ringwaldinclude_directories(../../src) 358b0cf348SMatthias Ringwaldinclude_directories(../../chipset/zephyr) 368b0cf348SMatthias Ringwaldinclude_directories(../../platform/embedded) 378b0cf348SMatthias Ringwaldinclude_directories(../../platform/posix) 388b0cf348SMatthias Ringwaldinclude_directories(../../platform/windows) 398b0cf348SMatthias Ringwald 408b0cf348SMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../example/sco_demo_util.c" "../../platform/posix/wav_util.c") 418b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c") 428b0cf348SMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "../../src/classic/*.c") 438b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 448b0cf348SMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 458b0cf348SMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 468b0cf348SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 478b0cf348SMatthias Ringwaldfile(GLOB SOURCES_MD5 "../../3rd-party/md5/md5.c") 488b0cf348SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 498b0cf348SMatthias Ringwaldfile(GLOB SOURCES_WINDOWS "../../platform/windows/*.c") 508b0cf348SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 518b0cf348SMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 528b0cf348SMatthias Ringwaldfile(GLOB SOURCES_PORT "*.c") 538b0cf348SMatthias Ringwaldfile(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") 548b0cf348SMatthias Ringwald 558b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 568b0cf348SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 578b0cf348SMatthias Ringwald 588b0cf348SMatthias Ringwald 598b0cf348SMatthias Ringwaldset(SOURCES 608b0cf348SMatthias Ringwald ${SOURCES_BLE} 618b0cf348SMatthias Ringwald ${SOURCES_BLUEDROID} 628b0cf348SMatthias Ringwald ${SOURCES_CLASSIC} 638b0cf348SMatthias Ringwald ${SOURCES_GATT} 648b0cf348SMatthias Ringwald ${SOURCES_HXCMOD} 658b0cf348SMatthias Ringwald ${SOURCES_MD5} 668b0cf348SMatthias Ringwald ${SOURCES_PORT} 678b0cf348SMatthias Ringwald ${SOURCES_RIJNDAEL} 688b0cf348SMatthias Ringwald ${SOURCES_SRC} 698b0cf348SMatthias Ringwald ${SOURCES_UECC} 708b0cf348SMatthias Ringwald ${SOURCES_WINDOWS} 718b0cf348SMatthias Ringwald ${SOURCES_YXML} 728b0cf348SMatthias Ringwald ${SOURCES_ZEPHYR} 738b0cf348SMatthias Ringwald) 748b0cf348SMatthias Ringwaldlist(SORT SOURCES) 758b0cf348SMatthias Ringwald 768b0cf348SMatthias Ringwald# create static lib 778b0cf348SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 788b0cf348SMatthias Ringwald 798b0cf348SMatthias Ringwald# get list of examples, skipping mesh_node_demo 808b0cf348SMatthias Ringwaldinclude(../../example/CMakeLists.txt) 818b0cf348SMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE}) 828b0cf348SMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES) 838b0cf348SMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo") 848b0cf348SMatthias Ringwald 858b0cf348SMatthias Ringwald# create targets 868b0cf348SMatthias Ringwaldset (EXAMPLES_C) 878b0cf348SMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES}) 888b0cf348SMatthias Ringwald # get c file 898b0cf348SMatthias Ringwald file(GLOB EXAMPLE_FILE "../../example/${EXAMPLE}.c") 908b0cf348SMatthias Ringwald 918b0cf348SMatthias Ringwald # add GATT DB creation 928b0cf348SMatthias Ringwald if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} ) 938b0cf348SMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 948b0cf348SMatthias Ringwald add_custom_command( 958b0cf348SMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 96*02bddf72SMatthias Ringwald DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt 97*02bddf72SMatthias Ringwald COMMAND ${Python_EXECUTABLE} 98*02bddf72SMatthias Ringwald ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 998b0cf348SMatthias Ringwald ) 1008b0cf348SMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 1018b0cf348SMatthias Ringwald else() 1028b0cf348SMatthias Ringwald message("example ${EXAMPLE}") 1038b0cf348SMatthias Ringwald endif() 1048b0cf348SMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE} ) 1058b0cf348SMatthias Ringwald target_link_libraries(${EXAMPLE} btstack setupapi winusb) 1068b0cf348SMatthias Ringwaldendforeach(EXAMPLE) 107