CMakeDetermineVSServicePack

在 4.1 版的變更: This module is available only if policy CMP0196 is not set to NEW.

在 3.0 版之後被棄用: This module should no longer be used. The functionality of this module has been superseded by the CMAKE_<LANG>_COMPILER_VERSION variable that contains the compiler version number.

This module provides a command to determine the installed Visual Studio service pack version for Visual Studio 2012 and earlier.

Load this module in a CMake project with:

include(CMakeDetermineVSServicePack)

Commands

This module provides the following command:

DetermineVSServicePack

Determines the Visual Studio service pack version of the cl compiler in use:

DetermineVSServicePack(<variable>)

The result is stored in the specified internal cache variable <variable>, which is set to one of the following values, or to an empty string if the service pack cannot be determined:

  • vc80, vc80sp1

  • vc90, vc90sp1

  • vc100, vc100sp1

  • vc110, vc110sp1, vc110sp2, vc110sp3, vc110sp4

範例

Determining the Visual Studio service pack version in a project:

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