Share via


CMake Generator Visual Studio 2017 Does Not Work

Question

Thursday, October 17, 2019 10:54 AM

Using Visual Studio 2019 Developer Command Prompt v16.3.5, cmake -G "Visual Studio 15 2017" -A x64  <path to source here> has the following error:

CMake Error at CMakeLists.txt:3 (project): Generator
Visual Studio 15 2017
  could not find any instance of Visual Studio.

This is the same type of issue reported here: https://developercommunity.visualstudio.com/content/problem/433328/cmake-visual-studio-2017-generator-does-not-work.html

Anyone have any ideas on how to fix this?

All replies (2)

Friday, October 18, 2019 8:18 AM ✅Answered

Hi Brigity,

Welcome to the MSDN forum.

According to your description, I have tried to reproduce your issue in my side.

I tried to create two files (CMakeLists.txt file and XXX.cpp file) in the same folder and use Command Prompt(2019 and 2017), type cmake –g “Visual Studio 15 2017” –A x64 <path> and cmake –g “Visual Studio 16 2019” –A x64 <path> separately to check but both of them could work well.

Not sure if the “-G” command maybe affect this build, because I first use cmake –G “Visual Studio 15 2017” –A x64 <path> like you said but it failed with error like : The C compiler identification is unknown… though not the same error like you but when I changed it to –g it works.

Maybe you could also check if the path of your source files are correct.

In addition, I also researched more, You could try to install these components: Visual C++ tools for CMake, C++/CLI support, VC++ 2015.3 v14.00 (v140) toolset for desktop. (to install them from Visual Studio installer -> find VS 2017 -> Modify -> Individual components)

If this issue still persists feel free to contact us.

BTW, since it is hard for us to reproduce your issue, if possible could you share us with a simple sample then upload via onedrive or github and I will go to download and check in my side.

Hope all above could help you. 

Best Regards,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Friday, October 18, 2019 6:06 PM ✅Answered

Your recommendations worked!

a) Without installing any components, using lower case "-g" instead of "-G" did not work, I got the same result as with "-G"

b) I had all the components installed that you recommended EXCEPT for:

b.1) C++/CLI support for v142 build tools (14.20)

b.2) C++/CLI support for v142 build tools (14.21)

b.3) C++/CLI support for v142 build tools (14.23)

b.4) VC++ 2015.3 v14.00 (v140) toolset for desktop (I have MSVC v140 - VS 2015 C++ build tools (v14.00) component installed. I could not install VC++ 2015.3 v14.00 (v140) component since it is not listed in the Visual Studio installer -> find VS 2010 -> Modify -> Individual components section (I am using VS2019 community and do not have vs2017)

c) I installed the components in (b.1), (b.2), and (b.3), left everything else same and rebooted. Then inside vs2019 developer command prompt I typed as you recommended: cmake –g “Visual Studio 15 2017” –A x64 <path> and it worked! Also cmake –g “Visual Studio 16 2019” –A x64 <path> worked!

Thank you for your excellent and timely advise!

Sincerely, Brigity