C++ Cmake编译多文件(vscode)

C++ Cmake编译多文件(vscode)

出自:https://www.bilibili.com/video/BV1YL411L7Sg

写一个CmakeList.txt

  • 在项目文件夹下新建一个CmakeList.txt文件
project(result) #项目名称

aux_source_directory(./project1 SRCS) # 源文件

add_executable(${PROJECT_NAME} ${SRCS})

修改launch.json文件

找到"program": "${fileDirname}\${fileBasenameNoExtension}.exe" 将其修改为"program": "${command:cmake.launchTargetPath}"

重启vscode

选择合适的编译器

image

运行

1.先Build
2.再Run

posted @ 2023-01-02 14:02  梧桐灯下江楚滢  阅读(214)  评论(0)    收藏  举报