Passing command line arguments to Visual Studio using CMake for profile guided optimization

我怕爱的太早我们不能终老 提交于 2019-12-24 04:38:11

问题


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": [
        "...", "..."
      ]
    }
  ]
}

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.

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.


回答1:


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": ["...", "..."]
    }
  ]
}


来源:https://stackoverflow.com/questions/53726905/passing-command-line-arguments-to-visual-studio-using-cmake-for-profile-guided-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!