填坑日记:CMake选不到vs2010

今天打算编译一个VS2010下使用的PDFHummus,发现新版本的CMake居然移除了VS2010的支持。

坑的描述 CMake3.26.4无法生成vc10 windows工程
根本原因 CMake移除了对vc10的支持
填坑进度 已解决

问题描述:

你说气不气人,vc9(VS2008)都还在,唯独把VS10移除了支持。

CMake-GUI编译器选择界面

原因分析:

官方倒也不藏着掖着,直接告诉你,我就是移除支持了。(https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2010%202010.html

Removed. This once generated Visual Studio 10 2010 project files, but the generator has been removed since CMake 3.25. It is still possible to build with VS 10 2010 tools using the Visual Studio 12 2013 (or above) generator with CMAKE_GENERATOR_TOOLSET set to v100, or by using the NMake Makefiles generator.

解决方案:

  • 官方帮助里面也写了,可以使用高版本VS来“曲线救国”。其原理,是VS允许选择当前计算机安装过的、其他版本的vc套件来执行编译。如下图所示:
VS选择其他vc套件
  • 对应到CMake-GUI里面,设置如下:
CMake-GUI中配置使用vs2019中使用vc10套件
  • 之后生成的windows工程使用VS2019打开,就可以正常编译了。
vs2019编译界面

二零二三年八月二十五日 顾毅写于厦门