如何在Visual Studio的CMake支持下运行INSTALL?

MiP*_*MiP 5 cmake visual-studio visual-studio-2017

借助Visual Studio中的CMake支持,如何运行INSTALL构建?

在此处输入图片说明 从顶部工具栏的CMake菜单中,我看不到要运行INSTALL项目的任何选择。

编辑:vre建议的最低设置有效,INSTALL选项显示在工具栏菜单中:

  • CMakeLists.txt

    # 3.9.2 is the current version the newest VS is using
    cmake_minimum_required(VERSION 3.9.2)
    project(test2017)
    add_executable(hello hello.cpp)
    install(TARGETS hello DESTINATION hello/bin)
    
    Run Code Online (Sandbox Code Playgroud)
  • 你好

但是当我移到hello.cpp子文件夹时,该选项消失了:

MiP*_*MiP 4

使用子文件夹时似乎有一个错误,并且在当前的 VS 15.5.5 中仍未修复。

解决方法是在文件内部添加一个install参数。例子:buildCommandArgsCMakeSettings.json

{
  "configurations": [
    {
      "name": "x86-Debug",
      "generator": "Ninja",
      "configurationType": "Debug",
      "inheritEnvironments": [ "msvc_x86" ],
      "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
      "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "-v install",
      "ctestCommandArgs": ""
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)