Skip to content

Update cmakelist.txt file to support compiling in ESP IDF #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
cmake_minimum_required(VERSION 3.16)

# set the project name
project(arduino_helix)
if (DEFINED ESP_PLATFORM)
# idf component
idf_component_register(
SRC_DIRS src src/utils src/libhelix-aac src/libhelix-mp3
INCLUDE_DIRS src src/utils src/libhelix-aac src/libhelix-mp3
REQUIRES arduino-esp32
)

# lots of warnings and all warnings as errors
## add_compile_options(-Wall -Wextra )
set(CMAKE_CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} INTERFACE -Wno-error -Wno-format)
target_compile_options(${COMPONENT_LIB} PRIVATE -DUSE_DEFAULT_STDLIB)
add_compile_definitions(ESP32)
else()

option(MP3_EXAMPLES "build examples" OFF)
# set the project name
project(arduino_helix)

file(GLOB_RECURSE SRC_LIST_C CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/*.c" )
file(GLOB_RECURSE SRC_LIST_CPP CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/*.cpp" )
# lots of warnings and all warnings as errors
## add_compile_options(-Wall -Wextra )
set(CMAKE_CXX_STANDARD 17)

# define libraries
add_library (arduino_helix ${SRC_LIST_C} ${SRC_LIST_CPP})
option(MP3_EXAMPLES "build examples" OFF)

# prevent compile errors
target_compile_options(arduino_helix PRIVATE -DUSE_DEFAULT_STDLIB)
file(GLOB_RECURSE SRC_LIST_C CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/*.c" )
file(GLOB_RECURSE SRC_LIST_CPP CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/*.cpp" )

# define location for header files
target_include_directories(arduino_helix PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/libhelix-mp3 ${CMAKE_CURRENT_SOURCE_DIR}/src/libhelix-aac )
# define libraries
add_library (arduino_helix ${SRC_LIST_C} ${SRC_LIST_CPP})

# build examples
if(MP3_EXAMPLES)
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/examples/output_mp3")
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/examples/output_aac")
# prevent compile errors
target_compile_options(arduino_helix PRIVATE -DUSE_DEFAULT_STDLIB)

# define location for header files
target_include_directories(arduino_helix PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/libhelix-mp3 ${CMAKE_CURRENT_SOURCE_DIR}/src/libhelix-aac )

# build examples
if(MP3_EXAMPLES)
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/examples/output_mp3")
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/examples/output_aac")
endif()
endif()