背景
window系统vs2017使用cmake实现linux远程调试和编译时,搭建的环境报CMake 缺少以下功能:“serverMode”。请参阅 https://aka.ms/linuxcmakeconfig 了解详细信息错误,如何解决?
经排查,发现远程开发环境的cmake版本不支持serverMode模式,因此,无法实现远程编译
解决方案
验证远程目标服务器的cmake支持的能力,执行以下命令:cmake -E capabilities
输出结果如下:
{“fileApi”:{“requests”:[{“kind”:“codemodel”,“version”:[{“major”:2,“minor”:3}]},{“kind”:“cache”,“version”:[{“major”:2,“minor”:0}]},{“kind”:“cmakeFiles”,“version”:[{“major”:1,“minor”:0}]},{“kind”:“toolchains”,“version”:[{“major”:1,“minor”:0}]}]},“generators”:[{“extraGenerators”:[],“name”:“Watcom WMake”,“platformSupport”:false,“toolsetSupport”:false},{“extraGenerators”:[],“name”:“Ninja Multi-Config”,“platformSupport”:false,“toolsetSupport”:false},{“extraGenerators”:[“CodeBlocks”,“CodeLite”,“Eclipse CDT4”,“Kate”,“Sublime Text 2”],“name”:“Ninja”,“platformSupport”:false,“toolsetSupport”:false},{“extraGenerators”:[“CodeBlocks”,“CodeLite”,“Eclipse CDT4”,“Kate”,“Sublime Text 2”],“name”:“Unix Makefiles”,“platformSupport”:false,“toolsetSupport”:false},{“extraGenerators”:[],“name”:“Green Hills MULTI”,“platformSupport”:true,“toolsetSupport”:true}],“serverMode”:false,“version”:{“isDirty”:false,“major”:3,“minor”:21,“patch”:1,“string”:“3.21.1”,“suffix”:“”}}
可以看到参数serverMode为false,因此远程编译失败,如何将参数置为true?除了换cmake的版本,目前没有想到其他的解决办法,我尝试从相同版本cmake使用源码编译的方式,去寻找与之相关联的参数,但均尝试失败。目前在centos系统下,3.17.1的版本该模式为true,而3.21则不行
注意事项:
如何目标服务器有多个版本的cmake,在本地的CMakeSettings.json文件中"cmakeExecutable"字段可以指定使用哪个cmake
其他变量参数应尽可能使用绝对路径,避免使用类似于$HOME等宏定义变量,防止于windows的环境变量冲突
参考文献
https://learn.microsoft.com/zh-cn/cpp/linux/cmake-linux-configure?view=msvc-170
https://learn.microsoft.com/zh-cn/cpp/build/get-started-linux-cmake?view=msvc-170
————————————————
版权声明:本文为CSDN博主「spirits_of_snail」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qikaihuting/article/details/132448341
ps:经验证,cmake3.19.8版本也可以,下载路径:https://cmake.org/files/v3.19/