Quellcode durchsuchen

CMP0055: Remove support for OLD behavior

Brad King vor 10 Monaten
Ursprung
Commit
cfcb36ca34

+ 5 - 4
Help/policy/CMP0055.rst

@@ -1,6 +1,9 @@
 CMP0055
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 .. versionadded:: 3.2
 
 Strict checking for the :command:`break` command.
@@ -14,7 +17,5 @@ outside of loop contexts and ignores any arguments.  The ``NEW`` behavior for th
 policy is to issue an error if a misplaced break or any arguments are found.
 
 .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.2
-.. |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

+ 9 - 48
Source/cmBreakCommand.cxx

@@ -2,68 +2,29 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmBreakCommand.h"
 
-#include <sstream>
-
 #include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
-#include "cmPolicies.h"
 
 // cmBreakCommand
 bool cmBreakCommand(std::vector<std::string> const& args,
                     cmExecutionStatus& status)
 {
   if (!status.GetMakefile().IsLoopBlock()) {
-    bool issueMessage = true;
-    std::ostringstream e;
-    MessageType messageType = MessageType::AUTHOR_WARNING;
-    switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0055)) {
-      case cmPolicies::WARN:
-        e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
-        break;
-      case cmPolicies::OLD:
-        issueMessage = false;
-        break;
-      case cmPolicies::NEW:
-        messageType = MessageType::FATAL_ERROR;
-        break;
-    }
-
-    if (issueMessage) {
-      e << "A BREAK command was found outside of a proper "
-           "FOREACH or WHILE loop scope.";
-      status.GetMakefile().IssueMessage(messageType, e.str());
-      if (messageType == MessageType::FATAL_ERROR) {
-        return false;
-      }
-    }
+    status.GetMakefile().IssueMessage(
+      MessageType::FATAL_ERROR,
+      "A BREAK command was found outside of a proper "
+      "FOREACH or WHILE loop scope.");
+    return false;
   }
 
   status.SetBreakInvoked();
 
   if (!args.empty()) {
-    bool issueMessage = true;
-    std::ostringstream e;
-    MessageType messageType = MessageType::AUTHOR_WARNING;
-    switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0055)) {
-      case cmPolicies::WARN:
-        e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
-        break;
-      case cmPolicies::OLD:
-        issueMessage = false;
-        break;
-      case cmPolicies::NEW:
-        messageType = MessageType::FATAL_ERROR;
-        break;
-    }
-
-    if (issueMessage) {
-      e << "The BREAK command does not accept any arguments.";
-      status.GetMakefile().IssueMessage(messageType, e.str());
-      if (messageType == MessageType::FATAL_ERROR) {
-        return false;
-      }
-    }
+    status.GetMakefile().IssueMessage(
+      MessageType::FATAL_ERROR,
+      "The BREAK command does not accept any arguments.");
+    return false;
   }
 
   return true;

+ 1 - 1
Source/cmPolicies.h

@@ -164,7 +164,7 @@ class cmMakefile;
     "Only interpret if() arguments as variables or keywords when unquoted.",  \
     3, 1, 0, NEW)                                                             \
   SELECT(POLICY, CMP0055, "Strict checking for break() command.", 3, 2, 0,    \
-         WARN)                                                                \
+         NEW)                                                                 \
   SELECT(POLICY, CMP0056,                                                     \
          "Honor link flags in try_compile() source-file signature.", 3, 2, 0, \
          WARN)                                                                \

+ 1 - 1
Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt

@@ -1,4 +1,4 @@
-CMake Error at CMP0055-NEW-Out-of-Scope.cmake:4 \(break\):
+CMake Error at CMP0055-NEW-Out-of-Scope.cmake:1 \(break\):
   A BREAK command was found outside of a proper FOREACH or WHILE loop scope.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

+ 0 - 3
Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake

@@ -1,4 +1 @@
-
-cmake_policy(SET CMP0055 NEW)
-
 break()

