Skip to content
Merged
Show file tree
Hide file tree
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
34 changes: 32 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,42 @@ else()
set(COMPONENT_REQUIRES ${_m5gfx_name} esp_adc_cal)
endif()

### If you use arduino-esp32 components, please activate next comment line.
# list(APPEND COMPONENT_REQUIRES arduino-esp32)


message(STATUS "M5Unified use component = ${COMPONENT_REQUIRES}" )


register_component()

# Arduino as an ESP-IDF component: arduino-esp32 publishes -DARDUINO... as PUBLIC compile options, so
# they only reach components that link against it, while the public headers of this library change
# class layout with ARDUINO. Link the Arduino component publicly whenever it is part of the build so
# this library is compiled in the same mode as the application. Only components already selected
# for the build are considered; a build without Arduino is unaffected.
# M5UNIFIED_ARDUINO_COMPONENT=<name> use a differently named Arduino component
# M5UNIFIED_ARDUINO_COMPONENT=OFF disable the automatic dependency
set(_m5unified_arduino_candidates arduino arduino-esp32 espressif__arduino-esp32)
set(_m5unified_arduino_enabled ON)
if(DEFINED M5UNIFIED_ARDUINO_COMPONENT AND NOT "${M5UNIFIED_ARDUINO_COMPONENT}" STREQUAL "")
if(M5UNIFIED_ARDUINO_COMPONENT)
set(_m5unified_arduino_candidates ${M5UNIFIED_ARDUINO_COMPONENT})
else()
set(_m5unified_arduino_enabled OFF)
endif()
endif()
if(_m5unified_arduino_enabled)
idf_build_get_property(_m5unified_arduino_build_components BUILD_COMPONENTS)
set(_m5unified_arduino_hits)
foreach(_m5unified_arduino_name ${_m5unified_arduino_candidates})
if(_m5unified_arduino_name IN_LIST _m5unified_arduino_build_components)
list(APPEND _m5unified_arduino_hits ${_m5unified_arduino_name})
endif()
endforeach()
list(LENGTH _m5unified_arduino_hits _m5unified_arduino_count)
if(_m5unified_arduino_count GREATER 1)
message(FATAL_ERROR "M5UNIFIED: several Arduino components are in the build (${_m5unified_arduino_hits}). Set M5UNIFIED_ARDUINO_COMPONENT to the one to use.")
elseif(_m5unified_arduino_count EQUAL 1)
idf_component_get_property(_m5unified_arduino_lib ${_m5unified_arduino_hits} COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${_m5unified_arduino_lib})
endif()
endif()
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ or have explicit support in the M5Unified library. To use these functions, simp
- ESP-IDF
- Arduino IDE


## Supported devices (ESP32)
- M5Stack Core (BASIC / GRAY / GO / FIRE)
- M5Stack Core2 / Core2 v1.1 / Tough
Expand Down Expand Up @@ -128,6 +129,16 @@ or have explicit support in the M5Unified library. To use these functions, simp
- Unit IMU


## Notes

### Arduino as an ESP-IDF component
When arduino-esp32 is used as an ESP-IDF component together with this library, the library links
the Arduino component automatically (it looks for a component named `arduino`, `arduino-esp32` or
`espressif__arduino-esp32` in the build) so that it is compiled with the same `ARDUINO` definitions
as the application. Without that, the application and the library would see different layouts of the
same classes. Set `M5UNIFIED_ARDUINO_COMPONENT=<name>` (CMake cache variable) if your Arduino component
has another name, or `M5UNIFIED_ARDUINO_COMPONENT=OFF` to disable this.

# Hardware information

### ESP32 GPIO list
Expand Down
Loading