فهرست منبع

CMP0016: Remove support for OLD behavior

Brad King 11 ماه پیش
والد
کامیت
ae13e27225
3فایلهای تغییر یافته به همراه11 افزوده شده و 41 حذف شده
  1. 5 4
      Help/policy/CMP0016.rst
  2. 1 1
      Source/cmPolicies.h
  3. 5 36
      Source/cmTargetLinkLibrariesCommand.cxx

+ 5 - 4
Help/policy/CMP0016.rst

@@ -1,6 +1,9 @@
 CMP0016
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 :command:`target_link_libraries` reports error if its only argument
 is not a target.
 
@@ -10,7 +13,5 @@ wasn't a valid target.  In CMake 2.8.3 and above it reports an error
 in this case.
 
 .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.3
-.. |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
Source/cmPolicies.h

@@ -60,7 +60,7 @@ class cmMakefile;
   SELECT(POLICY, CMP0016,                                                     \
          "target_link_libraries() reports error if its only argument "        \
          "is not a target.",                                                  \
-         2, 8, 3, WARN)                                                       \
+         2, 8, 3, NEW)                                                        \
   SELECT(POLICY, CMP0017,                                                     \
          "Prefer files from the CMake module directory when including from "  \
          "there.",                                                            \

+ 5 - 36
Source/cmTargetLinkLibrariesCommand.cxx

@@ -95,42 +95,11 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
     }
   }
   if (!target) {
-    MessageType t = MessageType::FATAL_ERROR; // fail by default
-    std::ostringstream e;
-    e << "Cannot specify link libraries for target \"" << args[0]
-      << "\" which is not built by this project.";
-    // The bad target is the only argument. Check how policy CMP0016 is set,
-    // and accept, warn or fail respectively:
-    if (args.size() < 2) {
-      switch (mf.GetPolicyStatus(cmPolicies::CMP0016)) {
-        case cmPolicies::WARN:
-          t = MessageType::AUTHOR_WARNING;
-          // Print the warning.
-          e << "\n"
-               "CMake does not support this but it used to work accidentally "
-               "and is being allowed for compatibility."
-               "\n"
-            << cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
-          break;
-        case cmPolicies::OLD: // OLD behavior does not warn.
-          t = MessageType::MESSAGE;
-          break;
-        case cmPolicies::NEW: // NEW behavior prints the error.
-          break;
-      }
-    }
-    // Now actually print the message.
-    switch (t) {
-      case MessageType::AUTHOR_WARNING:
-        mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
-        break;
-      case MessageType::FATAL_ERROR:
-        mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
-        cmSystemTools::SetFatalErrorOccurred();
-        break;
-      default:
-        break;
-    }
+    mf.IssueMessage(MessageType::FATAL_ERROR,
+                    cmStrCat("Cannot specify link libraries for target \"",
+                             args[0],
+                             "\" which is not built by this project."));
+    cmSystemTools::SetFatalErrorOccurred();
     return true;
   }