Skip to content

Conversation

@glneo
Copy link
Contributor

@glneo glneo commented Nov 19, 2025

Summary by cubic

Simplified CMake config selection to avoid modifying the source tree and fixed a bug that could set CONFIG to OFF, causing build failures. Builds now reference the chosen defaults file directly and skip copying unused generator files.

  • Bug Fixes

    • Use a cached STRING for CONFIG with default "default" to prevent OFF being set and breaking builds.
    • Validate LV_CONF_DEFAULTS_PATH and log the selected config.
  • Refactors

    • Stop renaming/copying lv_conf.defaults in the source; update LV_CONF_DEFAULTS_PATH to the selected config instead.
    • Stop copying lv_conf template/defaults and the generator script to the build dir; track them with CMAKE_CONFIGURE_DEPENDS.

Written for commit 1dd9881. Summary will update automatically on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@AndreCostaaa
Copy link
Collaborator

Hi thank you for the PR

I'm aware of the bug but haven't had time to fix it yet, i'm sorry about that

As for the changes here:

  • I believe We need the configure_file lines as these will make sure we regenerate lvgl's config in case any of the 3 files change (lv_conf.defaults, lv_conf_template.h or the python script that generates the config)

  • I like the approach of copying the config, it feels natural coming from defconfig and that is why I implemented it

  • Ideally the following should work

cmake -B build -DCONFIG=wayland
vim lv_conf.defaults # make changes to the config
cmake --build build # doesn't override the current config with the default wayland config

Right now it doesn't quite work that way because CONFIG is stored and the next build time it will copy the wayland config again overriding the manual changes done

Fyi: the current workaround is this one, and will work okay, it just feels weird having to manually bootstrap cmake twice

cmake -B build -DCONFIG=wayland
vim lv_conf.defaults # make changes to the config
cmake -B build -DCONFIG=default
cmake --build build

I would gladly merge a PR that makes the ideal solution work

@glneo
Copy link
Contributor Author

glneo commented Nov 20, 2025

I believe We need the configure_file lines as these will make sure we regenerate lvgl's config in case any of the 3 files change (lv_conf.defaults, lv_conf_template.h or the python script that generates the config)

That's easy then, those files can be added to CMAKE_CONFIGURE_DEPENDS, that will have the same effect but without the unneeded file copies.

I like the approach of copying the config, it feels natural coming from defconfig and that is why I implemented it

Maybe we could just switch to using defconfig/Kconfig and drop the defaults files, seems to be the way projects are going and Kconfig would be the nature choice for Linux (this being the Linux port project).

Ideally the following should work

The issue is that breaks a principle that the build should not modify the source files. All changes should be done to copies made in the output/build directory. It is also confusing, as you said, that the config will be overwritten on later build/configure steps.

How about one just modifies the file they want in place, so for wayland:

vim configs/wayland.defaults # make changes to the config
cmake -B build -DCONFIG=wayland
cmake --build build

This also works in any order since the config file can be added to the CMake depends, so changing the config after is also valid:

cmake -B build -DCONFIG=wayland
vim configs/wayland.defaults # make changes to the config
cmake --build build

@glneo glneo force-pushed the cmake-config-defaults branch from 67c66a1 to 124d726 Compare November 20, 2025 20:40
@AndreCostaaa
Copy link
Collaborator

AndreCostaaa commented Nov 23, 2025

That's easy then, those files can be added to CMAKE_CONFIGURE_DEPENDS, that will have the same effect but without the unneeded file copies.

TIL. That's good to know, thank you!

Maybe we could just switch to using defconfig/Kconfig and drop the defaults files, seems to be the way projects are going and Kconfig would be the nature choice for Linux (this being the Linux port project).

It has been discussed and we decided to not use it because the .defaults format is LVGL's built-in way of handling it and we'd like to use this project as a reference on how to use it even for other projects that might not be linux based

We might end up moving to KConfig at some point but that's not in the plans for now

The issue is that breaks a principle that the build should not modify the source files. All changes should be done to copies made in the output/build directory.

This is untrue, source files are not modified by the build system, instead it generates lv_conf.h which is the actual source file, so I don't think that principle applies here

It is also confusing, as you said, that the config will be overwritten on later build/configure steps.

That's a bug and shouldn't happen, like I mentioned previously

How about one just modifies the file they want in place, so for wayland:

It's an idea but I liked the idea of not having to "think" about which file to modify. One disadvantage is of course the fact that we're losing the previous config when doing it but i'm not sure if it's a big problem

Anyways, since you already implemented it that way and it fixes the current bug, i'll go ahead and approve that approach, just please:

glneo added 5 commits December 4, 2025 12:11
This reverts commit de589ca.

Using option() instead of set() adds the variable to the cache just the
same, so this commit was not effective. The commit was also broken as
option() also forces the variable to be a BOOL, but CONFIG is a STRING.
This causes CONFIG to be set to OFF in the cache when no -DCONFIG is set
which causes build failures:

CMake Error at CMakeLists.txt:36 (message):
  Config file not found:
  /home/a0226330local/projects/lvgl/lv_port_linux/configs/OFF.defaults

Signed-off-by: Andrew Davis <afd@ti.com>
The file linux-default-settings.defaults is a reference for the set of
settings that are common to all config files. It is meant as a template
for starting new config files, not to be used directly. Move this to
a new directory to avoid confusion.

Signed-off-by: Andrew Davis <afd@ti.com>
These files are copied to the build directory but then never used during
the build, instead the command to generate lv_conf.h below uses the
original source files. Skip this unneeded copy.

Instead add these files to CMake's CONFIGURE_DEPENDS so that CMake will
still reconfigure if these source files change.

Signed-off-by: Andrew Davis <afd@ti.com>
When a non-default lv_conf.defaults is used it is currenly copied out of
the configs/ directory replacing the existing lv_conf.defaults file. This
makes changes to source files during build which should be avoided, only
modifications should happen in the build directory.

There is no need to do this as we can simply update the path used to
locate lv_conf.defaults in CMake to the non-default file path and use
it just the same.

Signed-off-by: Andrew Davis <afd@ti.com>
The function of the CONFIG CMake variable has slightly changed
to not perform a copy of the selected .defconfig file. Update
the documentation to make this behavior clear.

Signed-off-by: Andrew Davis <afd@ti.com>
@glneo glneo force-pushed the cmake-config-defaults branch from 124d726 to 1dd9881 Compare December 4, 2025 18:24
Copy link
Collaborator

@AndreCostaaa AndreCostaaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🚀

@AndreCostaaa AndreCostaaa merged commit ce9d176 into lvgl:master Dec 12, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants