官方参考,自己写自定义变量就是临摹这个文章:CMakeSettings.json 架构引用 | Microsoft Docs
-
先生成缓存,就是将本地文件同步到服务器上,根据
CMakeSettings.json
里的设置创建文件夹等 -
然后点生成(即生成二进制文件)
-
贴张自己改造的
CMakeSettings.json
{ // 自定义变量的声明方式 "environments": [ { // 相当于解决方案放置的目录 "ProjectPath": "/home/zhouqinan/projects" } ], "configurations": [ { "name": "Linux-Release", "generator": "Unix Makefiles", "remoteMachineName": "${defaultRemoteMachineName}", "configurationType": "RelWithDebInfo", // 引用自定义变量 ${env.ProjectPath} // 关键目录一,存放源文件 "remoteCMakeListsRoot": "${env.ProjectPath}/vs_cmake/src", "cmakeExecutable": "/usr/bin/cmake", // 关键目录二.存放生成的二进制文件,注意哈,必须要有 build 这个字段 "remoteBuildRoot": "${env.ProjectPath}/vs_cmake/build", "remoteCopySources": true, "remoteCopySourcesOutputVerbosity": "Normal", "remoteCopySourcesConcurrentCopies": "10", "remoteCopySourcesMethod": "rsync", "remoteCopySourcesExclusionList": [ ".vs", ".git" ], "rsyncCommandArgs": "-t --delete --delete-excluded", "remoteCopyBuildOutput": false, "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", "inheritEnvironments": [ "linux_x64" ] } ] }
-
官方给的
CMakeSettings.json
{ "configurations": [ { "name": "Linux-Release", "generator": "Unix Makefiles", "remoteMachineName": "${defaultRemoteMachineName}", "configurationType": "RelWithDebInfo", "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", "cmakeExecutable": "/usr/local/bin/cmake", "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", "remoteCopySources": true, "remoteCopySourcesOutputVerbosity": "Normal", "remoteCopySourcesConcurrentCopies": "10", "remoteCopySourcesMethod": "rsync", "remoteCopySourcesExclusionList": [ ".vs", ".git" ], "rsyncCommandArgs": "-t --delete --delete-excluded", "remoteCopyBuildOutput": false, "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", "inheritEnvironments": [ "linux_x64" ] } ] }