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 5710277393SMatthias Ringwald# enable optional features 5810277393SMatthias Ringwaldadd_compile_definitions(ENABLE_TESTING_SUPPORT) 5910277393SMatthias Ringwald 6010277393SMatthias Ringwald# to find generated .h from .gatt files 6110277393SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR}) 6210277393SMatthias Ringwald 6310277393SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile 6410277393SMatthias Ringwaldinclude_directories(.) 6510277393SMatthias Ringwald 6610277393SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 6710277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include) 6810277393SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include) 6910277393SMatthias Ringwaldinclude_directories(../../3rd-party/md5) 7010277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player) 7110277393SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod) 72e40ee29aSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include) 7310277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/core/src/include) 7410277393SMatthias Ringwaldinclude_directories(../../3rd-party/lwip/dhcp-server) 7510277393SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 7610277393SMatthias Ringwaldinclude_directories(../../3rd-party/yxml) 7710277393SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir) 7810277393SMatthias Ringwaldinclude_directories(../../src) 7910277393SMatthias Ringwaldinclude_directories(../../example) 8010277393SMatthias Ringwaldinclude_directories(../../chipset/zephyr) 8110277393SMatthias Ringwaldinclude_directories(../../platform/posix) 8210277393SMatthias Ringwaldinclude_directories(../../platform/embedded) 8310277393SMatthias Ringwaldinclude_directories(../../platform/lwip) 8410277393SMatthias Ringwaldinclude_directories(../../platform/lwip/port) 8510277393SMatthias Ringwald 8610277393SMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../src/*.cpp" "../../example/sco_demo_util.c") 8710277393SMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c") 8810277393SMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c") 8910277393SMatthias Ringwaldfile(GLOB SOURCES_CLASSIC "../../src/classic/*.c") 9010277393SMatthias Ringwaldfile(GLOB SOURCES_MESH "../../src/mesh/*.c") 9110277393SMatthias Ringwaldfile(GLOB SOURCES_MD5 "../../3rd-party/md5/md5.c") 9210277393SMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c") 9310277393SMatthias Ringwaldfile(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") 9410277393SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD "../../3rd-party/hxcmod-player/*.c" "../../3rd-party/hxcmod-player/mods/*.c") 9510277393SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") 9610277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX "../../platform/posix/*.c") 9710277393SMatthias Ringwaldfile(GLOB SOURCES_MAIN "main.c") 9810277393SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") 99e40ee29aSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") 10010277393SMatthias Ringwald 10110277393SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") 10210277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) 10310277393SMatthias Ringwald 10410277393SMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c") 10510277393SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF}) 10610277393SMatthias Ringwald 10710277393SMatthias Ringwaldset(SOURCES 10810277393SMatthias Ringwald ${SOURCES_MD5} 10910277393SMatthias Ringwald ${SOURCES_YXML} 110e40ee29aSMatthias Ringwald ${SOURCES_LC3_GOOGLE} 11110277393SMatthias Ringwald ${SOURCES_POSIX} 11210277393SMatthias Ringwald ${SOURCES_MAIN} 11310277393SMatthias Ringwald ${SOURCES_RIJNDAEL} 11410277393SMatthias Ringwald ${SOURCES_SRC} 11510277393SMatthias Ringwald ${SOURCES_BLE} 11610277393SMatthias Ringwald ${SOURCES_GATT} 11710277393SMatthias Ringwald ${SOURCES_MESH} 11810277393SMatthias Ringwald ${SOURCES_CLASSIC} 11910277393SMatthias Ringwald ${SOURCES_UECC} 12010277393SMatthias Ringwald ${SOURCES_HXCMOD} 12110277393SMatthias Ringwald ${SOURCES_ZEPHYR} 12210277393SMatthias Ringwald) 12310277393SMatthias Ringwaldlist(SORT SOURCES) 12410277393SMatthias Ringwald 12510277393SMatthias Ringwald# create static lib 12610277393SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 12710277393SMatthias Ringwald 12810277393SMatthias Ringwald# create targets for all examples 129*533ea81fSMatthias Ringwaldfile(GLOB EXAMPLES_C "le_audio_*.c" "lc3_*.c") 13010277393SMatthias Ringwaldlist(SORT EXAMPLES_C) 13110277393SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt") 13210277393SMatthias Ringwald 13310277393SMatthias Ringwald# create targets 13410277393SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C}) 13510277393SMatthias Ringwald get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE) 13610277393SMatthias Ringwald 13710277393SMatthias Ringwald # add GATT DB creation 13810277393SMatthias Ringwald if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} ) 13910277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE} -- with GATT DB") 14010277393SMatthias Ringwald add_custom_command( 14110277393SMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 14210277393SMatthias Ringwald DEPENDS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt 14310277393SMatthias Ringwald COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py 14410277393SMatthias Ringwald ARGS ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 14510277393SMatthias Ringwald ) 14610277393SMatthias Ringwald list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 14710277393SMatthias Ringwald else() 14810277393SMatthias Ringwald message("LE Audio Tool: ${EXAMPLE}") 14910277393SMatthias Ringwald endif() 15010277393SMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE} ) 1512fe0253dSMatthias Ringwald target_link_libraries(${EXAMPLE} btstack m pthread) 15210277393SMatthias Ringwaldendforeach(EXAMPLE_FILE) 153