一、配置Windows/Linux开发环境<CMakePresets.json>
{
"version": 3,
"configurePresets": [
{
"name": "x64-default",
"hidden": true,
"inherits": "windows-x64",
"cacheVariables": {
"VTK_DIR": "E:/ThirdLib/VTK/install/lib/cmake/vtk-9.2",
"OpenCV_DIR": "E:/ThirdLib/opencv/build",
"rabbitmq-c_DIR": "E:/ThirdLib/librabbitmq/x64-windows/share/rabbitmq-c",
"CMAKE_TOOLCHAIN_FILE": "E:/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "x64-Debug",
"inherits": [
"x64-default"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"GX_MISCELLANEOUS_ROOT": "E:/ThirdLib/gx-miscellaneous/windows-debug",
"Qt6AdvancedDocking_DIR": "E:/ThirdLib/QtADS/x64-debug/lib/cmake/qt6advanceddocking"
}
},
{
"name": "x64-Release",
"inherits": [
"x64-default"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"GX_MISCELLANEOUS_ROOT": "E:/ThirdLib/gx-miscellaneous/windows-release",
"Qt6AdvancedDocking_DIR": "E:/ThirdLib/QtADS/x64-release/lib/cmake/qt6advanceddocking"
}
},
/************************ Linux系统配置 *******************************************/
{
"name": "linux-x64-base",
"hidden": true,
"description": "面向适用于 Linux 的 Windows 子系统(WSL)或远程 Linux 系统。",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Linux" ] },
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/wxj/$ms{projectDirName}" }
}
},
{
"name": "Linux-x64-Debug",
"inherits": "linux-x64-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"GX_MISCELLANEOUS_ROOT": "${sourceDir}/lib/gx-miscellaneous/linux-ubuntu",
"rabbitmq-c_DIR": "${sourceDir}/lib/librabbitmq/x64-linux/lib/cmake/rabbitmq-c"
}
},
{
"name": "Linux-x64-Release",
"inherits": "linux-x64-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"GX_MISCELLANEOUS_ROOT": "${sourceDir}/lib/gx-miscellaneous/linux-ubuntu",
"rabbitmq-c_DIR": "${sourceDir}/lib/librabbitmq/x64-linux/lib/cmake/rabbitmq-c"
}
}
]
}
二、配置本地调试或远程调试
在launch.vs.json文件中添加如下代码:
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "remoteWindows",
"authenticationType": "none",
"name": "SteelSurfaceMeasure.exe (远程调试)",
"project": "CMakeLists.txt",
"projectTarget": "SteelSurfaceMeasure.exe (安装)",
"remoteMachineName": "10.147.20.72",
"cwd": "D:\\SteelSurfaceMeasure\\Debug\\",
"program": "D:\\SteelSurfaceMeasure\\Debug\\SteelSurfaceMeasure.exe",
"disableDeploy": true,
"deployDirectory": "D:\\SteelSurfaceMeasure\\Debug\\",
"deploy": [
{
"sourceMachine": "10.147.20.107",
"targetMachine": "10.147.20.72",
"sourcePath": "E:\\Project\\TangRailMeasure\\TangRailMeasure\\out\\install\\x64-Debug\\SteelSurfaceMeasure\\SteelSurfaceMeasure.exe",
"targetPath": "D:\\SteelSurfaceMeasure\\Debug\\SteelSurfaceMeasure.exe",
"executable": "false"
}
],
"args": [],
"env": {}
},
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "SteelSurfaceMeasure.exe (安装)",
"name": "SteelSurfaceMeasure.exe (本地调试)"
}
}
三、配置带有命令行的控制台程序
在launch.vs.json文件中添加如下代码:
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "DefectImageServer.exe (安装)",
"name": "DefectImageServer.exe (安装)",
"args": [
"-s",
"192.168.7.141:9500",
"-l",
"192.168.7.141:8099"
]
}
]
}