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