CMake配置开发环境和调试环境

一、配置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"
      ]
    }
  ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值