فهرست منبع

CMP0045: Remove support for OLD behavior

Brad King 1 سال پیش
والد
کامیت
1e8a744f07

+ 5 - 4
Help/policy/CMP0045.rst

@@ -1,6 +1,9 @@
 CMP0045
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 Error on non-existent target in get_target_property.
 
 In CMake 2.8.12 and lower, the :command:`get_target_property` command accepted
@@ -13,7 +16,5 @@ for this policy is to issue a ``FATAL_ERROR`` if the command is called with a
 non-existent 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

+ 6 - 26
Source/cmGetTargetPropertyCommand.cxx

@@ -2,13 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGetTargetPropertyCommand.h"
 
-#include <sstream>
-
 #include "cmExecutionStatus.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
-#include "cmPolicies.h"
+#include "cmStringAlgorithms.h"
 #include "cmTarget.h"
 #include "cmValue.h"
 
@@ -50,29 +48,11 @@ bool cmGetTargetPropertyCommand(std::vector<std::string> const& args,
       }
     }
   } else {
-    bool issueMessage = false;
-    std::ostringstream e;
-    MessageType messageType = MessageType::AUTHOR_WARNING;
-    switch (mf.GetPolicyStatus(cmPolicies::CMP0045)) {
-      case cmPolicies::WARN:
-        issueMessage = true;
-        e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0045) << "\n";
-        CM_FALLTHROUGH;
-      case cmPolicies::OLD:
-        break;
-      case cmPolicies::NEW:
-        issueMessage = true;
-        messageType = MessageType::FATAL_ERROR;
-        break;
-    }
-    if (issueMessage) {
-      e << "get_target_property() called with non-existent target \""
-        << targetName << "\".";
-      mf.IssueMessage(messageType, e.str());
-      if (messageType == MessageType::FATAL_ERROR) {
-        return false;
-      }
-    }
+    mf.IssueMessage(
+      MessageType::FATAL_ERROR,
+      cmStrCat("get_target_property() called with non-existent target \"",
+               targetName, "\"."));
+    return false;
   }
   if (prop_exists) {
     mf.AddDefinition(var, prop);

+ 1 - 1
Source/cmPolicies.h

@@ -138,7 +138,7 @@ class cmMakefile;
          NEW)                                                                 \
   SELECT(POLICY, CMP0045,                                                     \
          "Error on non-existent target in get_target_property.", 3, 0, 0,     \
-         WARN)                                                                \
+         NEW)                                                                 \
   SELECT(POLICY, CMP0046,                                                     \
          "Error on non-existent dependency in add_dependencies.", 3, 0, 0,    \
          WARN)                                                                \

+ 1 - 1
Tests/RunCMake/CMP0045/CMP0045-NEW-stderr.txt

@@ -1,4 +1,4 @@
-CMake Error at CMP0045-NEW.cmake:4 \(get_target_property\):
+CMake Error at CMP0045-NEW.cmake:[0-9]+ \(get_target_property\):
   get_target_property\(\) called with non-existent target "tgt".
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

+ 0 - 3
Tests/RunCMake/CMP0045/CMP0045-NEW.cmake

@@ -1,4 +1 @@
-
-cmake_policy(SET CMP0045 NEW)
-
 get_target_property(result tgt TYPE)

+ 0 - 10
Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt

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

+ 0 - 4
Tests/RunCMake/CMP0045/CMP0045-OLD.cmake

@@ -1,4 +0,0 @@
-
-cmake_policy(SET CMP0045 OLD)
-
-get_target_property(result tgt TYPE)

+ 0 - 1
Tests/RunCMake/CMP0045/CMP0045-WARN-result.txt

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

+ 0 - 9
Tests/RunCMake/CMP0045/CMP0045-WARN-stderr.txt

@@ -1,9 +0,0 @@
-CMake Warning \(dev\) at CMP0045-WARN.cmake:2 \(get_target_property\):
-  Policy CMP0045 is not set: Error on non-existent target in
-  get_target_property.  Run "cmake --help-policy CMP0045" for policy details.
-  Use the cmake_policy command to set the policy and suppress this warning.
-
-  get_target_property\(\) called with non-existent target "tgt".
-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/CMP0045/CMP0045-WARN.cmake

@@ -1,2 +0,0 @@
-
-get_target_property(result tgt TYPE)

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

@@ -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)

+ 0 - 3
Tests/RunCMake/CMP0045/RunCMakeTest.cmake

@@ -1,6 +1,3 @@
 include(RunCMake)
-set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
 
-run_cmake(CMP0045-OLD)
 run_cmake(CMP0045-NEW)
-run_cmake(CMP0045-WARN)