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

CMP0004: Remove support for OLD behavior

Brad King 1 рік тому
батько
коміт
2a0a7401ce

+ 5 - 4
Help/policy/CMP0004.rst

@@ -1,6 +1,9 @@
 CMP0004
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 Libraries linked may not have leading or trailing whitespace.
 
 CMake versions 2.4 and below silently removed leading and trailing
@@ -20,7 +23,5 @@ target is created by an :command:`add_executable` or :command:`add_library`
 command.
 
 .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.6.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 - 21
Source/cmGeneratorTarget.cxx

@@ -4744,27 +4744,11 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
   }
   if (lib != item) {
     cmake* cm = this->LocalGenerator->GetCMakeInstance();
-    switch (this->GetPolicyStatusCMP0004()) {
-      case cmPolicies::WARN: {
-        std::ostringstream w;
-        w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n"
-          << "Target \"" << this->GetName() << "\" links to item \"" << item
-          << "\" which has leading or trailing whitespace.";
-        cm->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
-                         this->GetBacktrace());
-      }
-        CM_FALLTHROUGH;
-      case cmPolicies::OLD:
-        break;
-      case cmPolicies::NEW: {
-        std::ostringstream e;
-        e << "Target \"" << this->GetName() << "\" links to item \"" << item
-          << "\" which has leading or trailing whitespace.  "
-          << "This is now an error according to policy CMP0004.";
-        cm->IssueMessage(MessageType::FATAL_ERROR, e.str(),
-                         this->GetBacktrace());
-      } break;
-    }
+    std::ostringstream e;
+    e << "Target \"" << this->GetName() << "\" links to item \"" << item
+      << "\" which has leading or trailing whitespace.  "
+      << "This is now an error according to policy CMP0004.";
+    cm->IssueMessage(MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
   }
   return lib;
 }

+ 1 - 1
Source/cmPolicies.h

@@ -27,7 +27,7 @@ class cmMakefile;
     2, 6, 0, NEW)                                                             \
   SELECT(POLICY, CMP0004,                                                     \
          "Libraries linked may not have leading or trailing whitespace.", 2,  \
-         6, 0, WARN)                                                          \
+         6, 0, NEW)                                                           \
   SELECT(POLICY, CMP0005,                                                     \
          "Preprocessor definition values are now escaped automatically.", 2,  \
          6, 0, WARN)                                                          \

+ 0 - 1
Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt

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

+ 0 - 2
Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt

@@ -1,2 +0,0 @@
-  Target "bat" links to item " bar " which has leading or trailing
-  whitespace.  This is now an error according to policy CMP0004.

+ 0 - 18
Tests/RunCMake/CMP0004/CMP0004-OLD.cmake

@@ -1,18 +0,0 @@
-cmake_policy(SET CMP0004 OLD)
-
-add_library(foo SHARED empty.cpp)
-add_library(bar SHARED empty.cpp)
-add_library(bing SHARED empty.cpp)
-add_library(bung SHARED empty.cpp)
-
-cmake_policy(SET CMP0004 NEW)
-
-add_library(bat SHARED empty.cpp)
-
-target_link_libraries(foo "$<1: bar >")
-target_link_libraries(bing "$<$<NOT:$<TARGET_POLICY:CMP0004>>: bar >")
-target_link_libraries(bung "$<$<TARGET_POLICY:CMP0004>: bar >")
-
-# The line below causes the error because the policy is NEW when bat
-# is created.
-target_link_libraries(bat "$<1: bar >")

+ 0 - 1
Tests/RunCMake/CMP0004/RunCMakeTest.cmake

@@ -1,5 +1,4 @@
 include(RunCMake)
 
-run_cmake(CMP0004-OLD)
 run_cmake(CMP0004-NEW)
 run_cmake(CMP0004-policy-genex)