What do you want to achieve?
I would like to place lv_conf.h in my project’s src sub-directory rather than at the top level, as described in LVGL’s current release (v9.3) docs for CMake. I’m new to LVGL and CMake, so I might be overlooking something simple.
What have you tried so far? (And steps to reproduce)
With a clone of GitHub’s lvgl/lv_port_pc_vscode in Visual Studio Code with Microsoft’s CMake Tools on an Arm Mac, I can build and run using the PC simulator just fine. (I’m very glad to have the simulator, by the way.)
I then made the following changes:
- Moved
lv_conf.hintosrc - Updated the top-level
CMakeLists.txtto includeset(LV_BUILD_CONF_DIR src)as a new line 39, before other LVGL options and beforeadd_subdirectory(lvgl)
Whenever I slightly alter and save that CMakeLists.txt, VSCode automatically configures the CMake project, and all goes well:
[main] Configuring project: lv_port_pc_vscode
[proc] Executing command: /opt/homebrew/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/opt/homebrew/Cellar/llvm/21.1.0/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/opt/homebrew/Cellar/llvm/21.1.0/bin/clang++ --no-warn-unused-cli -S /Users/wallace/Projects/S/github/lv_port_pc_vscode -B /Users/wallace/Projects/S/github/lv_port_pc_vscode/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- FreeRTOS is disabled
[cmake] --
[cmake] -- Using lv_conf.h from the user-supplied configuration directory: src
[cmake] -- Converted to absolute path: /Users/wallace/Projects/S/github/lv_port_pc_vscode/src
[cmake] -- Enabling the building of ThorVG internal
[cmake] -- Enabling the building of examples
[cmake] -- Enabling the building of demos
[cmake] -- Debug mode enabled
[cmake] -- AddressSanitizer disabled
[cmake] -- Configuring done (0.1s)
[cmake] -- Generating done (0.2s)
[cmake] -- Build files have been written to: /Users/wallace/Projects/S/github/lv_port_pc_vscode/build
After that, I can build by clicking VSCode’s button in the status bar, and (aside from 243 warnings from the compiler and linker) it builds fine, and the generated binary runs fine in the simulator.
But when I go to the CMake panel in VSCode and click “Delete Cache and Reconfigure,” my LV_BUILD_CONF_DIR setting has no effect, and the configuration fails because lv_conf.h was not found at the top level:
[main] Configuring project: lv_port_pc_vscode
[driver] Removing /Users/wallace/Projects/S/github/lv_port_pc_vscode/build/CMakeCache.txt
[driver] Removing /Users/wallace/Projects/S/github/lv_port_pc_vscode/build/CMakeFiles
[proc] Executing command: /opt/homebrew/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/opt/homebrew/Cellar/llvm/21.1.0/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/opt/homebrew/Cellar/llvm/21.1.0/bin/clang++ --no-warn-unused-cli -S /Users/wallace/Projects/S/github/lv_port_pc_vscode -B /Users/wallace/Projects/S/github/lv_port_pc_vscode/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is Clang 21.1.0
[cmake] -- The CXX compiler identification is Clang 21.1.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /opt/homebrew/Cellar/llvm/21.1.0/bin/clang - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /opt/homebrew/Cellar/llvm/21.1.0/bin/clang++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- FreeRTOS is disabled
[cmake] -- The ASM compiler identification is Clang with GNU-like command-line
[cmake] -- Found assembler: /opt/homebrew/Cellar/llvm/21.1.0/bin/clang
[cmake] --
[cmake] -- Using lv_conf.h from the top-level project directory
[cmake] CMake Error at lvgl/env_support/cmake/os_desktop.cmake:126 (message):
[cmake] Configuration file:
[cmake] /Users/wallace/Projects/S/github/lv_port_pc_vscode/lv_conf.h - not
[cmake] found
[cmake] Call Stack (most recent call first):
[cmake] lvgl/CMakeLists.txt:28 (include)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: /opt/homebrew/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/opt/homebrew/Cellar/llvm/21.1.0/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/opt/homebrew/Cellar/llvm/21.1.0/bin/clang++ --no-warn-unused-cli -S /Users/wallace/Projects/S/github/lv_port_pc_vscode -B /Users/wallace/Projects/S/github/lv_port_pc_vscode/build -G Ninja exited with code: 1
In .vscode/settings.json I tried "cmake.deleteBuildDirOnCleanConfigure": true but it didn’t change the situation.
Maybe I could just stay away from that “Delete Cache and Reconfigure” button, but this behavior seems like a symptom of a problem that I should fix before proceeding.
Environment
- MCU/MPU/Board: None yet; using PC simulator.
- LVGL version: v9.3 (latest release)