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 2042c5c558SMatthias Ringwald# pkgconfig 21*7367e9aaSMatthias Ringwaldfind_package(PkgConfig QUIET) 2242c5c558SMatthias Ringwald 2342c5c558SMatthias Ringwald# portaudio 24*7367e9aaSMatthias Ringwaldif (PkgConfig_FOUND) 2542c5c558SMatthias Ringwald pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) 2642c5c558SMatthias Ringwald if(PORTAUDIO_FOUND) 2742c5c558SMatthias Ringwald message("HAVE_PORTAUDIO") 2842c5c558SMatthias Ringwald include_directories(${PORTAUDIO_INCLUDE_DIRS}) 2942c5c558SMatthias Ringwald link_directories(${PORTAUDIO_LIBRARY_DIRS}) 3042c5c558SMatthias Ringwald link_libraries(${PORTAUDIO_LIBRARIES}) 3142c5c558SMatthias Ringwald # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) 3242c5c558SMatthias Ringwald SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") 3342c5c558SMatthias Ringwald endif() 34*7367e9aaSMatthias Ringwaldendif() 3542c5c558SMatthias Ringwald 3602bddf72SMatthias Ringwald# to generate .h from .gatt files 3702bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter) 38cb97e8fbSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 39cb97e8fbSMatthias Ringwald 40cb97e8fbSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 41cb97e8fbSMatthias Ringwaldinclude_directories(.) 42cb97e8fbSMatthias Ringwald 43cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 44cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 45cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/md5) 46cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 47cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 48cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 49cb97e8fbSMatthias Ringwaldinclude_directories(../../src) 50cb97e8fbSMatthias Ringwaldinclude_directories(../../chipset/zephyr) 51cb97e8fbSMatthias Ringwaldinclude_directories(../../platform/embedded) 52cb97e8fbSMatthias Ringwaldinclude_directories(../../platform/windows) 53cb97e8fbSMatthias Ringwald 54cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c") 55cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 56cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 57cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 58cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 59cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 60cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS "../../platform/windows/*.c") 61cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 62cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 63cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_PORT "*.c") 64cb97e8fbSMatthias Ringwald 65cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 66cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 67cb97e8fbSMatthias Ringwald 68cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS_OFF "../../platform/windows/hci_transport_h2_winusb.c") 69cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_WINDOWS ${SOURCES_WINDOWS_OFF}) 70cb97e8fbSMatthias Ringwald 71cb97e8fbSMatthias Ringwald 72cb97e8fbSMatthias Ringwaldset(SOURCES 73cb97e8fbSMatthias Ringwald ${SOURCES_BLE} 74cb97e8fbSMatthias Ringwald ${SOURCES_GATT} 75cb97e8fbSMatthias Ringwald ${SOURCES_HXCMOD} 76cb97e8fbSMatthias Ringwald ${SOURCES_PORT} 77cb97e8fbSMatthias Ringwald ${SOURCES_RIJNDAEL} 78cb97e8fbSMatthias Ringwald ${SOURCES_SRC} 79cb97e8fbSMatthias Ringwald ${SOURCES_UECC} 80cb97e8fbSMatthias Ringwald ${SOURCES_ZEPHYR} 81cb97e8fbSMatthias Ringwald ${SOURCES_WINDOWS} 82cb97e8fbSMatthias Ringwald) 83cb97e8fbSMatthias Ringwaldlist(SORT SOURCES) 84cb97e8fbSMatthias Ringwald 85cb97e8fbSMatthias Ringwald# create static lib 86cb97e8fbSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 87cb97e8fbSMatthias Ringwald 88cb97e8fbSMatthias Ringwald# get list of examples, skipping mesh_node_demo 89cb97e8fbSMatthias Ringwaldinclude(../../example/CMakeLists.txt) 90cb97e8fbSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL}) 91cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo") 92cb97e8fbSMatthias Ringwald 93cb97e8fbSMatthias Ringwald# create targets 94cb97e8fbSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES}) 95cb97e8fbSMatthias Ringwald # get c file 961e0ee29bSMatthias Ringwald set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c) 97cb97e8fbSMatthias Ringwald 98cb97e8fbSMatthias Ringwald # add GATT DB creation 99cb97e8fbSMatthias Ringwald if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} ) 100cb97e8fbSMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 101cb97e8fbSMatthias Ringwald add_custom_command( 102cb97e8fbSMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 10302bddf72SMatthias Ringwald DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt 10402bddf72SMatthias Ringwald COMMAND ${Python_EXECUTABLE} 10502bddf72SMatthias Ringwald ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 106cb97e8fbSMatthias Ringwald ) 107cb97e8fbSMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 108cb97e8fbSMatthias Ringwald else() 109cb97e8fbSMatthias Ringwald message("example ${EXAMPLE}") 110cb97e8fbSMatthias Ringwald endif() 1111e0ee29bSMatthias Ringwald add_executable(${EXAMPLE} ${SOURCES_EXAMPLE}) 112cb97e8fbSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 113cb97e8fbSMatthias Ringwaldendforeach(EXAMPLE) 114