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") 40*b8cf9cc0SMatthias Ringwaldfile(GLOB SOURCES_LE_AUDIO "../../src/le-audio/*.c" "../../src/le-audio/gatt-service/*.c" "../../example/le_audio_demo_util_*.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 824bcc4188SMatthias Ringwald# find pkgconfig 834bcc4188SMatthias Ringwaldfind_package(PkgConfig REQUIRED) 844bcc4188SMatthias Ringwald 854bcc4188SMatthias Ringwald# portaudio 864bcc4188SMatthias Ringwaldpkg_check_modules(PORTAUDIO portaudio-2.0) 874bcc4188SMatthias Ringwaldif(PORTAUDIO_FOUND) 884bcc4188SMatthias Ringwald include_directories(${PORTAUDIO_INCLUDE_DIRS}) 894bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) 904bcc4188SMatthias Ringwald target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) 914bcc4188SMatthias Ringwald add_compile_definitions(HAVE_PORTAUDIO) 924bcc4188SMatthias Ringwaldendif() 934bcc4188SMatthias Ringwald 944bcc4188SMatthias Ringwald# fdk-aac 954bcc4188SMatthias Ringwaldpkg_check_modules(FDK_AAC fdk-aac) 964bcc4188SMatthias Ringwaldif(FDK_AAC_FOUND) 974bcc4188SMatthias Ringwald message("HAVE_AAC_FDK") 984bcc4188SMatthias Ringwald include_directories(${FDK_AAC_INCLUDE_DIRS}) 994bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${FDK_AAC_LIBRARY_DIRS}) 1004bcc4188SMatthias Ringwald target_link_libraries(btstack ${FDK_AAC_LIBRARIES}) 1014bcc4188SMatthias Ringwald add_compile_definitions(HAVE_AAC_FDK) 1024bcc4188SMatthias Ringwaldendif() 1034bcc4188SMatthias Ringwald 1044bcc4188SMatthias Ringwald# ldac encoder 1054bcc4188SMatthias Ringwaldpkg_check_modules(LDAC_ENCODER ldacBT-enc) 1064bcc4188SMatthias Ringwaldif (LDAC_ENCODER_FOUND) 1074bcc4188SMatthias Ringwald message("HAVE_LDAC_ENCODER") 1084bcc4188SMatthias Ringwald include_directories(${LDAC_ENCODER_INCLUDE_DIRS}) 1094bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${LDAC_ENCODER_LIBRARY_DIRS}) 1104bcc4188SMatthias Ringwald target_link_libraries(btstack ${LDAC_ENCODER_LIBRARIES}) 1114bcc4188SMatthias Ringwald add_compile_definitions(HAVE_LDAC_ENCODER) 1124bcc4188SMatthias Ringwaldendif() 1134bcc4188SMatthias Ringwald 1144bcc4188SMatthias Ringwald# ldac decoder 1154bcc4188SMatthias Ringwaldpkg_check_modules(LDAC_DECODER libldacdec) 1164bcc4188SMatthias Ringwaldif (LDAC_DECODER_FOUND) 1174bcc4188SMatthias Ringwald message("HAVE_LDAC_DECODER") 1184bcc4188SMatthias Ringwald include_directories(${LDAC_DECODER_INCLUDE_DIRS}) 1194bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${LDAC_DECODER_LIBRARY_DIRS}) 1204bcc4188SMatthias Ringwald target_link_libraries(btstack ${LDAC_DECODER_LIBRARIES}) 1214bcc4188SMatthias Ringwald add_compile_definitions(HAVE_LDAC_DECODER) 1224bcc4188SMatthias Ringwaldendif() 1234bcc4188SMatthias Ringwald 1244bcc4188SMatthias Ringwald# openaptx 1254bcc4188SMatthias Ringwaldpkg_check_modules(APTX libopenaptx) 1264bcc4188SMatthias Ringwaldif (APTX_FOUND) 1274bcc4188SMatthias Ringwald message("HAVE_APTX") 1284bcc4188SMatthias Ringwald include_directories(${APTX_INCLUDE_DIRS}) 1294bcc4188SMatthias Ringwald target_link_directories(btstack PUBLIC ${APTX_LIBRARY_DIRS}) 1304bcc4188SMatthias Ringwald target_link_libraries(btstack ${APTX_LIBRARIES}) 1314bcc4188SMatthias Ringwald add_compile_definitions(HAVE_APTX) 1324bcc4188SMatthias Ringwaldendif() 1334bcc4188SMatthias Ringwald 1344bcc4188SMatthias Ringwald# lc3plus 1354bcc4188SMatthias Ringwaldpkg_check_modules(LC3PLUS LC3plus) 1364bcc4188SMatthias Ringwaldif(LC3PLUS_FOUND) 1374bcc4188SMatthias Ringwald message("HAVE_LC3PLUS") 1384bcc4188SMatthias Ringwald include_directories(${LC3PLUS_INCLUDE_DIRS}) 1391eafc990SEdison David target_link_directories(btstack PUBLIC ${LC3PLUS_LIBRARY_DIRS}) 1404bcc4188SMatthias Ringwald target_link_libraries(btstack ${LC3PLUS_LIBRARIES}) 1411eafc990SEdison David add_definitions(${LC3PLUS_CFLAGS}) 1424bcc4188SMatthias Ringwald add_compile_definitions(HAVE_LC3PLUS) 1434bcc4188SMatthias Ringwaldendif() 1444bcc4188SMatthias Ringwald 14510277393SMatthias Ringwald# create targets for all examples 146533ea81fSMatthias Ringwaldfile(GLOB EXAMPLES_C "le_audio_*.c" "lc3_*.c") 14710277393SMatthias Ringwaldlist(SORT EXAMPLES_C) 14810277393SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt") 14910277393SMatthias Ringwald 15010277393SMatthias Ringwald# create targets 15110277393SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C}) 15210277393SMatthias Ringwald get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE) 15308fd7607SMatthias Ringwald set(SOURCE_FILES ${EXAMPLE_FILE}) 15410277393SMatthias Ringwald 15510277393SMatthias Ringwald # add GATT DB creation 15610277393SMatthias Ringwald if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} ) 15710277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE} -- with GATT DB") 15810277393SMatthias Ringwald add_custom_command( 15910277393SMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 16010277393SMatthias Ringwald DEPENDS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt 16110277393SMatthias Ringwald COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py 16210277393SMatthias Ringwald ARGS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 16310277393SMatthias Ringwald ) 16410277393SMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 16510277393SMatthias Ringwald else() 16610277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE}") 16710277393SMatthias Ringwald endif() 16808fd7607SMatthias Ringwald add_executable(${EXAMPLE} ${SOURCE_FILES} ) 1692fe0253dSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack m pthread) 17010277393SMatthias Ringwaldendforeach(EXAMPLE_FILE) 171