cmake: use main lv_conf.h, use file globs for fonts and icons

To make the simulator work without modification for more PRs use the
original `lv_conf.h` file and modify the needed parts for the simulator.

Furthermore use globbing expressions to add all available fonts and
icons in case a PR adds new fonts or icons.
This commit is contained in:
Reinhold Gschweicher
2022-03-09 22:14:26 +01:00
committed by NeroBurner
parent 0b12245c08
commit eb7b589826
2 changed files with 34 additions and 785 deletions

View File

@@ -29,11 +29,35 @@ else()
endif()
set(CMAKE_C_STANDARD 11)#C11
# copy lv_conf.h from InfiniTime project and do little modifications
file(READ "${InfiniTime_DIR}/src/libs/lv_conf.h" lv_conf_main)
# set '#define LV_TICK_CUSTOM 0'
string(REGEX REPLACE "#define[ ]+LV_TICK_CUSTOM[ ]+1" "#define LV_TICK_CUSTOM 0" lv_conf_main "${lv_conf_main}")
# allow more memory in debug mode for the simulator
#define LV_MEM_SIZE (14U * 1024U)
string(REGEX REPLACE "#define[ ]+LV_MEM_SIZE[ ]+\\([^\)]*\\)"
"#ifdef NDEBUG
#define LV_MEM_SIZE (14U * 1024U)
#else // debug mode -> allow more memory
#define LV_MEM_SIZE (28U * 1024U)
#endif"
lv_conf_main "${lv_conf_main}")
# write to temporary file and overwrite file to use only if lv_conf changed to keep useless recompiles
# at a minimum
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lv_conf_modified.h" "${lv_conf_main}")
configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/lv_conf_modified.h"
"${CMAKE_CURRENT_BINARY_DIR}/lv_conf.h"
COPYONLY)
file(GLOB_RECURSE INCLUDES "lv_drivers/*.h" "${InfiniTime_DIR}/src/libs/lvgl/src/*.h" "./*.h" )
file(GLOB_RECURSE SOURCES "lv_drivers/*.c" "${InfiniTime_DIR}/src/libs/lvgl/src/*.c" )
add_executable(infinisim main.cpp ${SOURCES} ${INCLUDES})
# include the generated lv_conf.h file before anything else
target_include_directories(infinisim PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
# add simulator files
target_sources(infinisim PUBLIC
sim/displayapp/LittleVgl.h
@@ -115,22 +139,6 @@ target_include_directories(infinisim PRIVATE "sim/nrfx") # for nrfx_log.h and ot
target_include_directories(infinisim PRIVATE "sim/nrfx/hal") # for nrfx_log.h
target_compile_definitions(infinisim PRIVATE LV_CONF_INCLUDE_SIMPLE)
target_sources(infinisim PUBLIC
# LVGL Fonts
${InfiniTime_DIR}/src/libs/lvgl/src/lv_font/lv_font_montserrat_14.c
${InfiniTime_DIR}/src/libs/lvgl/src/lv_font/lv_font_montserrat_18.c
${InfiniTime_DIR}/src/libs/lvgl/src/lv_font/lv_font_montserrat_22.c
${InfiniTime_DIR}/src/libs/lvgl/src/lv_font/lv_font_montserrat_28.c
${InfiniTime_DIR}/src/displayapp/fonts/lv_font_navi_80.c
${InfiniTime_DIR}/src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c
${InfiniTime_DIR}/src/displayapp/fonts/jetbrains_mono_bold_20.c
${InfiniTime_DIR}/src/displayapp/fonts/jetbrains_mono_76.c
${InfiniTime_DIR}/src/displayapp/fonts/jetbrains_mono_42.c
${InfiniTime_DIR}/src/displayapp/fonts/lv_font_sys_48.c
${InfiniTime_DIR}/src/displayapp/fonts/open_sans_light.c
)
target_include_directories(infinisim PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(infinisim PRIVATE "${InfiniTime_DIR}/src/libs")
@@ -139,14 +147,23 @@ target_include_directories(infinisim PRIVATE "lv_drivers")
# add dates library
target_include_directories(infinisim SYSTEM PRIVATE "${InfiniTime_DIR}/src/libs/date/includes")
# add Screens with a globbing expression, to enable easier CI test-runs for PRs adding new Screens
# add Screens, fonts and icons with a globbing expression,
# to enable easier CI test-runs for PRs adding new Screens/Fonts/Icons
file(GLOB InfiniTime_SCREENS
"${InfiniTime_DIR}/src/displayapp/screens/*.h"
"${InfiniTime_DIR}/src/displayapp/screens/*.cpp"
"${InfiniTime_DIR}/src/displayapp/screens/settings/*.h"
"${InfiniTime_DIR}/src/displayapp/screens/settings/*.cpp"
)
file(GLOB InfiniTime_FONTS
"${InfiniTime_DIR}/src/displayapp/fonts/*.c"
)
file(GLOB InfiniTime_ICONS
"${InfiniTime_DIR}/src/displayapp/icons/*.c"
)
target_sources(infinisim PUBLIC ${InfiniTime_SCREENS})
target_sources(infinisim PUBLIC ${InfiniTime_FONTS})
target_sources(infinisim PUBLIC ${InfiniTime_ICONS})
# add files directly from InfiniTime sources
target_include_directories(infinisim PRIVATE "${InfiniTime_DIR}/src")
@@ -207,8 +224,6 @@ execute_process(
set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!")
configure_file("${InfiniTime_DIR}/src/Version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/Version.h")
target_include_directories(infinisim PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
option(WITH_PNG "Compile with libpng support to dump current screen as png" ON)
if(WITH_PNG)
target_compile_definitions(infinisim PRIVATE WITH_PNG)