I have used lvgl and Mbed already, but with the older python script based build system. Now Mbed is using also CMake as build system and I want to use this.
What LVGL version are you using?
What have you tried so far?
I have added the lvgl subdir to my CMakelist.txt and added the lv_conf.h:
in lv_conf.h I have disabled the examples:
#define LV_BUILD_EXAMPLES 0
the build starts and compiles the lvgl/src without errors. But then the examples are compiled and throw errors:
[9/116] Building C object lvgl/CMakeFiles/lvgl_examples.dir/examples/assets/img_star.c.obj
"C:\PROGRA~2\GNU Arm Embedded Toolchain\10 2020-q4-major\bin\arm-none-eabi-gcc.exe" @lvgl\CMakeFiles\lvgl_examples.dir\examples\assets\img_star.c.obj.rsp -MD -MT lvgl/CMakeFiles/lvgl_examples.dir/examples/assets/img_star.c.obj -MF lvgl\CMakeFiles\lvgl_examples.dir\examples\assets\img_star.c.obj.d -o lvgl/CMakeFiles/lvgl_examples.dir/examples/assets/img_star.c.obj -c D:/Projects/Sn/LocalGit/Mbed6-Projects/lvgl8-ST7735/lvgl/examples/assets/img_star.c
D:/Projects/Sn/LocalGit/Mbed6-Projects/lvgl8-ST7735/lvgl/examples/assets/img_star.c:4:10: fatal error: lvgl/lvgl.h: No such file or directory
4 | #include "lvgl/lvgl.h"
building the examples should be optional, how can this be set in the cmake configuration?
lvgl/lvgl.h is not relative to the examples dir, maybe it can be fixed also by setting the include search path, how is this set in cmake?
At the moment, not really. A few of the project repositories have CI on them, however, it only tests that the project itself builds with a specific LVGL commit. The CI doesn’t run in the vice-versa case where LVGL has changed and the project hasn’t.
Thanks, I’m still struggling with cmake.
The file(GLOB,…) makes it simple to list all files in the dirs, but there is a note in cmake that does not recommend to do this:
We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may not work reliably on all generators, or if a new generator is added in the future that cannot support it, projects using it will be stuck. Even if CONFIGURE_DEPENDS works reliably, there is still a cost to perform the check on every rebuild. file — CMake 3.21.3 Documentation
Its more tedious to list all files manually, but I see this in many other projects that use cmake. Any comments from a cmake user with some experience?
I’ve tested something more and got it running with mbed-os and cmake.
But lvgl uses as default case a static lib build. When I link the static lib to my target, it creates a huge binary, compared to using an interface lib its about factor 2. It looks like the optimization does not remove unused functions from the binary. The lv_conf.h is working, size is changing when I disable/enable options.
Are there any targets using the static lvgl library?