CMakeLists.txt 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. if(ESP_PLATFORM)
  2. file(GLOB_RECURSE SOURCES src/*.c)
  3. idf_build_get_property(LV_MICROPYTHON LV_MICROPYTHON)
  4. if (LV_MICROPYTHON)
  5. idf_component_register(SRCS ${SOURCES}
  6. INCLUDE_DIRS . src ../
  7. REQUIRES main)
  8. else()
  9. idf_component_register(SRCS ${SOURCES}
  10. INCLUDE_DIRS . src ../)
  11. endif()
  12. target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_CONF_INCLUDE_SIMPLE")
  13. if (CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM)
  14. target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_ATTRIBUTE_FAST_MEM=IRAM_ATTR")
  15. endif()
  16. elseif(ZEPHYR_BASE)
  17. if(CONFIG_LVGL)
  18. zephyr_include_directories(${ZEPHYR_BASE}/lib/gui/lvgl)
  19. target_include_directories(lvgl INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
  20. zephyr_compile_definitions(LV_CONF_KCONFIG_EXTERNAL_INCLUDE=<autoconf.h>)
  21. zephyr_library()
  22. file(GLOB_RECURSE SOURCES src/*.c)
  23. zephyr_library_sources(${SOURCES})
  24. endif(CONFIG_LVGL)
  25. else()
  26. file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/*.c)
  27. file(GLOB_RECURSE EXAMPLE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/examples/*.c)
  28. if(MICROPY_DIR)
  29. # with micropython, build lvgl as interface library
  30. # link chain is: lvgl_interface [lvgl] → usermod_lvgl_bindings [lv_bindings] → usermod [micropython] → firmware [micropython]
  31. add_library(lvgl_interface INTERFACE)
  32. # ${SOURCES} must NOT be given to add_library directly for some reason (won't be built)
  33. target_sources(lvgl_interface INTERFACE ${SOURCES})
  34. # Micropython builds with -Werror; we need to suppress some warnings, such as:
  35. #
  36. # /home/test/build/lv_micropython/ports/rp2/build-PICO/lv_mp.c:29316:16: error: 'lv_style_transition_dsc_t_path_xcb_callback' defined but not used [-Werror=unused-function]
  37. # 29316 | STATIC int32_t lv_style_transition_dsc_t_path_xcb_callback(const struct _lv_anim_t * arg0)
  38. # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. target_compile_options(lvgl_interface INTERFACE -Wno-unused-function)
  40. else(MICROPY_DIR)
  41. # without micropython, build lvgl and examples libs normally
  42. # default linux build uses this scope
  43. add_library(lvgl STATIC ${SOURCES})
  44. add_library(lvgl_examples STATIC ${EXAMPLE_SOURCES})
  45. include_directories(${CMAKE_SOURCE_DIR})
  46. # Lbrary and headers can be installed to system using make install
  47. file(GLOB LVGL_PUBLIC_HEADERS
  48. "${CMAKE_SOURCE_DIR}/lv_conf.h"
  49. "${CMAKE_SOURCE_DIR}/lvgl.h")
  50. if("${LIB_INSTALL_DIR}" STREQUAL "")
  51. set(LIB_INSTALL_DIR "lib")
  52. endif()
  53. if("${INC_INSTALL_DIR}" STREQUAL "")
  54. set(INC_INSTALL_DIR "include/lvgl")
  55. endif()
  56. install(DIRECTORY "${CMAKE_SOURCE_DIR}/src"
  57. DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
  58. FILES_MATCHING
  59. PATTERN "*.h")
  60. set_target_properties(lvgl PROPERTIES
  61. OUTPUT_NAME lvgl
  62. ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
  63. PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
  64. install(TARGETS lvgl
  65. ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
  66. PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
  67. endif(MICROPY_DIR)
  68. endif()