1b260a82eSMatthias Ringwaldcmake_minimum_required (VERSION 3.5) 2b260a82eSMatthias Ringwald 3b260a82eSMatthias Ringwaldproject(BTstack-windows-winusb-intel) 4b260a82eSMatthias Ringwald 5b260a82eSMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..) 6b260a82eSMatthias Ringwald 7b260a82eSMatthias Ringwald# extra compiler warnings 8b260a82eSMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*") 9b260a82eSMatthias Ringwald # using Clang 10b260a82eSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror") 11b260a82eSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 12b260a82eSMatthias Ringwald # using GCC 13b260a82eSMatthias Ringwald SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror") 14b260a82eSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") 15b260a82eSMatthias Ringwald # using Intel C++ 16b260a82eSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 17b260a82eSMatthias Ringwald # using Visual Studio C++ 18b260a82eSMatthias Ringwaldendif() 19b260a82eSMatthias 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 34b260a82eSMatthias Ringwald# Generate .h from .gatt files 35b260a82eSMatthias Ringwaldfind_package (Python COMPONENTS Interpreter) 36b260a82eSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 37b260a82eSMatthias Ringwaldmessage ("Python: ${Python_EXECUTABLE}") 38b260a82eSMatthias Ringwald 39b260a82eSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 40b260a82eSMatthias Ringwaldinclude_directories(.) 41b260a82eSMatthias Ringwald 42b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include) 43b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include) 44b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 45b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 46b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/md5) 47b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 48b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 49b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 50b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/yxml) 51b260a82eSMatthias Ringwaldinclude_directories(../../src) 52b260a82eSMatthias Ringwaldinclude_directories(../../chipset/csr) 53b260a82eSMatthias Ringwaldinclude_directories(../../chipset/intel) 54b260a82eSMatthias Ringwaldinclude_directories(../../chipset/zephyr) 55b260a82eSMatthias Ringwaldinclude_directories(../../platform/embedded) 56b260a82eSMatthias Ringwaldinclude_directories(../../platform/posix) 57b260a82eSMatthias Ringwaldinclude_directories(../../platform/windows) 58b260a82eSMatthias Ringwald 59b260a82eSMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../example/sco_demo_util.c" "../../platform/posix/wav_util.c") 60b260a82eSMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c") 61b260a82eSMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "../../src/classic/*.c") 62b260a82eSMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 63b260a82eSMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 64b260a82eSMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 65b260a82eSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 66b260a82eSMatthias Ringwaldfile(GLOB SOURCES_MD5 "../../3rd-party/md5/md5.c") 67b260a82eSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 68b260a82eSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS "../../platform/windows/*.c") 69b260a82eSMatthias Ringwaldfile(GLOB SOURCES_CSR "../../chipset/csr/*.c") 70b260a82eSMatthias Ringwaldfile(GLOB SOURCES_INTEL "../../chipset/intel/*.c") 71b260a82eSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 72b260a82eSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 73b260a82eSMatthias Ringwaldfile(GLOB SOURCES_PORT "*.c") 74b260a82eSMatthias Ringwaldfile(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") 75b260a82eSMatthias Ringwald 76b260a82eSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 77b260a82eSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 78b260a82eSMatthias Ringwald 79b260a82eSMatthias Ringwald 80b260a82eSMatthias Ringwaldset(SOURCES 81b260a82eSMatthias Ringwald ${SOURCES_BLE} 82b260a82eSMatthias Ringwald ${SOURCES_BLUEDROID} 83b260a82eSMatthias Ringwald ${SOURCES_CLASSIC} 84b260a82eSMatthias Ringwald ${SOURCES_GATT} 85b260a82eSMatthias Ringwald ${SOURCES_HXCMOD} 86b260a82eSMatthias Ringwald ${SOURCES_MD5} 87b260a82eSMatthias Ringwald ${SOURCES_PORT} 88b260a82eSMatthias Ringwald ${SOURCES_RIJNDAEL} 89b260a82eSMatthias Ringwald ${SOURCES_SRC} 90b260a82eSMatthias Ringwald ${SOURCES_UECC} 91b260a82eSMatthias Ringwald ${SOURCES_WINDOWS} 92b260a82eSMatthias Ringwald ${SOURCES_YXML} 93b260a82eSMatthias Ringwald ${SOURCES_CSR} 94b260a82eSMatthias Ringwald ${SOURCES_INTEL} 95b260a82eSMatthias Ringwald ${SOURCES_ZEPHYR} 96b260a82eSMatthias Ringwald) 97b260a82eSMatthias Ringwaldlist(SORT SOURCES) 98b260a82eSMatthias Ringwald 99b260a82eSMatthias Ringwald# create static lib 100b260a82eSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 101b260a82eSMatthias Ringwald 102b260a82eSMatthias Ringwald# get list of examples, skipping mesh_node_demo 103b260a82eSMatthias Ringwaldinclude(../../example/CMakeLists.txt) 104b260a82eSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE}) 105b260a82eSMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES) 106b260a82eSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo") 107b260a82eSMatthias Ringwald 108b260a82eSMatthias Ringwald# create targets 109b260a82eSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES}) 110b260a82eSMatthias Ringwald # get c file 111b260a82eSMatthias Ringwald set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c) 112b260a82eSMatthias Ringwald 113b260a82eSMatthias Ringwald # add GATT DB creation 114b260a82eSMatthias Ringwald if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} ) 115b260a82eSMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 116b260a82eSMatthias Ringwald add_custom_command( 117b260a82eSMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 118b260a82eSMatthias Ringwald DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt 119b260a82eSMatthias Ringwald COMMAND ${Python_EXECUTABLE} 120b260a82eSMatthias Ringwald ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 121b260a82eSMatthias Ringwald ) 122b260a82eSMatthias Ringwald list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 123b260a82eSMatthias Ringwald else() 124b260a82eSMatthias Ringwald message("example ${EXAMPLE}") 125b260a82eSMatthias Ringwald endif() 126b260a82eSMatthias Ringwald add_executable(${EXAMPLE} ${SOURCES_EXAMPLE}) 127b260a82eSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack setupapi winusb) 128b260a82eSMatthias Ringwaldendforeach(EXAMPLE) 129