Переглянути джерело

CMP0038: Remove support for OLD behavior

Brad King 11 місяців тому
батько
коміт
af28f030d8

+ 5 - 4
Help/policy/CMP0038.rst

@@ -1,6 +1,9 @@
 CMP0038
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 Targets may not link directly to themselves.
 
 CMake 2.8.12 and lower allowed a build target to link to itself directly with
@@ -12,7 +15,5 @@ in their own link implementation.  The ``NEW`` behavior for this policy is to
 report an error if a target attempts to link to itself.
 
 .. |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

+ 5 - 24
Source/cmGeneratorTarget_Link.cxx

@@ -1189,30 +1189,11 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
       }
       if (name == this->GetName() || name.empty()) {
         if (name == this->GetName()) {
-          bool noMessage = false;
-          MessageType messageType = MessageType::FATAL_ERROR;
-          std::ostringstream e;
-          switch (this->GetPolicyStatusCMP0038()) {
-            case cmPolicies::WARN: {
-              e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n";
-              messageType = MessageType::AUTHOR_WARNING;
-            } break;
-            case cmPolicies::OLD:
-              noMessage = true;
-              break;
-            case cmPolicies::NEW:
-              // Issue the fatal message.
-              break;
-          }
-
-          if (!noMessage) {
-            e << "Target \"" << this->GetName() << "\" links to itself.";
-            this->LocalGenerator->GetCMakeInstance()->IssueMessage(
-              messageType, e.str(), this->GetBacktrace());
-            if (messageType == MessageType::FATAL_ERROR) {
-              return;
-            }
-          }
+          this->LocalGenerator->GetCMakeInstance()->IssueMessage(
+            MessageType::FATAL_ERROR,
+            cmStrCat("Target \"", this->GetName(), "\" links to itself."),
+            this->GetBacktrace());
+          return;
         }
         continue;
       }

+ 1 - 1
Source/cmPolicies.h

@@ -119,7 +119,7 @@ class cmMakefile;
          "pattern.",                                                          \
          3, 0, 0, NEW)                                                        \
   SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3,  \
-         0, 0, WARN)                                                          \
+         0, 0, NEW)                                                           \
   SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.",  \
          3, 0, 0, WARN)                                                       \
   SELECT(POLICY, CMP0040,                                                     \

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

@@ -1,4 +1,4 @@
-CMake Error at CMP0038-NEW.cmake:3 \(add_library\):
+CMake Error at CMP0038-NEW.cmake:1 \(add_library\):
   Target "self_link" links to itself.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

+ 0 - 2
Tests/RunCMake/CMP0038/CMP0038-NEW.cmake

@@ -1,4 +1,2 @@
-
-cmake_policy(SET CMP0038 NEW)
 add_library(self_link empty.cpp)
 target_link_libraries(self_link self_link)

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

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

@@ -1,4 +0,0 @@
-
-cmake_policy(SET CMP0038 OLD)
-add_library(self_link empty.cpp)
-target_link_libraries(self_link self_link)

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

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

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

@@ -1,9 +0,0 @@
-CMake Warning \(dev\) at CMP0038-WARN.cmake:2 \(add_library\):
-  Policy CMP0038 is not set: Targets may not link directly to themselves.
-  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
-
-  Target "self_link" links to itself.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
-This warning is for project developers.  Use -Wno-dev to suppress it.

+ 0 - 3
Tests/RunCMake/CMP0038/CMP0038-WARN.cmake

@@ -1,3 +0,0 @@
-
-add_library(self_link empty.cpp)
-target_link_libraries(self_link self_link)

+ 1 - 1
Tests/RunCMake/CMP0038/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/CMP0038/RunCMakeTest.cmake

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

+ 0 - 1
Tests/RunCMake/target_link_libraries/CMP0108-self-link.cmake

@@ -1,5 +1,4 @@
 
-cmake_policy (SET CMP0038 NEW)
 cmake_policy (SET CMP0042 NEW)
 
 enable_language(C)