C/C++

MSBuild Tools 2017 com CMake 3.11.2 e Visual Studio Code 1.24 no Windows 10 1709

Baixar e instalar o MSBuild Tools 2017

https://www.visualstudio.com/pt-br/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15#

Baixar e instalar o CMake 3.11.2

x86_64 – https://cmake.org/files/v3.11/cmake-3.11.3-win64-x64.msi
x86 – https://cmake.org/files/v3.11/cmake-3.11.3-win32-x86.msi

Instalar o Visual Studio Code 1.24

x84_64 – https://go.microsoft.com/fwlink/?Linkid=852157
x86 – https://go.microsoft.com/fwlink/?LinkID=623230

Instalar as extensões do Visual Studio Code

  • C/C++
    • vscode:extension/ms-vscode.cpptools
  • CMake
    • vscode:extension/twxs.cmake
  • CMake Tools
    • vscode:extension/vector-of-bool.cmake-tools

Criar um projeto com os arquivos:

CMakeLists.txt

cmake_minimum_required (VERSION 3.0)
project (projeto)
set(SOURCE main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE})

main.cpp

#include <cstdio>
#include <cstdlib>

int main(){
    printf("Olah mundo!\n");

    return 0;
}

.vscode\launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Passe o mouse para ver as descrições dos atributos existentes.
    // Para obter mais informações, visite: https://go.microsoft.com/fwlink/?linkid=830387

    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }
    ]
}

Referências

https://vector-of-bool.github.io/docs/vscode-cmake-tools/debugging.html#debugging-launch-json