Skip to content

Commit ced575e

Browse files
committed
IDF as component
1 parent 185272c commit ced575e

File tree

1 file changed

+50
-35
lines changed

1 file changed

+50
-35
lines changed

CMakeLists.txt

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,65 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
# set the project name
4-
project(arduino-audio-tools)
3+
if (DEFINED ESP_PLATFORM)
54

6-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
7-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
8-
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
9-
add_compile_options(-Wno-deprecated-declarations)
5+
# idf component
6+
idf_component_register(
7+
SRC_DIRS src
8+
INCLUDE_DIRS src
9+
REQUIRES bt esp_common freertos hal log nvs_flash driver
10+
)
1011

11-
include(FetchContent)
12+
target_compile_options(${COMPONENT_LIB} PUBLIC -DESP32_CMAKE=1 -Wno-error -Wno-format -fpermissive)
1213

13-
add_library(arduino-audio-tools INTERFACE)
14+
else()
1415

15-
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
16-
option(ADD_PORTAUDIO "Add Portaudio Library" ON)
17-
option(ADD_ARDUINO_EMULATOR "Add Arduino Emulator Library" ON)
16+
# set the project name
17+
project(arduino-audio-tools)
1818

19+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
20+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
21+
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
22+
add_compile_options(-Wno-deprecated-declarations)
1923

20-
# make include directory available to calling projects
21-
target_include_directories (arduino-audio-tools INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
24+
include(FetchContent)
2225

23-
# installation of all header files
24-
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/" # source directory
25-
DESTINATION "include/arduino-audio-tools" # target directory
26-
FILES_MATCHING # install only matched files
27-
PATTERN "*.h" # select header files
28-
)
26+
add_library(arduino-audio-tools INTERFACE)
2927

30-
if (ADD_PORTAUDIO)
31-
add_compile_options(-DIS_DESKTOP)
32-
# Add Portaduio for desktop build
33-
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
34-
FetchContent_GetProperties(portaudio)
35-
if(NOT portaudio_POPULATED)
36-
FetchContent_Populate(portaudio)
37-
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
28+
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
29+
option(ADD_PORTAUDIO "Add Portaudio Library" ON)
30+
option(ADD_ARDUINO_EMULATOR "Add Arduino Emulator Library" ON)
31+
32+
33+
# make include directory available to calling projects
34+
target_include_directories (arduino-audio-tools INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
35+
36+
# installation of all header files
37+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/" # source directory
38+
DESTINATION "include/arduino-audio-tools" # target directory
39+
FILES_MATCHING # install only matched files
40+
PATTERN "*.h" # select header files
41+
)
42+
43+
if (ADD_PORTAUDIO)
44+
add_compile_options(-DIS_DESKTOP)
45+
# Add Portaduio for desktop build
46+
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
47+
FetchContent_GetProperties(portaudio)
48+
if(NOT portaudio_POPULATED)
49+
FetchContent_Populate(portaudio)
50+
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
51+
endif()
3852
endif()
39-
endif()
4053

4154

42-
if (ADD_ARDUINO_EMULATOR)
43-
# Build with Linux Arduino Emulator
44-
FetchContent_Declare(arduino_emulator GIT_REPOSITORY "https://github.com/pschatzmann/Arduino-Emulator.git" GIT_TAG main )
45-
FetchContent_GetProperties(arduino_emulator)
46-
if(NOT arduino_emulator_POPULATED)
47-
FetchContent_Populate(arduino_emulator)
48-
add_subdirectory(${arduino_emulator_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/emulator)
55+
if (ADD_ARDUINO_EMULATOR)
56+
# Build with Linux Arduino Emulator
57+
FetchContent_Declare(arduino_emulator GIT_REPOSITORY "https://github.com/pschatzmann/Arduino-Emulator.git" GIT_TAG main )
58+
FetchContent_GetProperties(arduino_emulator)
59+
if(NOT arduino_emulator_POPULATED)
60+
FetchContent_Populate(arduino_emulator)
61+
add_subdirectory(${arduino_emulator_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/emulator)
62+
endif()
4963
endif()
64+
5065
endif()

0 commit comments

Comments
 (0)