New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add target_include_directories for lvgl #2713
Conversation
Although technically correct I wouldn't use the INTERFACE keyword in this case since LVGL isn't an INTERFACE target. The old version of the CMakeLists.txt file uses include_directories (bad practice) and the root project path (CMAKE_SOURCE_DIR) which obviously is wrong if you include it somewhere else. Both of these issues are already addressed by PR #2656. I therefor see no reason to merge this. |
INTERFACE means here that the include path is exposed to users of the lib,, but it is not included for the own target. See also: When it is used also internaly, then PUBLiC maybe better. But it is missing also for the MICROPY version. I'm using this for getting the interface lib. Otherwise, I would like to add a configuration for Mbed users. |
With the exception of "lvgl.h" itself the library only uses relative paths as far as I know. The problem are libraries which depend on lvgl. Take lv_drivers for example. Most of its headers contain the following code #ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif Now your PR makes lvgl.h visible to consumers of lvgl but without the definition of LV_LVGL_H_INCLUDE_SIMPLE lv_drivers would still fail to compile because they would be looking for lvgl/lvgl.h. |
ok, I wanted to avoid a lot of different cases for different target, but it seems these exist already. |
How would Mbed differ from a "usual" CMake target? I can see how ESP, ZEPHYR and Micropython need to be treated differently, but Mbed? I mean sure, if it has to be. The current CMake situation needs to be changed anyhow. If needs be why not add a special Mbed target. A 100kB larger binary just because of some missing inline opportunities... (static lib vs interface) that sounds like there is something wrong with your compiler settings? Either you forgot to turn optimizations on or the compiler isn't able to discard unused code for some reason... |
Mbed is not using special functions like zephyr or ESP, I can use the MicroPy version of interface lib with 'set(MICROPY_DIR true)'. The static lib works with simply add_subdirectory(). Only the target_include_directories was missing, but that will be included with your PR.
|
Have you tried turning optimizations on? (e.g. -Os) There is a great tool to analyze GCC map files out there called Amap. Maybe this can give you a clue. |
The static library needs to be compiled with Currently I don't think we pass any compiler-specific flags in the generic case, so that is probably not happening. |
yes, these are used. The above LANGUAGE_COMPILE_FLAGS are a from the build.ninja log.
I will try it. Thanks for your help! edit: Success! this works now:
thank you so much, I have spent a lot of time to figure it out, but I have started only 2 weeks ago configuring cmake. |
Description of the feature or fix
Better cmake integration for projects that use lvgl.
With target_include_directories, the lvgl path is emitted as include for compilers in projects that use lvgl. Otherwise, the projects must define where lvgl includes are located.
This follows https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1#declare-include-directories-with-target_include_directories
and is also use by zephyr already.
Checkpoints