CMake: Visual Studio 15 2017 could not find any instance of Visual Studio

…衆ロ難τιáo~ 提交于 2020-08-17 19:45:07

问题


When I am trying to install CMake I get the error:

Visual Studio 15 2017 could not find any instance of Visual Studio.

I am using Windows 7 and Visual Studio 2017. The CMakeOutput.log file writes:

The system is: Windows - 6.1.7601 - AMD64

Any ideas?


回答1:


I ran into the same error and performed the following steps to resolve the issue:

  1. Open Visual Studio
  2. Go to Tools -> Get Tools and Features
  3. In the "Workloads" tab enable "Desktop development with C++"
  4. Click Modify at the bottom right

These steps resulted in the "Visual C++ tools for CMake" feature being installed, but the other optional C++ features included in this workload may also helpful for what you are trying to do.

After the Visual Studio updater finishes installing try re-running the command. You may need to open a new command window.




回答2:


In my case, I installed Visual Studio, selecting the workloads and modules that I wanted, but I ignored the request to reboot, assuming that shutting down the computer at the end of the day and restarting it the following day would suffice. I was wrong.

The following day I tried a cmake build and got the "could not find any instance of Visual Studio" error. After several attempts to resolve, I re-ran the installer, made no changes to the configuration, and clicked Modify. This time I let it reboot the computer. The reboot took a long time. After which my cmake build worked.




回答3:


I had the same issue "could not find any instance of Visual Studio" but with Visual Studio 2019 (Community Edition) and I just had to configure the VS160COMNTOOLS variable so that CMake correctly detects Visual Studio.

export VS160COMNTOOLS="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools"

(cf https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html)

With Visual Studio 15 2017, the variable you need should be VS150COMNTOOLS. (cf https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2015%202017.html)

NB: in my case, in a Travis-CI workflow, I installed Visual Studio using the commands (no need to reboot):

choco install visualstudio2019community
choco install visualstudio2019-workload-nativedesktop # required

With only the first package, CMake detection of VS2019 failed.




回答4:


if you have installed two or more Windows 10 SDK, delete them excluding latest one.



来源:https://stackoverflow.com/questions/51668676/cmake-visual-studio-15-2017-could-not-find-any-instance-of-visual-studio

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