Visual Studio Code for C/C++ with ARM Cortex-M: Part 5 – ToolKit

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:

Tool Chain loaded 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:

No Kit Selected in Visual Studio Code

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:

Select a Kit

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"
    }
]
Kit successfully loaded

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:

Selecting Kit in Visual Studio Code

CMake Actions

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

CMake Build or 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

12 thoughts on “Visual Studio Code for C/C++ with ARM Cortex-M: Part 5 – ToolKit

    • 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.

      Like

    • 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.

      Like

  1. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 6 | MCU on Eclipse

  2. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 1 | MCU on Eclipse

  3. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 2 | MCU on Eclipse

  4. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 3 | MCU on Eclipse

  5. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 4 | MCU on Eclipse

  6. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 7 – FreeRTOS | MCU on Eclipse

  7. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 8 – xPack C/C++ Managed Build Tools | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.