110277393SMatthias Ringwaldcmake_minimum_required (VERSION 3.12) 210277393SMatthias Ringwaldproject(BTstack-LE-Audio) 310277393SMatthias Ringwaldset (CMAKE_CXX_STANDARD 11) 410277393SMatthias Ringwald 510277393SMatthias Ringwald# fink pkgconfig 610277393SMatthias Ringwaldfind_package(PkgConfig REQUIRED) 710277393SMatthias Ringwald 810277393SMatthias Ringwald# portaudio 910277393SMatthias Ringwaldpkg_check_modules(PORTAUDIO portaudio-2.0) 1010277393SMatthias Ringwaldif(PORTAUDIO_FOUND) 1110277393SMatthias Ringwald include_directories(${PORTAUDIO_INCLUDE_DIRS}) 1210277393SMatthias Ringwald link_directories(${PORTAUDIO_LIBRARY_DIRS}) 1310277393SMatthias Ringwald link_libraries(${PORTAUDIO_LIBRARIES}) 1410277393SMatthias Ringwald add_compile_definitions(HAVE_PORTAUDIO) 1510277393SMatthias Ringwaldendif() 1610277393SMatthias Ringwald 1710277393SMatthias Ringwald# fdk-aac 1810277393SMatthias Ringwaldpkg_check_modules(FDK_AAC fdk-aac) 1910277393SMatthias Ringwaldif(FDK_AAC_FOUND) 2010277393SMatthias Ringwald message("HAVE_AAC_FDK") 2110277393SMatthias Ringwald include_directories(${FDK_AAC_INCLUDE_DIRS}) 2210277393SMatthias Ringwald link_directories(${FDK_AAC_LIBRARY_DIRS}) 2310277393SMatthias Ringwald link_libraries(${FDK_AAC_LIBRARIES}) 2410277393SMatthias Ringwald add_compile_definitions(HAVE_AAC_FDK) 2510277393SMatthias Ringwaldendif() 2610277393SMatthias Ringwald 2710277393SMatthias Ringwald# ldac encoder 2810277393SMatthias Ringwaldpkg_check_modules(LDAC_ENCODER ldacBT-enc) 2910277393SMatthias Ringwaldif (LDAC_ENCODER_FOUND) 3010277393SMatthias Ringwald message("HAVE_LDAC_ENCODER") 3110277393SMatthias Ringwald include_directories(${LDAC_ENCODER_INCLUDE_DIRS}) 3210277393SMatthias Ringwald link_directories(${LDAC_ENCODER_LIBRARY_DIRS}) 3310277393SMatthias Ringwald link_libraries(${LDAC_ENCODER_LIBRARIES}) 3410277393SMatthias Ringwald add_compile_definitions(HAVE_LDAC_ENCODER) 3510277393SMatthias Ringwaldendif() 3610277393SMatthias Ringwald 3710277393SMatthias Ringwald# ldac decoder 3810277393SMatthias Ringwaldpkg_check_modules(LDAC_DECODER libldacdec) 3910277393SMatthias Ringwaldif (LDAC_DECODER_FOUND) 4010277393SMatthias Ringwald message("HAVE_LDAC_DECODER") 4110277393SMatthias Ringwald include_directories(${LDAC_DECODER_INCLUDE_DIRS}) 4210277393SMatthias Ringwald link_directories(${LDAC_DECODER_LIBRARY_DIRS}) 4310277393SMatthias Ringwald link_libraries(${LDAC_DECODER_LIBRARIES}) 4410277393SMatthias Ringwald add_compile_definitions(HAVE_LDAC_DECODER) 4510277393SMatthias Ringwaldendif() 4610277393SMatthias Ringwald 4710277393SMatthias Ringwald# openaptx 4810277393SMatthias Ringwaldpkg_check_modules(APTX libopenaptx) 4910277393SMatthias Ringwaldif (APTX_FOUND) 5010277393SMatthias Ringwald message("HAVE_APTX") 5110277393SMatthias Ringwald include_directories(${APTX_INCLUDE_DIRS}) 5210277393SMatthias Ringwald link_directories(${APTX_LIBRARY_DIRS}) 5310277393SMatthias Ringwald link_libraries(${APTX_LIBRARIES}) 5410277393SMatthias Ringwald add_compile_definitions(HAVE_APTX) 5510277393SMatthias Ringwaldendif() 5610277393SMatthias Ringwald 57ab05be60SMatthias Ringwald# lc3plus 58ab05be60SMatthias Ringwaldpkg_check_modules(LC3PLUS LC3plus) 59ab05be60SMatthias Ringwaldif(LC3PLUS_FOUND) 60ab05be60SMatthias Ringwald message("HAVE_LC3PLUS") 61ab05be60SMatthias Ringwald include_directories(${LC3PLUS_INCLUDE_DIRS}) 62ab05be60SMatthias Ringwald link_directories(${LC3PLUS_LIBRARY_DIRS}) 63ab05be60SMatthias Ringwald link_libraries(${LC3PLUS_LIBRARIES}) 64ab05be60SMatthias Ringwald add_definitions(${LC3PLUS_CFLAGS}) 65ab05be60SMatthias Ringwald add_compile_definitions(HAVE_LC3PLUS) 66ab05be60SMatthias Ringwaldendif() 67ab05be60SMatthias Ringwald 6810277393SMatthias Ringwald# enable optional features 6910277393SMatthias Ringwaldadd_compile_definitions(ENABLE_TESTING_SUPPORT) 7010277393SMatthias Ringwald 7110277393SMatthias Ringwald# to find generated .h from .gatt files 7210277393SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 7310277393SMatthias Ringwald 7410277393SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 759162c232SMatthias Ringwaldinclude_directories(include) 7610277393SMatthias Ringwald 7710277393SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 7810277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include) 7910277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include) 8010277393SMatthias Ringwaldinclude_directories(../../3rd-party/md5) 8110277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 8210277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 83e40ee29aSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 8410277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/core/src/include) 8510277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/dhcp-server) 8610277393SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 8710277393SMatthias Ringwaldinclude_directories(../../3rd-party/yxml) 8810277393SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir) 8910277393SMatthias Ringwaldinclude_directories(../../src) 9010277393SMatthias Ringwaldinclude_directories(../../example) 9110277393SMatthias Ringwaldinclude_directories(../../chipset/zephyr) 920c608997SMatthias Ringwaldinclude_directories(../../chipset/bcm) 9310277393SMatthias Ringwaldinclude_directories(../../platform/posix) 9410277393SMatthias Ringwaldinclude_directories(../../platform/embedded) 9510277393SMatthias Ringwaldinclude_directories(../../platform/lwip) 9610277393SMatthias Ringwaldinclude_directories(../../platform/lwip/port) 9710277393SMatthias Ringwald 9810277393SMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../src/*.cpp" "../../example/sco_demo_util.c") 9910277393SMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 10010277393SMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 10110277393SMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "../../src/classic/*.c") 1025deb0bb6SMatthias Ringwaldfile(GLOB SOURCES_LE_AUDIO "../../src/le-audio/*.c" "../../src/le-audio/gatt-service/*.c") 10310277393SMatthias Ringwaldfile(GLOB SOURCES_MESH "../../src/mesh/*.c") 10410277393SMatthias Ringwaldfile(GLOB SOURCES_MD5 "../../3rd-party/md5/md5.c") 10510277393SMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 10610277393SMatthias Ringwaldfile(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") 10710277393SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 10810277393SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 10910277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX "../../platform/posix/*.c") 110*d60a1028SMatthias Ringwaldfile(GLOB SOURCES_MAIN main.c) 11110277393SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 1120c608997SMatthias Ringwaldfile(GLOB SOURCES_BCM "../../chipset/bcm/*.c") 113e40ee29aSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 11410277393SMatthias Ringwald 11510277393SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 11610277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 11710277393SMatthias Ringwald 11810277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c") 11910277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 12010277393SMatthias Ringwald 12110277393SMatthias Ringwaldset(SOURCES 12210277393SMatthias Ringwald ${SOURCES_MD5} 12310277393SMatthias Ringwald ${SOURCES_YXML} 124e40ee29aSMatthias Ringwald ${SOURCES_LC3_GOOGLE} 12510277393SMatthias Ringwald ${SOURCES_POSIX} 12610277393SMatthias Ringwald ${SOURCES_MAIN} 12710277393SMatthias Ringwald ${SOURCES_RIJNDAEL} 12810277393SMatthias Ringwald ${SOURCES_SRC} 12910277393SMatthias Ringwald ${SOURCES_BLE} 13010277393SMatthias Ringwald ${SOURCES_GATT} 1315deb0bb6SMatthias Ringwald ${SOURCES_LE_AUDIO} 13210277393SMatthias Ringwald ${SOURCES_MESH} 13310277393SMatthias Ringwald ${SOURCES_CLASSIC} 13410277393SMatthias Ringwald ${SOURCES_UECC} 13510277393SMatthias Ringwald ${SOURCES_HXCMOD} 13610277393SMatthias Ringwald ${SOURCES_ZEPHYR} 1370c608997SMatthias Ringwald ${SOURCES_BCM} 13810277393SMatthias Ringwald) 13910277393SMatthias Ringwaldlist(SORT SOURCES) 14010277393SMatthias Ringwald 14110277393SMatthias Ringwald# create static lib 14210277393SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 14310277393SMatthias 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