CMakeDetermineVSServicePack

4.1 版中已更改:此模块仅在策略 CMP0196 未设置为 NEW 时可用。

自 3.0 版起已弃用:此模块不应再使用。此模块的功能已被包含编译器版本号的 CMAKE_<LANG>_COMPILER_VERSION 变量取代。

此模块提供了一个命令,用于确定 Visual Studio 2012 及更早版本所安装的 Visual Studio Service Pack 版本。

在 CMake 项目中加载此模块,使用

include(CMakeDetermineVSServicePack)

命令

此模块提供以下命令

DetermineVSServicePack

确定正在使用的 cl 编译器的 Visual Studio Service Pack 版本

DetermineVSServicePack(<variable>)

结果存储在指定的内部缓存变量 <variable> 中,该变量设置为以下值之一,如果无法确定 Service Pack,则设置为空字符串

  • vc80, vc80sp1

  • vc90, vc90sp1

  • vc100, vc100sp1

  • vc110, vc110sp1, vc110sp2, vc110sp3, vc110sp4

示例

在项目中确定 Visual Studio Service Pack 版本

if(MSVC)
  include(CMakeDetermineVSServicePack)
  DetermineVSServicePack(my_service_pack)
  if(my_service_pack)
    message(STATUS "Detected: ${my_service_pack}")
  endif()
endif()