|
1 | 1 | cmake_minimum_required(VERSION 3.16)
|
2 | 2 |
|
3 |
| -# set the project name |
4 |
| -project(arduino-audio-tools) |
| 3 | +if (DEFINED ESP_PLATFORM) |
5 | 4 |
|
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 | + ) |
10 | 11 |
|
11 |
| -include(FetchContent) |
| 12 | + target_compile_options(${COMPONENT_LIB} PUBLIC -DESP32_CMAKE=1 -Wno-error -Wno-format -fpermissive) |
12 | 13 |
|
13 |
| -add_library(arduino-audio-tools INTERFACE) |
| 14 | +else() |
14 | 15 |
|
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) |
18 | 18 |
|
| 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) |
19 | 23 |
|
20 |
| -# make include directory available to calling projects |
21 |
| -target_include_directories (arduino-audio-tools INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 24 | + include(FetchContent) |
22 | 25 |
|
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) |
29 | 27 |
|
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() |
38 | 52 | endif()
|
39 |
| -endif() |
40 | 53 |
|
41 | 54 |
|
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() |
49 | 63 | endif()
|
| 64 | + |
50 | 65 | endif()
|
0 commit comments