110277393SMatthias Ringwaldcmake_minimum_required (VERSION 3.12) 210277393SMatthias Ringwaldproject(BTstack-LE-Audio) 310277393SMatthias Ringwaldset (CMAKE_CXX_STANDARD 11) 410277393SMatthias Ringwald 5ab05be60SMatthias Ringwald 610277393SMatthias Ringwald# enable optional features 710277393SMatthias Ringwaldadd_compile_definitions(ENABLE_TESTING_SUPPORT) 810277393SMatthias Ringwald 910277393SMatthias Ringwald# to find generated .h from .gatt files 1010277393SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 1110277393SMatthias Ringwald 1210277393SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 139162c232SMatthias Ringwaldinclude_directories(include) 1410277393SMatthias Ringwald 1510277393SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 1610277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include) 1710277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include) 1810277393SMatthias Ringwaldinclude_directories(../../3rd-party/md5) 1910277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 2010277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 21e40ee29aSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 2210277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/core/src/include) 2310277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/dhcp-server) 2410277393SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 2510277393SMatthias Ringwaldinclude_directories(../../3rd-party/yxml) 2610277393SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir) 2710277393SMatthias Ringwaldinclude_directories(../../src) 2810277393SMatthias Ringwaldinclude_directories(../../example) 2910277393SMatthias Ringwaldinclude_directories(../../chipset/zephyr) 300c608997SMatthias Ringwaldinclude_directories(../../chipset/bcm) 3110277393SMatthias Ringwaldinclude_directories(../../platform/posix) 3210277393SMatthias Ringwaldinclude_directories(../../platform/embedded) 3310277393SMatthias Ringwaldinclude_directories(../../platform/lwip) 3410277393SMatthias Ringwaldinclude_directories(../../platform/lwip/port) 3510277393SMatthias Ringwald 3610277393SMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../src/*.cpp" "../../example/sco_demo_util.c") 3710277393SMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 3810277393SMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 3910277393SMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "../../src/classic/*.c") 405deb0bb6SMatthias Ringwaldfile(GLOB SOURCES_LE_AUDIO "../../src/le-audio/*.c" "../../src/le-audio/gatt-service/*.c") 4110277393SMatthias Ringwaldfile(GLOB SOURCES_MESH "../../src/mesh/*.c") 4210277393SMatthias Ringwaldfile(GLOB SOURCES_MD5 "../../3rd-party/md5/md5.c") 4310277393SMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 4410277393SMatthias Ringwaldfile(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") 4510277393SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 4610277393SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 4710277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX "../../platform/posix/*.c") 48d60a1028SMatthias Ringwaldfile(GLOB SOURCES_MAIN main.c) 4910277393SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 500c608997SMatthias Ringwaldfile(GLOB SOURCES_BCM "../../chipset/bcm/*.c") 51e40ee29aSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 5210277393SMatthias Ringwald 5310277393SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 5410277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 5510277393SMatthias Ringwald 5610277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c") 5710277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 5810277393SMatthias Ringwald 5910277393SMatthias Ringwaldset(SOURCES 6010277393SMatthias Ringwald ${SOURCES_MD5} 6110277393SMatthias Ringwald ${SOURCES_YXML} 62e40ee29aSMatthias Ringwald ${SOURCES_LC3_GOOGLE} 6310277393SMatthias Ringwald ${SOURCES_POSIX} 6410277393SMatthias Ringwald ${SOURCES_MAIN} 6510277393SMatthias Ringwald ${SOURCES_RIJNDAEL} 6610277393SMatthias Ringwald ${SOURCES_SRC} 6710277393SMatthias Ringwald ${SOURCES_BLE} 6810277393SMatthias Ringwald ${SOURCES_GATT} 695deb0bb6SMatthias Ringwald ${SOURCES_LE_AUDIO} 7010277393SMatthias Ringwald ${SOURCES_MESH} 7110277393SMatthias Ringwald ${SOURCES_CLASSIC} 7210277393SMatthias Ringwald ${SOURCES_UECC} 7310277393SMatthias Ringwald ${SOURCES_HXCMOD} 7410277393SMatthias Ringwald ${SOURCES_ZEPHYR} 750c608997SMatthias Ringwald ${SOURCES_BCM} 7610277393SMatthias Ringwald) 7710277393SMatthias Ringwaldlist(SORT SOURCES) 7810277393SMatthias Ringwald 7910277393SMatthias Ringwald# create static lib 8010277393SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 8110277393SMatthias Ringwald 82*4bcc4188SMatthias Ringwald# find pkgconfig 83*4bcc4188SMatthias Ringwaldfind_package(PkgConfig REQUIRED) 84*4bcc4188SMatthias Ringwald 85*4bcc4188SMatthias Ringwald# portaudio 86*4bcc4188SMatthias Ringwaldpkg_check_modules(PORTAUDIO portaudio-2.0) 87*4bcc4188SMatthias Ringwaldif(PORTAUDIO_FOUND) 88*4bcc4188SMatthias Ringwald include_directories(${PORTAUDIO_INCLUDE_DIRS}) 89*4bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) 90*4bcc4188SMatthias Ringwald target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) 91*4bcc4188SMatthias Ringwald add_compile_definitions(HAVE_PORTAUDIO) 92*4bcc4188SMatthias Ringwaldendif() 93*4bcc4188SMatthias Ringwald 94*4bcc4188SMatthias Ringwald# fdk-aac 95*4bcc4188SMatthias Ringwaldpkg_check_modules(FDK_AAC fdk-aac) 96*4bcc4188SMatthias Ringwaldif(FDK_AAC_FOUND) 97*4bcc4188SMatthias Ringwald message("HAVE_AAC_FDK") 98*4bcc4188SMatthias Ringwald include_directories(${FDK_AAC_INCLUDE_DIRS}) 99*4bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${FDK_AAC_LIBRARY_DIRS}) 100*4bcc4188SMatthias Ringwald target_link_libraries(btstack ${FDK_AAC_LIBRARIES}) 101*4bcc4188SMatthias Ringwald add_compile_definitions(HAVE_AAC_FDK) 102*4bcc4188SMatthias Ringwaldendif() 103*4bcc4188SMatthias Ringwald 104*4bcc4188SMatthias Ringwald# ldac encoder 105*4bcc4188SMatthias Ringwaldpkg_check_modules(LDAC_ENCODER ldacBT-enc) 106*4bcc4188SMatthias Ringwaldif (LDAC_ENCODER_FOUND) 107*4bcc4188SMatthias Ringwald message("HAVE_LDAC_ENCODER") 108*4bcc4188SMatthias Ringwald include_directories(${LDAC_ENCODER_INCLUDE_DIRS}) 109*4bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${LDAC_ENCODER_LIBRARY_DIRS}) 110*4bcc4188SMatthias Ringwald target_link_libraries(btstack ${LDAC_ENCODER_LIBRARIES}) 111*4bcc4188SMatthias Ringwald add_compile_definitions(HAVE_LDAC_ENCODER) 112*4bcc4188SMatthias Ringwaldendif() 113*4bcc4188SMatthias Ringwald 114*4bcc4188SMatthias Ringwald# ldac decoder 115*4bcc4188SMatthias Ringwaldpkg_check_modules(LDAC_DECODER libldacdec) 116*4bcc4188SMatthias Ringwaldif (LDAC_DECODER_FOUND) 117*4bcc4188SMatthias Ringwald message("HAVE_LDAC_DECODER") 118*4bcc4188SMatthias Ringwald include_directories(${LDAC_DECODER_INCLUDE_DIRS}) 119*4bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${LDAC_DECODER_LIBRARY_DIRS}) 120*4bcc4188SMatthias Ringwald target_link_libraries(btstack ${LDAC_DECODER_LIBRARIES}) 121*4bcc4188SMatthias Ringwald add_compile_definitions(HAVE_LDAC_DECODER) 122*4bcc4188SMatthias Ringwaldendif() 123*4bcc4188SMatthias Ringwald 124*4bcc4188SMatthias Ringwald# openaptx 125*4bcc4188SMatthias Ringwaldpkg_check_modules(APTX libopenaptx) 126*4bcc4188SMatthias Ringwaldif (APTX_FOUND) 127*4bcc4188SMatthias Ringwald message("HAVE_APTX") 128*4bcc4188SMatthias Ringwald include_directories(${APTX_INCLUDE_DIRS}) 129*4bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${APTX_LIBRARY_DIRS}) 130*4bcc4188SMatthias Ringwald target_link_libraries(btstack ${APTX_LIBRARIES}) 131*4bcc4188SMatthias Ringwald add_compile_definitions(HAVE_APTX) 132*4bcc4188SMatthias Ringwaldendif() 133*4bcc4188SMatthias Ringwald 134*4bcc4188SMatthias Ringwald# lc3plus 135*4bcc4188SMatthias Ringwaldpkg_check_modules(LC3PLUS LC3plus) 136*4bcc4188SMatthias Ringwaldif(LC3PLUS_FOUND) 137*4bcc4188SMatthias Ringwald message("HAVE_LC3PLUS") 138*4bcc4188SMatthias Ringwald include_directories(${LC3PLUS_INCLUDE_DIRS}) 139*4bcc4188SMatthias Ringwald target_link_directories(btstack ${LC3PLUS_LIBRARY_DIRS}) 140*4bcc4188SMatthias Ringwald target_link_libraries(btstack ${LC3PLUS_LIBRARIES}) 141*4bcc4188SMatthias Ringwald add_compile_definitions(HAVE_LC3PLUS) 142*4bcc4188SMatthias Ringwaldendif() 143*4bcc4188SMatthias Ringwald 14410277393SMatthias Ringwald# create targets for all examples 145533ea81fSMatthias Ringwaldfile(GLOB EXAMPLES_C "le_audio_*.c" "lc3_*.c") 14610277393SMatthias Ringwaldlist(SORT EXAMPLES_C) 14710277393SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt") 14810277393SMatthias Ringwald 14910277393SMatthias Ringwald# create targets 15010277393SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C}) 15110277393SMatthias Ringwald get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE) 15208fd7607SMatthias Ringwald set(SOURCE_FILES ${EXAMPLE_FILE}) 15310277393SMatthias Ringwald 15410277393SMatthias Ringwald # add GATT DB creation 15510277393SMatthias Ringwald if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} ) 15610277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE} -- with GATT DB") 15710277393SMatthias Ringwald add_custom_command( 15810277393SMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 15910277393SMatthias Ringwald DEPENDS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt 16010277393SMatthias Ringwald COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py 16110277393SMatthias Ringwald ARGS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 16210277393SMatthias Ringwald ) 16310277393SMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 16410277393SMatthias Ringwald else() 16510277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE}") 16610277393SMatthias Ringwald endif() 16708fd7607SMatthias Ringwald add_executable(${EXAMPLE} ${SOURCE_FILES} ) 1682fe0253dSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack m pthread) 16910277393SMatthias Ringwaldendforeach(EXAMPLE_FILE) 170