Two operations of CMake under windows

Makefile

  • Two operations of CMake under windows (using VScode)

  • The first way is to directly use the Cmake plugin that comes with VSCode

    1. Install CMake directly in VSCode

    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. Then CTRL+SHIFT+Pquickly build CMake, click CMake configuration, and the build folder will appear

    4. cd build
      mingw32-make 
      main.exe
      
  • the second way

    1. After installing CMake Windows, configure CMakeLists

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

Guess you like

Origin blog.csdn.net/m0_51780913/article/details/129394287