Skip to content

Instantly share code, notes, and snippets.

@xeptore
Last active July 5, 2019 11:45
Show Gist options
  • Save xeptore/e2a32264e72005a1527bd17be0774ec2 to your computer and use it in GitHub Desktop.
Save xeptore/e2a32264e72005a1527bd17be0774ec2 to your computer and use it in GitHub Desktop.
cpp vscode development (cmake, build, and debugging) configurations
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"configurationProvider": "vector-of-bool.cmake-tools",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
cmake_minimum_required (VERSION 3.10)
project (main)
# book.cpp implementing book.h definitions
add_library(Book book.h book.cpp)
add_executable(main main.cpp)
# linking Book library to main
target_link_libraries (main Book)
{
"version": "0.2.0",
"configurations": [
{
"name": "build and debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "make",
"dependsOn": [
"cmake"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "cmake",
"type": "shell",
"command": "cmake",
"args": [
"-DCMAKE_BUILD_TYPE=Debug",
"CMakeLists.txt"
],
"group": "build"
}
]
}
@xeptore
Copy link
Author

xeptore commented Apr 21, 2019

VSCode C++ Development Configuration

Using these configurations adds the ability to:

  • make your C++ project with CMake
  • use and link header files to your project (should be configured in CMakeLists.txt)
  • debug

Usage

  • put tasks.json, launch.json, and c_cpp_properties.json files, into .vscode/ directory.
  • put CMakeLists.txt file into your workspace directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment