Tools - code + vs + cmake + c/c++


Purpose

In the development process, use VSCODE instead of VS.
In view of my own development language C/C++/python, the development platform spans Linuxand win, the commonly used tools are cmake, and considering that my computer configuration is not very high, so choosing a lightweight development tool is conducive to efficient work.
VSAs the strongest IDEtitle in the universe, it is difficult to shake, but codethe advantages are also very obvious:

  1. Lightweight, it only takes a few seconds to turn on my computer code, and it vstakes 20+ seconds to turn it on;
  2. File management is convenient, which codeis closely related to the positioning as a file editor;
  3. Cross-platform, although the learning cost is high under a single system, but considering the cross-platform attributes, it reduces the learning cost;

Of course, codethe flaws are also obvious:

  1. Configuration is troublesome, various configurations; (this article is to record how to solve these problems)
  2. Code prompt, not sensitive, sometimes unable to prompt

1. Introduction

Development platform:
System : win + wsl
Development language : c/c++
Configuration tool : cmake
Compiler : vs2019

Basic document introduction

Introduction to commonly used files on the official website:

tasks.json (build instructions)
launch.json (debugger settings)
c_cpp_properties.json (compiler path and IntelliSense settings)

1.1 Plugins

Required plugins: C/C++and CMakethe
insert image description here

1.2 configuration

1.2.1 Basic version – the lowest method

To use, first use the shortcut key Ctrl + Shift + P, and then follow the steps below:

  1. CMake: Select a Kit: Select the compiler, it can be MSVC, WinGW, gcc, g++etc. In principle, it will automatically scan the compiler on the computer, but it does not rule out the need to set it manually (I haven’t learned how to set it yet);
  2. CMake: Select a Variant: choose to be Releaseor Debugwait, the default is Debug;
  3. CMake:Configurebuild: cmake configuration environment, a folder created in the current directory by default ;
  4. CMake: Buildcompile;

ps:下一步目标,把所有默认改成便于修改项

1.2.2 Advanced – Configuring Tasks.json

I will add it later if there is a need, but I haven't found it useful for the time being

CUDA

In CMakeLists.txtmodified projectto:

project(main LANGUAGES CXX CUDA)

Guess you like

Origin blog.csdn.net/weixin_42823098/article/details/128393140