CMake 在windows下的两种操作

Makefile

  • CMake 在windows下的两种操作(使用VScode)

  • 第一种方式,直接使用VSCode自带的Cmake插件

    1. 直接在VSCode中安装CMake

    2. # 在CMakeLists中配置如下信息:
      cmake_minimum_required(VERSION 3.10)
      
      set(CMAKE_C_COMPILER "gcc")
      set(CMAKE_CXX_COMPILER "g++")
      
      project(main)
      
      add_executable(main main.cpp fact.cpp printhello.cpp)
      
    3. 然后通过CTRL+SHIFT+P快速构建CMake,点击CMake配置,即可出现build文件夹

    4. cd build
      mingw32-make 
      main.exe
      
  • 第二种方式

    1. 安装CMake Windows后,配置好CMakeLists

    2. mkdir compile_main
      cd compile_main
      cmake .. #cmake 上一层目录中的CMakeLists
      cmake -- build .
      cd compile_main/debug
      main.exe
      

猜你喜欢

转载自blog.csdn.net/m0_51780913/article/details/129394287