CMake problem: could not find any instance of Visual Studio
Solution 1
This error:
CMake Error at CMakeLists.txt:2 (project): Generator
Visual Studio 15 2017 Win64
could not find any instance of Visual Studio.
indicates that you probably do not have Visual Studio 2017 installed, or at least, not installed correctly. If you want CMake to use Visual Studio 2019 instead, which it appears you have installed, you should use the following cmake
command instead:
cmake -G "Visual Studio 16 2019" -A x64 ..
Visual Studio 15 2017 and Visual Studio 16 2019 provide different compile suites, so you must be sure to use the correct version.
Note, your instructions for setting up the SDK indicate that the SDK was tested on Visual Studio 2017. So, to avoid other potential issues you may encounter with Visual Studio 2019, I suggest downloading and installing Visual Studio 2017 instead. Then, simply following the instructions should work without errors.
Solution 2
I ran into this problem when connecting to a windows build node from Jenkins via ssh.
What I was able to verify is that through the ssh connection running bash or windows cmd shell "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" would return no results.
However when running from local bash or cmd shell on the build node vswhere would return all the expected information.
After carefully comparing the differences in the two sets of environment variables ssh connection vs local setting ProgramData resulted in vswhere returning the expected results and CMake could find all installed Visual Studio instances.
In cmd shell set ProgramData=C:\ProgramData
In .bashrc export ProgramData='C:\ProgramData'
Qian Xu
Updated on June 04, 2022Comments
-
Qian Xu 7 months
What I want to do
I got a source SDK file folder which contains all the files needed to create a project (or .sln), including a CMakeLists. And then I tried to use CMake to build a solution file. And this image below is the guide for how to get this SDK started.
What I did
Open Visual Studio 2019 (The CMake module have been installed).
Open the SDK file folder with VS2019.
Click "Tools" and open Visual Studio 2019 Developer Command Prompt v16.4.2.
-
Type:
mkdir build cd build cmake -G"Visual Studio 15 2017 Win64" ..
Problem
And I met the problem below:
CMake Error at CMakeLists.txt:2 (project): Generator Visual Studio 15 2017 Win64 could not find any instance of Visual Studio. -- Configuring incomplete, errors occurred! See also "C:/Users/admin/Desktop/StructureSDK-CrossPlatform-0.7.3-ROS/build/CMakeFiles/CMakeOutput.log".
-
Qian Xu almost 3 yearsThank you so much! I tried the VS2019
cmake
command:cmake -G "Visual Studio 16 2019" -A x64 ..
And it works!!! Thank you again!