Sfoglia il codice sorgente

CMP0039: Remove support for OLD behavior

Brad King 11 mesi fa
parent
commit
0b6412b514

+ 5 - 4
Help/policy/CMP0039.rst

@@ -1,6 +1,9 @@
 CMP0039
 CMP0039
 -------
 -------
 
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 Utility targets may not have link dependencies.
 Utility targets may not have link dependencies.
 
 
 CMake 2.8.12 and lower allowed using utility targets in the left hand side
 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.
 utility target.
 
 
 .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0
 .. |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
Source/cmPolicies.h

@@ -121,7 +121,7 @@ class cmMakefile;
   SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3,  \
   SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3,  \
          0, 0, NEW)                                                           \
          0, 0, NEW)                                                           \
   SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.",  \
   SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.",  \
-         3, 0, 0, WARN)                                                       \
+         3, 0, 0, NEW)                                                        \
   SELECT(POLICY, CMP0040,                                                     \
   SELECT(POLICY, CMP0040,                                                     \
          "The target in the TARGET signature of add_custom_command() must "   \
          "The target in the TARGET signature of add_custom_command() must "   \
          "exist and must be defined in the current directory.",               \
          "exist and must be defined in the current directory.",               \

+ 6 - 23
Source/cmTargetLinkLibrariesCommand.cxx

@@ -103,29 +103,12 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
 
 
   // Having a UTILITY library on the LHS is a bug.
   // Having a UTILITY library on the LHS is a bug.
   if (target->GetType() == cmStateEnums::UTILITY) {
   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.
   // But we might not have any libs after variable expansion.

+ 3 - 3
Tests/RunCMake/CMP0039/CMP0039-NEW-stderr.txt

@@ -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
   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\):
 Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
+  CMakeLists\.txt:[0-9]+ \(include\)

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

@@ -1,6 +1,3 @@
-
-cmake_policy(SET CMP0039 NEW)
-
 add_custom_target(utility
 add_custom_target(utility
   COMMAND ${CMAKE_COMMAND} -E echo test
   COMMAND ${CMAKE_COMMAND} -E echo test
 )
 )

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

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

+ 0 - 7
Tests/RunCMake/CMP0039/CMP0039-OLD.cmake

@@ -1,7 +0,0 @@
-
-cmake_policy(SET CMP0039 OLD)
-
-add_custom_target(utility
-  COMMAND ${CMAKE_COMMAND} -E echo test
-)
-target_link_libraries(utility m)

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

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

+ 0 - 10
Tests/RunCMake/CMP0039/CMP0039-WARN-stderr.txt

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

+ 0 - 5
Tests/RunCMake/CMP0039/CMP0039-WARN.cmake

@@ -1,5 +0,0 @@
-
-add_custom_target(utility
-  COMMAND ${CMAKE_COMMAND} -E echo test
-)
-target_link_libraries(utility m)

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

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

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

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