使用CMake将命令行参数传递给Visual Studio以进行配置文件引导的优化 [英] Passing command line arguments to Visual Studio using CMake for profile guided optimization

查看:359
本文介绍了使用CMake将命令行参数传递给Visual Studio以进行配置文件引导的优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C ++ 项目中使用 CMake 。我正在尝试使用 配置文件引导的优化 ,因此我还需要将命令行参数传递给二进制文件的 Release 模式版本。 Visual Studio 需要此文件来创建性能配置文件。我已经为 Debug 模式二进制文件提供了 launch.vs.json 配置,并带有命令行参数:

I'm using CMake for a C++ project. I'm trying to use profile guided optimization so I need to also pass command line arguments to the Release mode version of my binary. Visual Studio needs this to create a performance profile. I already have a launch.vs.json configuration for the Debug mode binary with command line arguments:

{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "name": "MyProject",
      "project": "CMakeLists.txt",
      "projectTarget": "MyProject.exe",
      "type": "default",
      "args": [
        "...", "..."
      ]
    }
  ]
}

当我切换到发布模式并选择 MyProject 启动项, Visual Studio 显示以下错误消息:

When I switch to Release mode and choose the MyProject startup item, Visual Studio shows the following error message:

Unable to start debugging. The startup project could not be launched.

为什么这样不起作用?我也无法设置其他配置文件并使 Visual Studio 发布模式下识别它,但是在 Debug 模式。

Why does it not work that way? I also cannot setup another profile and make Visual Studio recognize it in Release mode but it works fine in Debug mode.

推荐答案

我现在通过添加另一个条目来做到这一点:

I managed to do it now by adding another entry:

{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "name": "MyProject",
      "project": "CMakeLists.txt",
      "projectTarget": "MyProject.exe",
      "type": "default",
      "args": ["...", "..."]
    },
    {
      "name": "MyProject (Release\\MyProject.exe)",
      "project": "CMakeLists.txt",
      "projectTarget": "MyProject.exe (Release\\MyProject.exe)",
      "type": "default",
      "args": ["...", "..."]
    }
  ]
}

这篇关于使用CMake将命令行参数传递给Visual Studio以进行配置文件引导的优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