CMP0039: Remove support for OLD behavior

This commit is contained in:
Brad King
2025-01-19 09:41:01 -05:00
parent af28f030d8
commit 0b6412b514
12 changed files with 16 additions and 71 deletions
+5 -4
View File
@@ -1,6 +1,9 @@
CMP0039
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
Utility targets may not have link dependencies.
CMake 2.8.12 and lower allowed using utility targets in the left hand side
@@ -13,7 +16,5 @@ report an error if an attempt is made to set the link libraries of a
utility target.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
.. include:: STANDARD_ADVICE.txt
.. include:: DEPRECATED.txt
.. |WARNED_OR_DID_NOT_WARN| replace:: warned
.. include:: REMOVED_EPILOGUE.txt
+1 -1
View File
@@ -121,7 +121,7 @@ class cmMakefile;
SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3, \
0, 0, NEW) \
SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.", \
3, 0, 0, WARN) \
3, 0, 0, NEW) \
SELECT(POLICY, CMP0040, \
"The target in the TARGET signature of add_custom_command() must " \
"exist and must be defined in the current directory.", \
+6 -23
View File
@@ -103,29 +103,12 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
// Having a UTILITY library on the LHS is a bug.
if (target->GetType() == cmStateEnums::UTILITY) {
std::ostringstream e;
const char* modal = nullptr;
MessageType messageType = MessageType::AUTHOR_WARNING;
switch (mf.GetPolicyStatus(cmPolicies::CMP0039)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << '\n';
modal = "should";
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
modal = "must";
messageType = MessageType::FATAL_ERROR;
break;
}
if (modal) {
e << "Utility target \"" << target->GetName() << "\" " << modal
<< " not be used as the target of a target_link_libraries call.";
mf.IssueMessage(messageType, e.str());
if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
mf.IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat(
"Utility target \"", target->GetName(),
"\" must not be used as the target of a target_link_libraries call."));
return false;
}
// But we might not have any libs after variable expansion.
@@ -1,5 +1,5 @@
CMake Error at CMP0039-NEW.cmake:7 \(target_link_libraries\):
CMake Error at CMP0039-NEW\.cmake:[0-9]+ \(target_link_libraries\):
Utility target "utility" must not be used as the target of a
target_link_libraries call.
target_link_libraries call\.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
CMakeLists\.txt:[0-9]+ \(include\)
-3
View File
@@ -1,6 +1,3 @@
cmake_policy(SET CMP0039 NEW)
add_custom_target(utility
COMMAND ${CMAKE_COMMAND} -E echo test
)
@@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0039-OLD.cmake:2 \(cmake_policy\):
The OLD behavior for policy CMP0039 will be removed from a future version
of CMake.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
-7
View File
@@ -1,7 +0,0 @@
cmake_policy(SET CMP0039 OLD)
add_custom_target(utility
COMMAND ${CMAKE_COMMAND} -E echo test
)
target_link_libraries(utility m)
@@ -1 +0,0 @@
0
@@ -1,10 +0,0 @@
CMake Warning \(dev\) at CMP0039-WARN.cmake:5 \(target_link_libraries\):
Policy CMP0039 is not set: Utility targets may not have link dependencies.
Run "cmake --help-policy CMP0039" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
Utility target "utility" should not be used as the target of a
target_link_libraries call.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
@@ -1,5 +0,0 @@
add_custom_target(utility
COMMAND ${CMAKE_COMMAND} -E echo test
)
target_link_libraries(utility m)
+1 -1
View File
@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.10)
project(${RunCMake_TEST} CXX)
include(${RunCMake_TEST}.cmake)
@@ -1,6 +1,3 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(CMP0039-WARN)
run_cmake(CMP0039-NEW)
run_cmake(CMP0039-OLD)