CMake:如何指定安装了VS2017的VS2015.3工具集

Aur*_*ang 4 c++ compilation cmake visual-studio-2015 visual-studio-2017

我安装了VS2017,安装了VS2017(v141)和VS2015.3(v140)工具集.我需要用CMake生成一个解决方案,我希望CMake被"愚弄",好像安装了VS2015,所以我可以使用v140工具集构建项目.
我知道这个问题可能与以下内容重复: cmake如何为Visual Studio 2015项目指定"Platform Toolset"?
但它提供的解决方案对我没有帮助.
错误消息是:

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.
Run Code Online (Sandbox Code Playgroud)

我尝试安装VS2017和VS2015.3(IDE),但VS2015.3拒绝创建一个简单的控制台程序.
有没有其他方法可以使用v140工具集生成解决方案?
(PS不要告诉我,我应该首先使用v141工具集生成并修改Visual Studio中的工具集选项.这会产生很大的不同.)

Flo*_*ian 7

我刚刚运行了一个测试,它适用于我在CMake的GUI(版本3.10.0 RC4)中的以下设置:

在此输入图像描述

然后我得到以下输出:

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
Run Code Online (Sandbox Code Playgroud)

如果我打开最终的解决方案,它会 - 正如预期的那样 - 问我:

在此输入图像描述

平台工具集映射

来自Marco Foco:Microsoft Visual C++版本地图:

在此输入图像描述

如果那不起作用......

首先请检查CMakeError.log二进制输出目录中的内容.该错误应该会让你对错误有所了解.

如果这没有帮助,你可以尝试几件事(除了重新安装VS,我认为不会解决问题):

  1. 其中一个Windows SDK未完全/ correclty安装; 从Microsoft的网站重新安装
  2. 尝试授予cmake-gui管理权限
  3. 检查PATH环境中是否有带GCC编译器的GNU工具链.

参考