2020-10-26 08:05:32 -06:00
if ( ESP_PLATFORM )
2021-09-06 10:39:51 +02:00
file ( GLOB_RECURSE SOURCES src/*.c )
2020-10-26 08:05:32 -06:00
2021-09-06 10:39:51 +02:00
idf_build_get_property ( LV_MICROPYTHON LV_MICROPYTHON )
2021-08-13 20:30:00 +03:00
2021-09-06 10:39:51 +02:00
if ( LV_MICROPYTHON )
idf_component_register ( SRCS ${ SOURCES }
I N C L U D E _ D I R S . s r c . . /
R E Q U I R E S m a i n )
else ( )
idf_component_register ( SRCS ${ SOURCES }
I N C L U D E _ D I R S . s r c . . / )
endif ( )
2020-10-26 08:05:32 -06:00
2021-09-06 10:39:51 +02:00
target_compile_definitions ( ${ COMPONENT_LIB } PUBLIC "-DLV_CONF_INCLUDE_SIMPLE" )
2020-12-20 13:34:48 +01:00
2021-09-06 10:39:51 +02:00
if ( CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM )
target_compile_definitions ( ${ COMPONENT_LIB } PUBLIC "-DLV_ATTRIBUTE_FAST_MEM=IRAM_ATTR" )
endif ( )
2020-10-26 08:05:32 -06:00
2021-01-04 14:18:11 +01:00
elseif ( ZEPHYR_BASE )
2021-09-06 10:39:51 +02:00
if ( CONFIG_LVGL )
2021-01-04 14:18:11 +01:00
2021-09-06 10:39:51 +02:00
zephyr_include_directories ( ${ ZEPHYR_BASE } /lib/gui/lvgl )
2021-01-04 14:18:11 +01:00
2021-09-06 10:39:51 +02:00
target_include_directories ( lvgl INTERFACE ${ CMAKE_CURRENT_SOURCE_DIR } )
2021-01-04 14:18:11 +01:00
2021-09-06 10:39:51 +02:00
zephyr_compile_definitions ( LV_CONF_KCONFIG_EXTERNAL_INCLUDE=<autoconf.h> )
2021-01-04 14:18:11 +01:00
2021-09-06 10:39:51 +02:00
zephyr_library ( )
2021-01-04 14:18:11 +01:00
2021-09-06 10:39:51 +02:00
file ( GLOB_RECURSE SOURCES src/*.c )
zephyr_library_sources ( ${ SOURCES } )
2021-01-04 14:18:11 +01:00
2021-09-06 10:39:51 +02:00
endif ( CONFIG_LVGL )
2021-01-04 14:18:11 +01:00
2020-10-26 08:05:32 -06:00
else ( )
2021-02-18 15:41:54 +03:00
2021-09-06 10:39:51 +02:00
file ( GLOB_RECURSE SOURCES ${ CMAKE_CURRENT_LIST_DIR } /src/*.c )
file ( GLOB_RECURSE EXAMPLE_SOURCES ${ CMAKE_CURRENT_LIST_DIR } /examples/*.c )
if ( MICROPY_DIR )
# with micropython, build lvgl as interface library
# link chain is: lvgl_interface [lvgl] → usermod_lvgl_bindings [lv_bindings] → usermod [micropython] → firmware [micropython]
add_library ( lvgl_interface INTERFACE )
# ${SOURCES} must NOT be given to add_library directly for some reason (won't be built)
target_sources ( lvgl_interface INTERFACE ${ SOURCES } )
# Micropython builds with -Werror; we need to suppress some warnings, such as:
#
# /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]
# 29316 | STATIC int32_t lv_style_transition_dsc_t_path_xcb_callback(const struct _lv_anim_t * arg0)
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target_compile_options ( lvgl_interface INTERFACE -Wno-unused-function )
else ( MICROPY_DIR )
# without micropython, build lvgl and examples libs normally
2021-10-06 21:31:37 +02:00
# default linux build uses this scope
2021-09-06 10:39:51 +02:00
add_library ( lvgl STATIC ${ SOURCES } )
add_library ( lvgl_examples STATIC ${ EXAMPLE_SOURCES } )
2021-08-27 06:49:31 -07:00
2021-10-06 21:31:37 +02:00
include_directories ( ${ CMAKE_SOURCE_DIR } )
2021-10-04 16:54:33 +02:00
2021-10-06 21:31:37 +02:00
# Lbrary and headers can be installed to system using make install
file ( GLOB LVGL_PUBLIC_HEADERS
" $ { C M A K E _ S O U R C E _ D I R } / l v _ c o n f . h "
" $ { C M A K E _ S O U R C E _ D I R } / l v g l . h " )
2021-10-04 16:54:33 +02:00
2021-10-06 21:31:37 +02:00
if ( "${LIB_INSTALL_DIR}" STREQUAL "" )
set ( LIB_INSTALL_DIR "lib" )
endif ( )
if ( "${INC_INSTALL_DIR}" STREQUAL "" )
set ( INC_INSTALL_DIR "include/lvgl" )
endif ( )
2021-10-04 16:54:33 +02:00
2021-10-06 21:31:37 +02:00
install ( DIRECTORY "${CMAKE_SOURCE_DIR}/src"
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ P R E F I X } / $ { I N C _ I N S T A L L _ D I R } / "
F I L E S _ M A T C H I N G
P A T T E R N " * . h " )
2021-10-04 16:54:33 +02:00
2021-10-06 21:31:37 +02:00
set_target_properties ( lvgl PROPERTIES
O U T P U T _ N A M E l v g l
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / l i b "
P U B L I C _ H E A D E R " $ { L V G L _ P U B L I C _ H E A D E R S } " )
2021-10-04 16:54:33 +02:00
2021-10-06 21:31:37 +02:00
install ( TARGETS lvgl
A R C H I V E D E S T I N A T I O N " $ { L I B _ I N S T A L L _ D I R } "
P U B L I C _ H E A D E R D E S T I N A T I O N " $ { I N C _ I N S T A L L _ D I R } " )
endif ( MICROPY_DIR )
2021-10-04 16:54:33 +02:00
2021-10-06 21:31:37 +02:00
endif ( )
2021-10-04 16:54:33 +02:00