Skip to content

[pull] master from Kitware:master #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Help/manual/cmake-policies.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Policies Introduced by CMake 4.1
.. toctree::
:maxdepth: 1

CMP0196: The CMakeDetermineVSServicePack module is removed. </policy/CMP0196>
CMP0195: Swift modules in build trees use the Swift module directory structure. </policy/CMP0195>
CMP0194: MSVC is not an assembler for language ASM. </policy/CMP0194>
CMP0193: GNUInstallDirs caches CMAKE_INSTALL_* with leading 'usr/' for install prefix '/'. </policy/CMP0193>
Expand Down
23 changes: 23 additions & 0 deletions Help/policy/CMP0196.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CMP0196
-------

.. versionadded:: 4.1

The :module:`CMakeDetermineVSServicePack` module is removed.

The ``CMakeDetermineVSServicePack`` module has long been superseded by
the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable, and the module
has been documented as deprecated since CMake 3.0. CMake 4.1 and above
prefer to not provide the module. This policy provides compatibility
for projects that have not been ported away from it.

The ``OLD`` behavior of this policy is for
``include(CMakeDetermineVSServicePack)`` to load the deprecated module.
The ``NEW`` behavior halts with a fatal error if anything tries to include
the module.

.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.1
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
.. include:: include/STANDARD_ADVICE.rst

.. include:: include/DEPRECATED.rst
6 changes: 6 additions & 0 deletions Help/release/dev/remove-CMakeDetermineVSServicePack.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
remove-CMakeDetermineVSServicePack
----------------------------------

* The :module`:CMakeDetermineVSServicePack` module has been deprecated
via policy :policy:`CMP0196`. Port projects to the
:variable:`CMAKE_<LANG>_COMPILER_VERSION` variable instead.
14 changes: 14 additions & 0 deletions Modules/CMakeDetermineVSServicePack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
CMakeDetermineVSServicePack
---------------------------

.. versionchanged:: 4.1

This module is available only if policy :policy:`CMP0196` is not set to ``NEW``.

.. deprecated:: 3.0

This module should no longer be used. The functionality of this module has
Expand Down Expand Up @@ -59,6 +63,16 @@ Determining the Visual Studio service pack version in a project:
endif()
#]=======================================================================]

cmake_policy(GET CMP0196 _CMakeDetermineVSServicePack_CMP0196)
if(_CMakeDetermineVSServicePack_CMP0196 STREQUAL "NEW")
message(FATAL_ERROR "The CMakeDetermineVSServicePack module has been removed by policy CMP0196.")
endif()

if(_CMakeDetermineVSServicePack_testing)
set(_CMakeDetermineVSServicePack_included TRUE)
return()
endif()

if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8)
message(DEPRECATION
"This module is deprecated and should not be used. "
Expand Down
1 change: 1 addition & 0 deletions Source/cmIncludeCommand.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bool cmIncludeCommand(std::vector<std::string> const& args,
{
static std::map<std::string, cmPolicies::PolicyID> DeprecatedModules;
if (DeprecatedModules.empty()) {
DeprecatedModules["CMakeDetermineVSServicePack"] = cmPolicies::CMP0196;
DeprecatedModules["CMakeFindFrameworks"] = cmPolicies::CMP0173;
DeprecatedModules["Dart"] = cmPolicies::CMP0145;
DeprecatedModules["Documentation"] = cmPolicies::CMP0106;
Expand Down
4 changes: 3 additions & 1 deletion Source/cmPolicies.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@ class cmMakefile;
SELECT( \
POLICY, CMP0195, \
"Swift modules in build trees use the Swift module directory structure.", \
4, 1, 0, WARN)
4, 1, 0, WARN) \
SELECT(POLICY, CMP0196, \
"The CMakeDetermineVSServicePack module is removed.", 4, 1, 0, WARN)

#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
Expand Down
1 change: 1 addition & 0 deletions Tests/RunCMake/include/CMP0196-NEW-name-result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
6 changes: 6 additions & 0 deletions Tests/RunCMake/include/CMP0196-NEW-name-stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
^CMake Error at CMP0196-NEW-name\.cmake:[0-9]+ \(include\):
include could not find requested file:

CMakeDetermineVSServicePack
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$
2 changes: 2 additions & 0 deletions Tests/RunCMake/include/CMP0196-NEW-name.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cmake_policy(SET CMP0196 NEW)
include(CMakeDetermineVSServicePack)
1 change: 1 addition & 0 deletions Tests/RunCMake/include/CMP0196-NEW-path-result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
6 changes: 6 additions & 0 deletions Tests/RunCMake/include/CMP0196-NEW-path-stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
^CMake Error at [^
]*/Modules/CMakeDetermineVSServicePack.cmake:[0-9]+ \(message\):
The CMakeDetermineVSServicePack module has been removed by policy CMP0196\.
Call Stack \(most recent call first\):
CMP0196-NEW-path\.cmake:[0-9]+ \(include\)
CMakeLists\.txt:[0-9]+ \(include\)$
2 changes: 2 additions & 0 deletions Tests/RunCMake/include/CMP0196-NEW-path.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cmake_policy(SET CMP0196 NEW)
include(${CMAKE_ROOT}/Modules/CMakeDetermineVSServicePack.cmake)
7 changes: 7 additions & 0 deletions Tests/RunCMake/include/CMP0196-OLD.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_policy(SET CMP0196 OLD)
set(_CMakeDetermineVSServicePack_testing 1)
include(CMakeDetermineVSServicePack)

if(NOT _CMakeDetermineVSServicePack_included)
message(FATAL_ERROR "CMakeDetermineVSServicePack.cmake not included")
endif()
8 changes: 8 additions & 0 deletions Tests/RunCMake/include/CMP0196-WARN-stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
^CMake Warning \(dev\) at CMP0196-WARN\.cmake:[0-9]+ \(include\):
Policy CMP0196 is not set: The CMakeDetermineVSServicePack module is
removed\. Run "cmake --help-policy CMP0196" for policy details\. Use the
cmake_policy command to set the policy and suppress this warning\.

Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-dev to suppress it\.$
7 changes: 7 additions & 0 deletions Tests/RunCMake/include/CMP0196-WARN.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Do not set CMP0196.
set(_CMakeDetermineVSServicePack_testing 1)
include(CMakeDetermineVSServicePack)

if(NOT _CMakeDetermineVSServicePack_included)
message(FATAL_ERROR "CMakeDetermineVSServicePack.cmake not included")
endif()
5 changes: 5 additions & 0 deletions Tests/RunCMake/include/RunCMakeTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ run_cmake(CMP0191-OLD)
run_cmake(CMP0191-WARN)
run_cmake(CMP0191-NEW-name)
run_cmake(CMP0191-NEW-path)

run_cmake(CMP0196-OLD)
run_cmake(CMP0196-WARN)
run_cmake(CMP0196-NEW-name)
run_cmake(CMP0196-NEW-path)