+ 1 - 1
Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt

@@ -1,4 +1,4 @@
-CMake Error at CMP0055-NEW-Reject-Arguments.cmake:5 \(break\):
+CMake Error at CMP0055-NEW-Reject-Arguments.cmake:2 \(break\):
   The BREAK command does not accept any arguments.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

+ 1 - 4
Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake

@@ -1,6 +1,3 @@
-
-cmake_policy(SET CMP0055 NEW)
-
 foreach(i RANGE 1 2)
   break(1)
-endforeach()
+endforeach()

+ 0 - 1
Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt

@@ -1 +0,0 @@
-0

+ 0 - 10
Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt

@@ -1,10 +0,0 @@
-^CMake Deprecation Warning at CMP0055-OLD-Out-of-Scope.cmake:[0-9]+ \(cmake_policy\):
-  The OLD behavior for policy CMP0055 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:[0-9]+ \(include\)$

+ 0 - 4
Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake

@@ -1,4 +0,0 @@
-
-cmake_policy(SET CMP0055 OLD)
-
-break()

+ 0 - 1
Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt

@@ -1 +0,0 @@
-0

+ 0 - 10
Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt

@@ -1,10 +0,0 @@
-^CMake Deprecation Warning at CMP0055-OLD-Reject-Arguments.cmake:[0-9]+ \(cmake_policy\):
-  The OLD behavior for policy CMP0055 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:[0-9]+ \(include\)$

+ 0 - 6
Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake

@@ -1,6 +0,0 @@
-
-cmake_policy(SET CMP0055 OLD)
-
-foreach(i RANGE 1 2)
-  break(1)
-endforeach()

+ 0 - 1
Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt

@@ -1 +0,0 @@
-0

+ 0 - 9
Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt

@@ -1,9 +0,0 @@
-CMake Warning \(dev\) at CMP0055-WARN-Out-of-Scope.cmake:2 \(break\):
-  Policy CMP0055 is not set: Strict checking for break\(\) command.  Run "cmake
-  --help-policy CMP0055" for policy details.  Use the cmake_policy command to
-  set the policy and suppress this warning.
-
-  A BREAK command was found outside of a proper FOREACH or WHILE loop scope.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
-This warning is for project developers.  Use -Wno-dev to suppress it.

+ 0 - 2
Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake

@@ -1,2 +0,0 @@
-
-break()

+ 0 - 1
Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt

@@ -1 +0,0 @@
-0

+ 0 - 9
Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt

@@ -1,9 +0,0 @@
-CMake Warning \(dev\) at CMP0055-WARN-Reject-Arguments.cmake:3 \(break\):
-  Policy CMP0055 is not set: Strict checking for break\(\) command.  Run "cmake
-  --help-policy CMP0055" for policy details.  Use the cmake_policy command to
-  set the policy and suppress this warning.
-
-  The BREAK command does not accept any arguments.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
-This warning is for project developers.  Use -Wno-dev to suppress it.

+ 0 - 4
Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake

@@ -1,4 +0,0 @@
-
-foreach(i RANGE 1 2)
-  break(1)
-endforeach()

+ 1 - 1
Tests/RunCMake/CMP0055/CMakeLists.txt

@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.10)
 project(${RunCMake_TEST} NONE)
 include(${RunCMake_TEST}.cmake)

+ 0 - 6
Tests/RunCMake/CMP0055/RunCMakeTest.cmake

@@ -1,10 +1,4 @@
 include(RunCMake)
-set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
 
-run_cmake(CMP0055-OLD-Out-of-Scope)
 run_cmake(CMP0055-NEW-Out-of-Scope)
-run_cmake(CMP0055-WARN-Out-of-Scope)
-
-run_cmake(CMP0055-OLD-Reject-Arguments)
 run_cmake(CMP0055-NEW-Reject-Arguments)
-run_cmake(CMP0055-WARN-Reject-Arguments)