From 9d0896cdef1c6f9d6f2e165f0989547cd5079a94 Mon Sep 17 00:00:00 2001 From: wangyz1997 <798475117@qq.com> Date: Thu, 14 Jul 2022 00:07:30 +0800 Subject: [PATCH] fix(cmake-build): Fix example and demo build on esp-idf (#3466) --- env_support/cmake/esp.cmake | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/env_support/cmake/esp.cmake b/env_support/cmake/esp.cmake index a8671da25..4d39a8976 100644 --- a/env_support/cmake/esp.cmake +++ b/env_support/cmake/esp.cmake @@ -21,8 +21,34 @@ if(LV_MICROPYTHON) INTERFACE "-DLV_ATTRIBUTE_FAST_MEM=IRAM_ATTR") endif() else() - idf_component_register(SRCS ${SOURCES} INCLUDE_DIRS ${LVGL_ROOT_DIR} - ${LVGL_ROOT_DIR}/src ${LVGL_ROOT_DIR}/../) + if(CONFIG_LV_BUILD_EXAMPLES) + file(GLOB_RECURSE EXAMPLE_SOURCES ${LVGL_ROOT_DIR}/examples/*.c) + endif() + + if(CONFIG_LV_USE_DEMO_WIDGETS) + file(GLOB_RECURSE DEMO_WIDGETS_SOURCES ${LVGL_ROOT_DIR}/demos/widgets/*.c) + list(APPEND DEMO_SOURCES ${DEMO_WIDGETS_SOURCES}) + endif() + if(CONFIG_LV_USE_DEMO_KEYPAD_AND_ENCODER) + file(GLOB_RECURSE DEMO_KEYPAD_AND_ENCODER_SOURCES ${LVGL_ROOT_DIR}/demos/keypad_encoder/*.c) + list(APPEND DEMO_SOURCES ${DEMO_KEYPAD_AND_ENCODER_SOURCES}) + endif() + if(CONFIG_LV_USE_DEMO_BENCHMARK) + file(GLOB_RECURSE DEMO_BENCHMARK_SOURCES ${LVGL_ROOT_DIR}/demos/benchmark/*.c) + list(APPEND DEMO_SOURCES ${DEMO_BENCHMARK_SOURCES}) + endif() + if(CONFIG_LV_USE_DEMO_STRESS) + file(GLOB_RECURSE DEMO_STRESS_SOURCES ${LVGL_ROOT_DIR}/demos/stress/*.c) + list(APPEND DEMO_SOURCES ${DEMO_STRESS_SOURCES}) + endif() + if(CONFIG_LV_USE_DEMO_MUSIC) + file(GLOB_RECURSE DEMO_MUSIC_SOURCES ${LVGL_ROOT_DIR}/demos/music/*.c) + list(APPEND DEMO_SOURCES ${DEMO_MUSIC_SOURCES}) + endif() + + idf_component_register(SRCS ${SOURCES} ${EXAMPLE_SOURCES} ${DEMO_SOURCES} + INCLUDE_DIRS ${LVGL_ROOT_DIR} ${LVGL_ROOT_DIR}/src ${LVGL_ROOT_DIR}/../ + ${LVGL_ROOT_DIR}/examples ${LVGL_ROOT_DIR}/demos) target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_CONF_INCLUDE_SIMPLE")