The previous parts were about installation, project setup, building and debugging. This one is about defining the ‘tool kit’ so I can make use more of the CMake infrastructure in Visual Studio Code:

Outline
There are still a few things to be configured for our project. We can build and debug, but building is done through ‘Tasks‘ but not through CMake directly. This is because I have not configured a ‘kit’ yet. I can see this from a status message on the bottom:

If I try to make a ‘CMake: clean’ (use command palette or CTRL+SHIFT+P) with CMake: Clean

There is a list of ‘kits’ (somehow detected automatically?), but the GNU ARM Embedded toolchain I have installed and using is not listed:

Scan for Kits or using ‘unspecified‘ just resulted in wrong kits/compiler used, breaking the build for the ARM Cortex-M I’m using :-(.
Obviously the CMake with Visual Studio integration is missing something. Thanks to Martin investigating and commenting in the previous part 3 solved the problem: I need to add an extra cmake-kits.json file.
Adding a Kit with cmake-kits.json
Create a new file inside the .vscode folder and name it cmake-kits.json, with the following content (or copy it from GitHub):
[
{
"name": "GCC Arm Embedded",
"toolchainFile": "${workspaceRoot}/arm-none-eabi-gcc.cmake"
}
]

You can give it any name but it has to point to the correct toolchain file for Cmake. With this I have a ‘kit’ recognized and can assign it to a project using the icon in the bottom toolbar:

CMake Actions
With the proper toolchain or kit configured, I can use commands like CMake: Build or CMake: Clean:

Summary
To use the CMake commands, Visual Studio Code needs to know about the toolchain using the cmake-kits.json file present in the .vscode folder. Be sure to have that one added to the project to unlock more of the Visual Studio Code features.
Happy Coding 🙂
Links
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 1
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 2
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 3
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 4
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 5
- Visual Studio Code for C/C++ with ARM Cortex-M: Part 6
- Visual Studio Code website: https://code.visualstudio.com/
- Examples on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/VisualStudioCode
Great series! Thank you.
LikeLiked by 1 person
thanks! There should be more coming. I don’t have a plan, but what I want to check out are some more advanced features and looking into the extension made by Liviu.
LikeLike
Many thanks Erich… This series helped me to understand the cmake world as well.
As always excellent job!
🙏
LikeLiked by 1 person
Thanks! I’m still learning things in CMake. I see the potential and the power of it, the same time it is rather hard to understand and learn. IMHO make files are much easier to handle, but I hope that over time things will get easier using CMake.
LikeLike
Excellent series.
LikeLiked by 1 person
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 6 | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 1 | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 2 | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 3 | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 4 | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 7 – FreeRTOS | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 8 – xPack C/C++ Managed Build Tools | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 9 – RTT | MCU on Eclipse
Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 10 – Assembly Stepping | MCU on Eclipse
First of all thanks a lot for your wonderful series. Is there any way to use system environment variables to replace static toolchain folders that is defined in the arm-none-eabi-gcc.cmake files. Something like env:ARM_TOOLCHAIN_DIR instead of C::Program Files… definition?
I had a bit of research through the web but couldn’t find specific answer.
Thanks a lot for the help.
LikeLiked by 1 person
See for example https://cmake.org/cmake/help/latest/variable/ENV.html
LikeLike
Great series. Really helped to connect the different links in the toolchain :-).
Especially using gdb and gdb server.
Most IDE’s encourage limited debug to, set a breakpoint, step in, step out so its been great to explore command line gdb while having viewing source code terminal.
Regarding .svd files, this part seemed inevitable to lack full support.
I am having difficulty locating a .svd file for Renesas R7FS7G27H3A01CFC.
One forum indicated IAR has one but IAR is not big on offering free download
Checked Keil but no support their either.
Does anyone know where to locate a .svd file for Renesas R7FS7G27H3A01CFC?
LikeLike
I have not worked for a while with Renesas. I quickly checked https://embsysregview.sourceforge.net/ which is usually a good source, but it seems they don’t have Renesas file neither.
As for IAR, it should be still possible to get a trial (have not used IAR for years, but this was possible a few years ago).
LikeLike