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# libusb 910277393SMatthias Ringwaldpkg_check_modules(LIBUSB REQUIRED libusb-1.0) 1010277393SMatthias Ringwaldinclude_directories(${LIBUSB_INCLUDE_DIRS}) 1110277393SMatthias Ringwaldlink_directories(${LIBUSB_LIBRARY_DIRS}) 1210277393SMatthias Ringwaldlink_libraries(${LIBUSB_LIBRARIES}) 1310277393SMatthias Ringwald 1410277393SMatthias Ringwald# portaudio 1510277393SMatthias Ringwaldpkg_check_modules(PORTAUDIO portaudio-2.0) 1610277393SMatthias Ringwaldif(PORTAUDIO_FOUND) 1710277393SMatthias Ringwald include_directories(${PORTAUDIO_INCLUDE_DIRS}) 1810277393SMatthias Ringwald link_directories(${PORTAUDIO_LIBRARY_DIRS}) 1910277393SMatthias Ringwald link_libraries(${PORTAUDIO_LIBRARIES}) 2010277393SMatthias Ringwald add_compile_definitions(HAVE_PORTAUDIO) 2110277393SMatthias Ringwaldendif() 2210277393SMatthias Ringwald 2310277393SMatthias Ringwald# fdk-aac 2410277393SMatthias Ringwaldpkg_check_modules(FDK_AAC fdk-aac) 2510277393SMatthias Ringwaldif(FDK_AAC_FOUND) 2610277393SMatthias Ringwald message("HAVE_AAC_FDK") 2710277393SMatthias Ringwald include_directories(${FDK_AAC_INCLUDE_DIRS}) 2810277393SMatthias Ringwald link_directories(${FDK_AAC_LIBRARY_DIRS}) 2910277393SMatthias Ringwald link_libraries(${FDK_AAC_LIBRARIES}) 3010277393SMatthias Ringwald add_compile_definitions(HAVE_AAC_FDK) 3110277393SMatthias Ringwaldendif() 3210277393SMatthias Ringwald 3310277393SMatthias Ringwald# ldac encoder 3410277393SMatthias Ringwaldpkg_check_modules(LDAC_ENCODER ldacBT-enc) 3510277393SMatthias Ringwaldif (LDAC_ENCODER_FOUND) 3610277393SMatthias Ringwald message("HAVE_LDAC_ENCODER") 3710277393SMatthias Ringwald include_directories(${LDAC_ENCODER_INCLUDE_DIRS}) 3810277393SMatthias Ringwald link_directories(${LDAC_ENCODER_LIBRARY_DIRS}) 3910277393SMatthias Ringwald link_libraries(${LDAC_ENCODER_LIBRARIES}) 4010277393SMatthias Ringwald add_compile_definitions(HAVE_LDAC_ENCODER) 4110277393SMatthias Ringwaldendif() 4210277393SMatthias Ringwald 4310277393SMatthias Ringwald# ldac decoder 4410277393SMatthias Ringwaldpkg_check_modules(LDAC_DECODER libldacdec) 4510277393SMatthias Ringwaldif (LDAC_DECODER_FOUND) 4610277393SMatthias Ringwald message("HAVE_LDAC_DECODER") 4710277393SMatthias Ringwald include_directories(${LDAC_DECODER_INCLUDE_DIRS}) 4810277393SMatthias Ringwald link_directories(${LDAC_DECODER_LIBRARY_DIRS}) 4910277393SMatthias Ringwald link_libraries(${LDAC_DECODER_LIBRARIES}) 5010277393SMatthias Ringwald add_compile_definitions(HAVE_LDAC_DECODER) 5110277393SMatthias Ringwaldendif() 5210277393SMatthias Ringwald 5310277393SMatthias Ringwald# openaptx 5410277393SMatthias Ringwaldpkg_check_modules(APTX libopenaptx) 5510277393SMatthias Ringwaldif (APTX_FOUND) 5610277393SMatthias Ringwald message("HAVE_APTX") 5710277393SMatthias Ringwald include_directories(${APTX_INCLUDE_DIRS}) 5810277393SMatthias Ringwald link_directories(${APTX_LIBRARY_DIRS}) 5910277393SMatthias Ringwald link_libraries(${APTX_LIBRARIES}) 6010277393SMatthias Ringwald add_compile_definitions(HAVE_APTX) 6110277393SMatthias Ringwaldendif() 6210277393SMatthias Ringwald 6310277393SMatthias Ringwald# enable optional features 6410277393SMatthias Ringwaldadd_compile_definitions(ENABLE_TESTING_SUPPORT) 6510277393SMatthias Ringwald 6610277393SMatthias Ringwald# to find generated .h from .gatt files 6710277393SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 6810277393SMatthias Ringwald 6910277393SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 7010277393SMatthias Ringwaldinclude_directories(.) 7110277393SMatthias Ringwald 7210277393SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 7310277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include) 7410277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include) 7510277393SMatthias Ringwaldinclude_directories(../../3rd-party/md5) 7610277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 7710277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 78*e40ee29aSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 7910277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/core/src/include) 8010277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/dhcp-server) 8110277393SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 8210277393SMatthias Ringwaldinclude_directories(../../3rd-party/yxml) 8310277393SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir) 8410277393SMatthias Ringwaldinclude_directories(../../src) 8510277393SMatthias Ringwaldinclude_directories(../../example) 8610277393SMatthias Ringwaldinclude_directories(../../chipset/zephyr) 8710277393SMatthias Ringwaldinclude_directories(../../platform/posix) 8810277393SMatthias Ringwaldinclude_directories(../../platform/embedded) 8910277393SMatthias Ringwaldinclude_directories(../../platform/lwip) 9010277393SMatthias Ringwaldinclude_directories(../../platform/lwip/port) 9110277393SMatthias Ringwald 9210277393SMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../src/*.cpp" "../../example/sco_demo_util.c") 9310277393SMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 9410277393SMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 9510277393SMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "../../src/classic/*.c") 9610277393SMatthias Ringwaldfile(GLOB SOURCES_MESH "../../src/mesh/*.c") 9710277393SMatthias Ringwaldfile(GLOB SOURCES_MD5 "../../3rd-party/md5/md5.c") 9810277393SMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 9910277393SMatthias Ringwaldfile(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") 10010277393SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 10110277393SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 10210277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX "../../platform/posix/*.c") 10310277393SMatthias Ringwaldfile(GLOB SOURCES_MAIN "main.c") 10410277393SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 105*e40ee29aSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 10610277393SMatthias Ringwald 10710277393SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 10810277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 10910277393SMatthias Ringwald 11010277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c") 11110277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 11210277393SMatthias Ringwald 11310277393SMatthias Ringwaldset(SOURCES 11410277393SMatthias Ringwald ${SOURCES_MD5} 11510277393SMatthias Ringwald ${SOURCES_YXML} 116*e40ee29aSMatthias Ringwald ${SOURCES_LC3_GOOGLE} 11710277393SMatthias Ringwald ${SOURCES_POSIX} 11810277393SMatthias Ringwald ${SOURCES_MAIN} 11910277393SMatthias Ringwald ${SOURCES_RIJNDAEL} 12010277393SMatthias Ringwald ${SOURCES_SRC} 12110277393SMatthias Ringwald ${SOURCES_BLE} 12210277393SMatthias Ringwald ${SOURCES_GATT} 12310277393SMatthias Ringwald ${SOURCES_MESH} 12410277393SMatthias Ringwald ${SOURCES_CLASSIC} 12510277393SMatthias Ringwald ${SOURCES_UECC} 12610277393SMatthias Ringwald ${SOURCES_HXCMOD} 12710277393SMatthias Ringwald ${SOURCES_ZEPHYR} 12810277393SMatthias Ringwald) 12910277393SMatthias Ringwaldlist(SORT SOURCES) 13010277393SMatthias Ringwald 13110277393SMatthias Ringwald# Enable ASAN 13210277393SMatthias Ringwaldadd_compile_options( -g -fsanitize=address) 13310277393SMatthias Ringwaldadd_link_options( -fsanitize=address) 13410277393SMatthias Ringwald 13510277393SMatthias Ringwald# create static lib 13610277393SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 13710277393SMatthias Ringwald 13810277393SMatthias Ringwald# create targets for all examples 13910277393SMatthias Ringwaldfile(GLOB EXAMPLES_C "le_audio_*.c") 14010277393SMatthias Ringwaldlist(SORT EXAMPLES_C) 14110277393SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt") 14210277393SMatthias Ringwald 14310277393SMatthias Ringwald# create targets 14410277393SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C}) 14510277393SMatthias Ringwald get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE) 14610277393SMatthias Ringwald 14710277393SMatthias Ringwald # add GATT DB creation 14810277393SMatthias Ringwald if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} ) 14910277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE} -- with GATT DB") 15010277393SMatthias Ringwald add_custom_command( 15110277393SMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 15210277393SMatthias Ringwald DEPENDS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt 15310277393SMatthias Ringwald COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py 15410277393SMatthias Ringwald ARGS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 15510277393SMatthias Ringwald ) 15610277393SMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 15710277393SMatthias Ringwald else() 15810277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE}") 15910277393SMatthias Ringwald endif() 16010277393SMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE} ) 16110277393SMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 16210277393SMatthias Ringwaldendforeach(EXAMPLE_FILE) 163