CMake在vs code中的基本使用

🚀 CMake是一个跨平台的构建工具,用于管理软件项目的构建过程。它使用简单的语法和命令来描述构建过程,并生成适合不同平台和编译器的构建文件。

前提

  • 手动下载安装Cmake
  • 准备好C++环境(插件+编译器MinGW)
  • vscode中下载插件

步骤

按照官网教程的步骤,就行了

问题

  • 为什么没有选择generator?

因为在开始的步骤中,选择了编译器gcc,cmake会根据选择编译器,自动选择了generator:MinGW Makefiles
在这里插入图片描述
在这里插入图片描述

可以在vscode的”输出”窗口中可以看到”-G “MinGW Makefiles””指定了generator,说明generator会生成MinGW的makefile文件
在这里插入图片描述

  • 那对应的make工具又是什么?(cmak —help)

    可以看到MinGW Makefiles对应的make工具是mingw32-make.
    
    此外也可以看到NMake Makefiles前是带*的,是CMake根据当前环境默认选择的generator.
    
Generators

The following generators are available on this platform (* marks default):
  Visual Studio 17 2022        = Generates Visual Studio 2022 project files.
                                 Use -A option to specify architecture.
  Visual Studio 16 2019        = Generates Visual Studio 2019 project files.
                                 Use -A option to specify architecture.
  Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 12 2013 [arch] = Deprecated.  Generates Visual Studio 2013
                                 project files.  Optional [arch] can be
                                 "Win64" or "ARM".
  Visual Studio 9 2008 [arch]  = Deprecated.  Generates Visual Studio 2008
                                 project files.  Optional [arch] can be
                                 "Win64" or "IA64".
  Borland Makefiles            = Generates Borland makefiles.
* NMake Makefiles              = Generates NMake makefiles.
  NMake Makefiles JOM          = Generates JOM makefiles.
  MSYS Makefiles               = Generates MSYS makefiles.
  MinGW Makefiles              = Generates a make file for use with
                                 mingw32-make.

参考

https://code.visualstudio.com/docs/cpp/CMake-linux

https://github.com/microsoft/vscode-cmake-tools/blob/HEAD/docs/how-to.md

CMake在Windows环境下Visual Studio Code的使用 - Dapenson - 博客园

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值