8

I have VS2017 installed, with both VS2017 (v141) and VS2015.3 (v140) toolset installed. I need to generate a solution with CMake and I want CMake to be "fooled" as if VS2015 is installed, so I can build the project with v140 toolset.
I know this question is possibly a duplicate of: How cmake specify "Platform Toolset" for a Visual Studio 2015 project?
But the solution it provides doesn't help me.
The error messages are:

Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.15063.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:18 (project):
  No CMAKE_C_COMPILER could be found.

I tried installing both VS2017 and VS2015.3 (IDE), but VS2015.3 refused to create even a simple console program.
Is there another way to generate a solution with v140 toolset?
(P.S. Don't tell me that I should generate with v141 toolset first and modify the toolset option in Visual Studio. That makes a big difference. )

Aurus Huang
  • 372
  • 1
  • 3
  • 17
  • Can you please add the `cmake` command line that produces the error? And could you take please a look at your `CMakeCache.txt` what compiler and nmake paths were used. – Florian Nov 07 '17 at 09:48
  • No. I'm using CMake GUI, and I cannot see the actual command from it. I chose "Visual Studio 15 2017 win64" for the generator, and "v140" for -T parameter. I checked CMakeCache,txt but only find out that it cannot find ANY compiler or linker with above configuration. – Aurus Huang Nov 07 '17 at 09:49

1 Answers1

13

I've just ran a test and it works for me with the following settings in CMake's GUI (Version 3.10.0 RC4):

enter image description here

Then I get the following output:

The CXX compiler identification is MSVC 19.0.24215.1
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
Generating done

And if I open the resulting solution it will - as expected - ask me:

enter image description here

Platform Toolset Mapping

From Marco Foco: Microsoft Visual C++ version Map:

enter image description here

If that don't work ...

First please check the CMakeError.log in your binary output directory. The error should give you a lead on what's wrong.

If that's not helping, you can try several things (besides re-installing VS, which I think won't solve the problem):

  1. One of the Windows SDKs is not fully/correclty installed; Reinstall from Microsoft's web site
  2. Try to give the cmake-gui administrative rights
  3. Check if there is a GNU toolchain with GCC compiler in your PATH environment.

References

Florian
  • 39,996
  • 9
  • 133
  • 149
  • Well...perhaps reinstalling Visual Studio may solve this problem. I'll try it. – Aurus Huang Nov 08 '17 at 00:37
  • 1
    @AurusHuang If the above is not working, first please check the `CMakeError.log` in your binary output directory. I assume one of the following: 1. One of the Windows SDKs is not fully/correclty installed; Reinstall from Microsoft's web site 2. Try to give the `cmake-gui` administrative rights 3. Check if there is a GNU toolchain with GCC compiler in your `PATH` environment. – Florian Nov 08 '17 at 07:52
  • I reinstalled Visual Studio 2017 and upgraded it to latest version. With `v140` typed in CMake, it works. – Aurus Huang Nov 28 '17 at 08:17
  • Thanks. The strange thing is from console not working but gui working. – FindOutIslamNow Nov 01 '18 at 14:39
  • Is there a list of available Tool Set for `XCode` on macOS? – Royi Sep 29 '19 at 14:24