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