Skip to content
This repository was archived by the owner on Jan 18, 2025. It is now read-only.

VS Code Setup

Jamie Smith edited this page Mar 17, 2021 · 7 revisions

mbed-cmake and Visual Studio Code make a solid pair, and provide an editing experience equal to or better than Mbed's own IDE for zero dollars down.

Opening the Project

  1. Make sure the "C/C++", "CMake Tools", "Native Debug", and "CMake" extensions are installed.
  2. In VS Code, go to File > Open Workspace and select your project folder.
  3. Set up your CMake options. You can do this through cmake.configureSettings in settings.json. However, if your project supports multiple targets, you will need to handle this using a CMake variants file. Here's one I wrote for my project with three boards:
buildType:
  default: RelWithDebInfo
  choices:
    RelWithDebInfo:
      short: RelWithDebInfo
      long: Emit debug information but also optimize
      buildType: RelWithDebInfo
    debug:
      short: debug
      long: Emit debug information and don't optimize
      buildType: Debug
    release:
      short: Release
      long: Optimize generated code
      buildType: Release
board:
  default: GroundStationV1
  choices:
    GroundStationV1:
      short: GroundStationV1
      settings:
        TARGET: GroundStationV1
    GroundStationV2:
      short: GroundStationV2
      settings:
        TARGET: GroundStationV2
    TransponderV1:
      short: TransponderV1
      setting:
        TARGET: TransponderV1
  1. Select your variant. Use Ctrl-Shift-P and find CMake: Select Variant.

Variant list

  1. Configure the project. Use Ctrl-Shift-P and find CMake: Configure. Note: As of mbed-cmake 1.6.0, you should not need to select a kit, VS Code should find the compilers automatically once CMake has configured.
  2. If there's a popup asking if CMake should provide IntelliSense information, say yes!
  3. Done!
Clone this wiki locally