CMP0046: Remove support for OLD behavior

This commit is contained in:
Brad King
2024-12-05 14:14:38 -05:00
parent 1e8a744f07
commit d9498a474e
17 changed files with 14 additions and 101 deletions

View File

@@ -1,6 +1,9 @@
CMP0046
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
Error on non-existent dependency in add_dependencies.
CMake 2.8.12 and lower silently ignored non-existent dependencies
@@ -12,7 +15,5 @@ if non-existent dependencies are listed in the :command:`add_dependencies`
command.
.. |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

View File

@@ -17,12 +17,12 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocationKind.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetDepend.h"
@@ -353,29 +353,11 @@ void cmComputeTargetDepends::AddTargetDepend(size_t depender_index,
if (!dependee && !linking &&
(depender->GetType() != cmStateEnums::GLOBAL_TARGET)) {
MessageType messageType = MessageType::AUTHOR_WARNING;
bool issueMessage = false;
std::ostringstream e;
switch (depender->GetPolicyStatusCMP0046()) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n";
issueMessage = true;
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
issueMessage = true;
messageType = MessageType::FATAL_ERROR;
break;
}
if (issueMessage) {
cmake* cm = this->GlobalGenerator->GetCMakeInstance();
e << "The dependency target \"" << dependee_name << "\" of target \""
<< depender->GetName() << "\" does not exist.";
cm->IssueMessage(messageType, e.str(), dependee_name.Backtrace);
}
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The dependency target \"", dependee_name.AsStr(),
"\" of target \"", depender->GetName(), "\" does not exist."),
dependee_name.Backtrace);
}
// Skip targets that will not really be linked. This is probably a

View File

@@ -141,7 +141,7 @@ class cmMakefile;
NEW) \
SELECT(POLICY, CMP0046, \
"Error on non-existent dependency in add_dependencies.", 3, 0, 0, \
WARN) \
NEW) \
SELECT(POLICY, CMP0047, "Use QCC compiler id for the qcc drivers on QNX.", \
3, 0, 0, WARN) \
SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3, \

View File

@@ -1,10 +0,0 @@
CMake Warning \(dev\) at CMP0046-Duplicate.cmake:5 \(add_dependencies\):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
The dependency target "ctgt_no_exist" of target "dummy" does not exist.
Call Stack \(most recent call first\):
CMP0046-Duplicate.cmake:8 \(add_dep\)
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@@ -1,9 +0,0 @@
add_library(dummy empty.cpp)
macro(add_dep)
add_dependencies(dummy ctgt_no_exist)
endmacro()
add_dep()
add_dep()

View File

@@ -1,5 +1,3 @@
cmake_policy(SET CMP0046 NEW)
add_custom_target(foo)
add_custom_target(bar)
add_dependencies(foo bar)

View File

@@ -1,4 +1,4 @@
CMake Error at CMP0046-NEW-missing-dependency.cmake:4 \(add_dependencies\):
CMake Error at CMP0046-NEW-missing-dependency.cmake:[0-9]+ \(add_dependencies\):
The dependency target "bar" of target "foo" does not exist.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@@ -1,4 +1,2 @@
cmake_policy(SET CMP0046 NEW)
add_custom_target(foo)
add_dependencies(foo bar)

View File

@@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0046-OLD-existing-dependency.cmake:1 \(cmake_policy\):
The OLD behavior for policy CMP0046 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\)$

View File

@@ -1,5 +0,0 @@
cmake_policy(SET CMP0046 OLD)
add_custom_target(foo)
add_custom_target(bar)
add_dependencies(foo bar)

View File

@@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0046-OLD-missing-dependency.cmake:1 \(cmake_policy\):
The OLD behavior for policy CMP0046 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\)$

View File

@@ -1,4 +0,0 @@
cmake_policy(SET CMP0046 OLD)
add_custom_target(foo)
add_dependencies(foo bar)

View File

@@ -1,9 +0,0 @@
CMake Warning \(dev\) at CMP0046-WARN-missing-dependency.cmake:2 \(add_dependencies\):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
+
The dependency target "bar" of target "foo" does not exist.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@@ -1,2 +0,0 @@
add_custom_target(foo)
add_dependencies(foo bar)

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)

View File

@@ -1,10 +1,4 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(CMP0046-OLD-missing-dependency)
run_cmake(CMP0046-NEW-missing-dependency)
run_cmake(CMP0046-WARN-missing-dependency)
run_cmake(CMP0046-OLD-existing-dependency)
run_cmake(CMP0046-NEW-existing-dependency)
run_cmake(CMP0046-Duplicate)