vscode_with_cmake - DmitrySemikin/dsemikin_notes GitHub Wiki

Home / Other Notes


VS Code with CMake for C++ development

  • Install CMake, install VSCode.
  • Open the directory with CMake project.
  • Ctrl + Shift + P => type in "settings" => select "Preferences: Open Workspace Settings (JSON)". The file <working_dir>/.vscode/settings.json is created.
  • Specify configuration options (add CMake defines: -D option): add cmake.configureSettings (or cmake.configureArgs) with needed defines (see cmake settings reference: https://github.com/microsoft/vscode-cmake-tools/blob/master/docs/cmake-settings.md#cmake-settings).
  • On the left select "debugging". Click "create a lanuch.json file". Use example from here (adjust as needed): https://github.com/microsoft/vscode-cmake-tools/blob/master/docs/debug-launch.md#debug-using-a-launchjson-file. Note: it only works, when started from this "debug" view. For some reason button in the status bar does not use settings from launch.json (like PATH or LD_LIBRARY_PATH). It is also impossible to start app without debugging like this.
  • Press Ctrl + Shift + P and type "cmake: " - see, which commands are available (like "configure", "build" etc...).

Home / Other Notes