But more important, how does the config system with mbed_app.json does work together with cmake?
You can break down
mbed-tools compile into three steps:
mbed-tools configure, which reads the mbed_app.json and generates mbed_config.cmake
cmake, which configures and generates the build files (in this case Ninja)
cmake build, which in turn runs Ninja to build the binary.
I tried to use bare-metal, but compared to the bare-metal example, I had to manually change target_link_libraries to mbed-baremetal in CMakeList.txt, is this correct?
I did not try building baremetal with CLI2 yet but sounds reasonable.
It looks like other settings for the config in mbed_app.json are generated when I call mbed_tools compile. So mbed_tools is always required, I cannot use some cmake configuration itself?
Mbed-tools is actually only required to generate mbed_config.cmake, the rest is only a wrapper on top of cmake. After running
mbed-tools configure, pure cmake can be used to build the binary.
And I’m using VSCode and have installed the CMake Tools extension, but calling the cmake build from the tools gives some errors. How can I use these tools with mbed cmake?
I use the same setup. The cmake tools extension works pretty well. I use cmake kits to define the compiler and set
cmake.buildDirectory to the directory where mbed_config.cmake is generated. There might be some other configurations that I forgot, but try these and post the errors you are getting.
One problem was the large Mbed repo with all targets, the intellisense needed a configuration for all sourcefile path, it looks like this is automatically resolved with cmake include lists, is that right?
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" setting, which makes intellisense to retrieve the build system information from cmake. As an alternative to intellisense, clangd was proposed by @ladislas in another thread but I did not try integrating into my workflow yet.
Now in the next step, I want to add some driver lib that requires lvgl, but I get errors that lvgl.h is not found. What is necessary to add the lvgl includepath to the lvglDriver lib?
You have link lvgl to lvglDriver:
Otherwise how do you expect the lvglDriver to find lvgl? You would also need to link it to
mbed-os if you want to use mbed functions. This is a pure cmake question and I would recommend reading more on cmake (which unfortunately does not have a very beginner-friendly documentation).