-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
49 lines (43 loc) · 1.96 KB
/
CMakeLists.txt
File metadata and controls
49 lines (43 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/eil-cmake-utils/cmake)
include(eil_check_idf_features)
eil_check_idf_has_esp_drivers()
# List of common ESP-IDF components required by this component
set(REQUIRED_COMPONENTS log freertos esp_idf_lib_helpers)
# Add version-specific required componenets
if(EIL_IDF_HAS_ESP_DRIVERS)
list(APPEND REQUIRED_COMPONENTS esp_driver_gpio esp_driver_i2c)
else()
list(APPEND REQUIRED_COMPONENTS driver)
endif()
# ESP-IDF version detection for automatic driver selection
# Check for manual override via Kconfig
if(CONFIG_I2CDEV_USE_LEGACY_DRIVER)
set(USE_LEGACY_DRIVER TRUE)
message(STATUS "i2cdev: Manual override - using legacy driver (CONFIG_I2CDEV_USE_LEGACY_DRIVER=y)")
elseif(NOT DEFINED IDF_VERSION_MAJOR)
# In case older ESP-IDF versions that don't define IDF_VERSION_MAJOR
set(USE_LEGACY_DRIVER TRUE)
message(STATUS "i2cdev: IDF_VERSION_MAJOR not defined, using legacy driver")
elseif(IDF_VERSION_MAJOR LESS 5)
set(USE_LEGACY_DRIVER TRUE)
message(STATUS "i2cdev: ESP-IDF v${IDF_VERSION_MAJOR}.x detected, using legacy driver")
elseif(IDF_VERSION_MAJOR EQUAL 5 AND IDF_VERSION_MINOR LESS 3)
set(USE_LEGACY_DRIVER TRUE)
message(STATUS "i2cdev: ESP-IDF v${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR} detected, using legacy driver")
else()
set(USE_LEGACY_DRIVER FALSE)
message(STATUS "i2cdev: ESP-IDF v${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR} detected, using new i2c_master driver")
endif()
# Conditionally set the source file based on version detection or Kconfig override
if(USE_LEGACY_DRIVER)
set(SRCS "i2cdev_legacy.c")
message(STATUS "i2cdev: Compiling with legacy I2C driver (i2cdev_legacy.c)")
else()
set(SRCS "i2cdev.c")
message(STATUS "i2cdev: Compiling with new I2C master driver (i2cdev.c)")
endif()
# Register the component
idf_component_register(SRCS ${SRCS}
INCLUDE_DIRS "."
REQUIRES ${REQUIRED_COMPONENTS})
include(eil_ci)