c++visual-studiocmakesdk

CMake problem: could not find any instance of Visual Studio


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.

SDK instruction guide

What I did

  1. Open Visual Studio 2019 (The CMake module have been installed).

  2. Open the SDK file folder with VS2019.

  3. Click "Tools" and open Visual Studio 2019 Developer Command Prompt v16.4.2.

  4. 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".

Solution

  • 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.