diff --git a/CMakeLists.txt b/CMakeLists.txt index 63ada4df..760a207b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,3 +79,36 @@ if(_m5gfx_arduino_enabled) target_link_libraries(${COMPONENT_LIB} PUBLIC ${_m5gfx_arduino_lib}) endif() endif() + +# Panel_LT8912B (the PoE-P4 display output board) talks to the bridge through M5Unified's I2C_Class, which it +# picks up with __has_include(). In an ESP-IDF build that header is only +# visible when this library is given M5Unified's source directory, so add it whenever an +# M5Unified component is part of the build (headers only; the symbols resolve at link time as +# the component libraries are linked as one group). +# M5GFX_M5UNIFIED_COMPONENT= use a differently named M5Unified component +# M5GFX_M5UNIFIED_COMPONENT=OFF disable the automatic include path +set(_m5gfx_m5unified_candidates M5Unified m5unified m5stack__m5unified) +set(_m5gfx_m5unified_enabled ON) +if(DEFINED M5GFX_M5UNIFIED_COMPONENT AND NOT "${M5GFX_M5UNIFIED_COMPONENT}" STREQUAL "") + if(M5GFX_M5UNIFIED_COMPONENT) + set(_m5gfx_m5unified_candidates ${M5GFX_M5UNIFIED_COMPONENT}) + else() + set(_m5gfx_m5unified_enabled OFF) + endif() +endif() +if(_m5gfx_m5unified_enabled) + idf_build_get_property(_m5gfx_m5unified_build_components BUILD_COMPONENTS) + set(_m5gfx_m5unified_hits) + foreach(_m5gfx_m5unified_name ${_m5gfx_m5unified_candidates}) + if(_m5gfx_m5unified_name IN_LIST _m5gfx_m5unified_build_components) + list(APPEND _m5gfx_m5unified_hits ${_m5gfx_m5unified_name}) + endif() + endforeach() + list(LENGTH _m5gfx_m5unified_hits _m5gfx_m5unified_count) + if(_m5gfx_m5unified_count GREATER 1) + message(FATAL_ERROR "M5GFX: several M5Unified components are in the build (${_m5gfx_m5unified_hits}). Set M5GFX_M5UNIFIED_COMPONENT to the one to use.") + elseif(_m5gfx_m5unified_count EQUAL 1) + idf_component_get_property(_m5gfx_m5unified_dir ${_m5gfx_m5unified_hits} COMPONENT_DIR) + target_include_directories(${COMPONENT_LIB} PRIVATE ${_m5gfx_m5unified_dir}/src) + endif() +endif()