Skip to content

Commit a5bb112

Browse files
committed
fix: make IDF component dependencies version-aware
Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com>
1 parent 128e4ae commit a5bb112

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@
88
# (i2c_master_bus_handle_t) is the one used in non-Arduino builds.
99
# - googletest helpers (src/googletest/*) are EXCLUDED — they pull in
1010
# <M5Unified.h> for test scaffolding only and are not needed at runtime.
11+
include($ENV{IDF_PATH}/tools/cmake/version.cmake)
12+
1113
file(GLOB_RECURSE SRCS "src/*.cpp")
1214
list(FILTER SRCS EXCLUDE REGEX "/googletest/")
13-
# REQUIRES = public deps (exposed through src/ public headers); PRIV_REQUIRES = used only in .cpp.
14-
# Use the `driver` meta-component (exists in all IDF 5.x and publicly aggregates esp_driver_*),
15-
# NOT the split esp_driver_* components which only exist from IDF 5.3 and would break >=5.0.
15+
16+
set(public_requires driver M5HAL)
17+
set(private_requires esp_adc esp_timer M5Utility)
18+
19+
# Keep IDF 5.x on the driver meta-component. IDF v6 no longer exposes all split
20+
# driver include paths transitively, so add only the v6-specific component deps.
21+
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL "6")
22+
list(APPEND public_requires esp_driver_gpio esp_driver_i2c esp_driver_rmt esp_driver_spi esp_driver_uart esp_hw_support)
23+
list(APPEND private_requires esp_driver_ledc esp_ringbuf)
24+
endif()
25+
1626
idf_component_register(
1727
SRCS ${SRCS}
1828
INCLUDE_DIRS "src"
19-
REQUIRES driver M5HAL
20-
PRIV_REQUIRES esp_adc esp_timer M5Utility
29+
REQUIRES ${public_requires}
30+
PRIV_REQUIRES ${private_requires}
2131
)
2232

2333
# Optionally link M5Unified only when it is already part of the build (e.g. a M5Unified-based

0 commit comments

Comments
 (0)