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