mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
update cmake files
This commit is contained in:
@@ -12,8 +12,11 @@ add_definitions(-DBELL_USE_MBEDTLS)
|
|||||||
add_definitions(-Wno-unused-variable -Wno-unused-const-variable -Wchar-subscripts -Wunused-label -Wmaybe-uninitialized -Wmisleading-indentation)
|
add_definitions(-Wno-unused-variable -Wno-unused-const-variable -Wchar-subscripts -Wunused-label -Wmaybe-uninitialized -Wmisleading-indentation)
|
||||||
|
|
||||||
set(BELL_DISABLE_CODECS ON)
|
set(BELL_DISABLE_CODECS ON)
|
||||||
set(BELL_EXTERNAL_TREMOR "idf::codecs")
|
set(BELL_DISABLE_SINKS ON)
|
||||||
set(BELL_EXTERNAL_CJSON "idf::json")
|
set(CSPOT_TARGET_ESP32 ON)
|
||||||
|
# becase CMake is so broken, the cache set below overrides a normal "set" for the first build
|
||||||
|
set(BELL_EXTERNAL_TREMOR "idf::codecs" CACHE STRING "provide own codecs")
|
||||||
|
set(BELL_EXTERNAL_CJSON "idf::json" CACHE STRING "provide own CJSON")
|
||||||
|
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cspot ${CMAKE_CURRENT_BINARY_DIR}/cspot)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cspot ${CMAKE_CURRENT_BINARY_DIR}/cspot)
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE cspot ${EXTRA_REQ_LIBS})
|
target_link_libraries(${COMPONENT_LIB} PRIVATE cspot ${EXTRA_REQ_LIBS})
|
||||||
|
|||||||
@@ -25,26 +25,17 @@ if(UNIX AND NOT APPLE)
|
|||||||
# TODO: migrate from this to native linux mDNS
|
# TODO: migrate from this to native linux mDNS
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (GENERATE_PROTOS)
|
# Build protobuf code
|
||||||
file(GLOB SOURCES "src/*.cpp" "src/*.c")
|
set(NANOPB_OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
set(NANOPB_OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}")
|
file(GLOB PROTOS protobuf/*.proto)
|
||||||
set(PROTOS protobuf/authentication.proto protobuf/mercury.proto protobuf/keyexchange.proto protobuf/spirc.proto protobuf/metadata.proto)
|
nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH ${CMAKE_CURRENT_SOURCE_DIR} ${PROTOS})
|
||||||
message(${PROTOS})
|
add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
|
||||||
message("building protobuf")
|
set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS}
|
||||||
message(${CMAKE_CURRENT_SOURCE_DIR})
|
PROPERTIES GENERATED TRUE)
|
||||||
nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH ${CMAKE_CURRENT_SOURCE_DIR} ${PROTOS})
|
|
||||||
add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
|
|
||||||
set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} PROPERTIES GENERATED TRUE)
|
|
||||||
set(GENERATED_INCLUDES ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
else()
|
|
||||||
file(GLOB SOURCES "src/*.cpp" "src/*.c" "protobuf/*.c")
|
|
||||||
message("BEWARE => NOT GENERATING PROTOBUF")
|
|
||||||
set(GENERATED_INCLUDES ".")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(cspot STATIC ${SOURCES} ${PROTO_SRCS})
|
add_library(cspot STATIC ${SOURCES} ${PROTO_SRCS})
|
||||||
# PUBLIC to propagate includes from bell to cspot dependents
|
# PUBLIC to propagate includes from bell to cspot dependents
|
||||||
target_compile_definitions(bell PUBLIC PB_ENABLE_MALLOC)
|
target_compile_definitions(bell PUBLIC PB_ENABLE_MALLOC)
|
||||||
target_compile_definitions(bell PUBLIC PB_FIELD_32BIT)
|
target_compile_definitions(bell PUBLIC PB_FIELD_32BIT)
|
||||||
target_link_libraries(cspot PUBLIC ${EXTRA_LIBS})
|
target_link_libraries(cspot PUBLIC ${EXTRA_LIBS})
|
||||||
target_include_directories(cspot PUBLIC "include" ${GENERATED_INCLUDES} ${NANOPB_INCLUDE_DIRS})
|
target_include_directories(cspot PUBLIC "include" ${CMAKE_CURRENT_BINARY_DIR} ${NANOPB_INCLUDE_DIRS})
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
cmake_policy(SET CMP0077 NEW)
|
||||||
|
|
||||||
project(bell)
|
project(bell)
|
||||||
|
|
||||||
# Configurable options
|
# Configurable options
|
||||||
option(BELL_DISABLE_CODECS "Disable libhelix AAC and MP3 codecs" OFF)
|
option(BELL_DISABLE_CODECS "Disable libhelix AAC and MP3 codecs" OFF)
|
||||||
#set(BELL_EXTERNAL_CJSON "" CACHE STRING "External cJSON library target name, optional")
|
option(BELL_DISABLE_SINKS "Disable built-in audio sink implementations" OFF)
|
||||||
#set(BELL_EXTERNAL_TREMOR "" CACHE STRING "External tremor library target name, optional")
|
option(BELL_USE_ALSA "Enable ALSA sink" OFF)
|
||||||
|
option(BELL_USE_PORTAUDIO "Enable PortAudio sink" OFF)
|
||||||
|
set(BELL_EXTERNAL_CJSON "" CACHE STRING "External cJSON library target name, optional")
|
||||||
|
set(BELL_EXTERNAL_TREMOR "" CACHE STRING "External tremor library target name, optional")
|
||||||
|
|
||||||
# Include nanoPB library
|
# Include nanoPB library
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/nanopb/extra)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/nanopb/extra)
|
||||||
find_package(Nanopb REQUIRED)
|
find_package(Nanopb REQUIRED)
|
||||||
include_directories(${NANOPB_INCLUDE_DIRS})
|
list(APPEND EXTRA_INCLUDES ${NANOPB_INCLUDE_DIRS})
|
||||||
|
|
||||||
# CMake options
|
# CMake options
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
add_definitions(-DUSE_DEFAULT_STDLIB=1)
|
add_definitions(-DUSE_DEFAULT_STDLIB=1)
|
||||||
|
|
||||||
# Main library sources
|
# Main library sources
|
||||||
@@ -74,6 +79,33 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT BELL_DISABLE_SINKS)
|
||||||
|
set(PLATFORM "unix")
|
||||||
|
if(ESP_PLATFORM)
|
||||||
|
set(PLATFORM "esp")
|
||||||
|
endif()
|
||||||
|
# Add all built-in audio sinks
|
||||||
|
file(GLOB SINK_SOURCES "src/sinks/${PLATFORM}/*.cpp" "src/sinks/${PLATFORM}/*.c")
|
||||||
|
# Find ALSA if required, else remove the sink
|
||||||
|
if(BELL_USE_ALSA)
|
||||||
|
find_package(ALSA REQUIRED)
|
||||||
|
list(APPEND EXTRA_INCLUDES ${ALSA_INCLUDE_DIRS})
|
||||||
|
list(APPEND EXTRA_LIBS ${ALSA_LIBRARIES})
|
||||||
|
else()
|
||||||
|
list(REMOVE_ITEM SINK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/sinks/unix/ALSAAudioSink.cpp)
|
||||||
|
endif()
|
||||||
|
# Find PortAudio if required, else remove the sink
|
||||||
|
if(BELL_USE_PORTAUDIO)
|
||||||
|
find_package(portaudio REQUIRED)
|
||||||
|
list(APPEND EXTRA_INCLUDES ${PORTAUDIO_INCLUDE_DIRS})
|
||||||
|
list(APPEND EXTRA_LIBS ${PORTAUDIO_LIBRARIES})
|
||||||
|
else()
|
||||||
|
list(REMOVE_ITEM SINK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/sinks/unix/PortAudioSink.cpp)
|
||||||
|
endif()
|
||||||
|
list(APPEND SOURCES ${SINK_SOURCES})
|
||||||
|
list(APPEND EXTRA_INCLUDES "include/sinks/${PLATFORM}")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BELL_EXTERNAL_CJSON)
|
if(BELL_EXTERNAL_CJSON)
|
||||||
list(APPEND EXTRA_LIBS ${BELL_EXTERNAL_CJSON})
|
list(APPEND EXTRA_LIBS ${BELL_EXTERNAL_CJSON})
|
||||||
else()
|
else()
|
||||||
@@ -91,9 +123,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(bell STATIC ${SOURCES})
|
add_library(bell STATIC ${SOURCES})
|
||||||
|
|
||||||
message(${NANOPB_INCLUDE_DIRS})
|
|
||||||
# PUBLIC to propagate esp-idf includes to bell dependents
|
# PUBLIC to propagate esp-idf includes to bell dependents
|
||||||
target_link_libraries(bell PUBLIC ${EXTRA_LIBS})
|
target_link_libraries(bell PUBLIC ${EXTRA_LIBS})
|
||||||
target_include_directories(bell PUBLIC "include" ${EXTRA_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
|
target_include_directories(bell PUBLIC "include" "include/platform" ${EXTRA_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_compile_definitions(bell PUBLIC PB_ENABLE_MALLOC)
|
target_compile_definitions(bell PUBLIC PB_ENABLE_MALLOC)
|
||||||
|
|||||||
Reference in New Issue
Block a user