使用cmake工具多文件编译
-
创建CMakeLists.txt
project(PEOPLE) add_executable(my_cmake_people main.cpp people.cpp)
-
ctrl+shift+p: 为了生成build和.vscode文件
- 选择: CMake Configure
- 选择gcc编译器
- 生成build文件夹和.vscode文件夹
-
终端下: 进入到生成的build的文件夹下面
输入:
cmake ..
输出:
CMake Warning (dev) at CMakeLists.txt:1 (project): cmake_minimum_required() should be called prior to this top-level project() call. Please see the cmake-commands(7) manual for usage documentation of both commands. This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring done (0.2s) -- Generating done (0.1s) -- Build files have been written to: C:/Users/sen/Desktop/liusen/build
继续输入:
mingw32-make.exe
输出:PS C:\Users\sen\Desktop\liusen\build> mingw32-make.exe [ 33%] Building CXX object CMakeFiles/my_cmake_people.dir/main.cpp.obj [ 66%] Building CXX object CMakeFiles/my_cmake_people.dir/people.cpp.obj [