Browse Source

CMP0027: Remove support for OLD behavior

Brad King 11 months ago
parent
commit
5754c9f731

+ 5 - 4
Help/policy/CMP0027.rst

@@ -1,6 +1,9 @@
 CMP0027
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 Conditionally linked imported targets with missing include directories.
 
 CMake 2.8.11 introduced introduced the concept of
@@ -21,7 +24,5 @@ the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of a generator-expression
 conditionally linked ``IMPORTED`` target does not exist.
 
 .. |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

+ 12 - 28
Source/cmGeneratorTarget_IncludeDirectories.cxx

@@ -25,7 +25,6 @@
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
-#include "cmPolicies.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
@@ -149,37 +148,22 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt,
     cmLinkImplItem const& item = entry.LinkImplItem;
     std::string const& targetName = item.AsStr();
     bool const fromImported = item.Target && item.Target->IsImported();
-    bool const checkCMP0027 = item.CheckCMP0027;
 
     std::string usedIncludes;
     for (std::string& entryInclude : entry.Values) {
       if (fromImported && !cmSystemTools::FileExists(entryInclude)) {
-        std::ostringstream e;
-        MessageType messageType = MessageType::FATAL_ERROR;
-        if (checkCMP0027) {
-          switch (tgt->GetPolicyStatusCMP0027()) {
-            case cmPolicies::WARN:
-              e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n";
-              CM_FALLTHROUGH;
-            case cmPolicies::OLD:
-              messageType = MessageType::AUTHOR_WARNING;
-              break;
-            case cmPolicies::NEW:
-              break;
-          }
-        }
-        /* clang-format off */
-        e << "Imported target \"" << targetName << "\" includes "
-             "non-existent path\n  \"" << entryInclude << "\"\nin its "
-             "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
-             "* The path was deleted, renamed, or moved to another "
-             "location.\n"
-             "* An install or uninstall procedure did not complete "
-             "successfully.\n"
-             "* The installation package was faulty and references files it "
-             "does not provide.\n";
-        /* clang-format on */
-        tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
+        tgt->GetLocalGenerator()->IssueMessage(
+          MessageType::FATAL_ERROR,
+          cmStrCat(
+            "Imported target \"", targetName,
+            "\" includes non-existent path\n  \"", entryInclude,
+            "\"\nin its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons "
+            "include:\n"
+            "* The path was deleted, renamed, or moved to another location.\n"
+            "* An install or uninstall procedure did not complete "
+            "successfully.\n"
+            "* The installation package was faulty and references files it "
+            "does not provide.\n"));
         return;
       }
 

+ 4 - 5
Source/cmGeneratorTarget_Link.cxx

@@ -829,7 +829,7 @@ template <>
 inline cmLinkImplItem constructItem(cmGeneratorTarget* target,
                                     cmListFileBacktrace const& bt)
 {
-  return cmLinkImplItem(cmLinkItem(target, false, bt), false);
+  return cmLinkImplItem(cmLinkItem(target, false, bt));
 }
 
 template <>
@@ -1080,7 +1080,7 @@ void TransitiveLinkImpl::Follow(cmGeneratorTarget const* target)
 
     // Add the item itself, but at most once.
     if (this->Emitted.insert(item).second) {
-      this->Impl.Libraries.emplace_back(item, /* checkCMP0027= */ false);
+      this->Impl.Libraries.emplace_back(item);
     }
   }
 
@@ -1169,7 +1169,6 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
     std::string const& evaluated =
       cge->Evaluate(this->LocalGenerator, config, this, &dagChecker, nullptr,
                     this->LinkerLanguage);
-    bool const checkCMP0027 = evaluated != entry.Value;
     cmList llibs(evaluated);
     if (cge->GetHadHeadSensitiveCondition()) {
       impl.HadHeadSensitiveCondition = true;
@@ -1239,7 +1238,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
         if (depsForTarget != synthTargetsForConfig.end()) {
           for (auto const* depForTarget : depsForTarget->second) {
             cmLinkItem synthItem(depForTarget, item.Cross, item.Backtrace);
-            impl.Libraries.emplace_back(std::move(synthItem), false);
+            impl.Libraries.emplace_back(std::move(synthItem));
           }
         }
       } else {
@@ -1256,7 +1255,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
         }
       }
 
-      impl.Libraries.emplace_back(std::move(item), checkCMP0027);
+      impl.Libraries.emplace_back(std::move(item));
     }
 
     std::set<std::string> const& seenProps = cge->GetSeenTargetProperties();

+ 1 - 2
Source/cmLinkItem.cxx

@@ -71,9 +71,8 @@ std::ostream& operator<<(std::ostream& os, cmLinkItem const& item)
   return os << item.AsStr();
 }
 
-cmLinkImplItem::cmLinkImplItem(cmLinkItem item, bool checkCMP0027)
+cmLinkImplItem::cmLinkImplItem(cmLinkItem item)
   : cmLinkItem(std::move(item))
-  , CheckCMP0027(checkCMP0027)
 {
 }
 

+ 1 - 2
Source/cmLinkItem.h

@@ -51,8 +51,7 @@ class cmLinkImplItem : public cmLinkItem
 {
 public:
   cmLinkImplItem() = default;
-  cmLinkImplItem(cmLinkItem item, bool checkCMP0027);
-  bool CheckCMP0027 = false;
+  cmLinkImplItem(cmLinkItem item);
 };
 
 /** The link implementation specifies the direct library

+ 1 - 1
Source/cmPolicies.h

@@ -92,7 +92,7 @@ class cmMakefile;
   SELECT(POLICY, CMP0027,                                                     \
          "Conditionally linked imported targets with missing include "        \
          "directories.",                                                      \
-         3, 0, 0, WARN)                                                       \
+         3, 0, 0, NEW)                                                        \
   SELECT(POLICY, CMP0028,                                                     \
          "Double colon in target name means ALIAS or IMPORTED target.", 3, 0, \
          0, WARN)                                                             \

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

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

+ 0 - 13
Tests/RunCMake/CMP0027/CMP0027-OLD-stderr.txt

@@ -1,13 +0,0 @@
-CMake Warning \(dev\) in CMakeLists.txt:
-  Imported target "testTarget" includes non-existent path
-
-    "/does/not/exist"
-
-  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
-
-  \* The path was deleted, renamed, or moved to another location.
-
-  \* An install or uninstall procedure did not complete successfully.
-
-  \* The installation package was faulty and references files it does not
-  provide.

+ 0 - 10
Tests/RunCMake/CMP0027/CMP0027-OLD.cmake

@@ -1,10 +0,0 @@
-
-enable_language(CXX)
-
-cmake_policy(SET CMP0027 OLD)
-
-add_library(testTarget UNKNOWN IMPORTED)
-set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "/does/not/exist")
-
-add_library(userTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
-target_link_libraries(userTarget PRIVATE $<1:testTarget>)

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

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

+ 0 - 18
Tests/RunCMake/CMP0027/CMP0027-WARN-stderr.txt

@@ -1,18 +0,0 @@
-CMake Warning \(dev\) in CMakeLists.txt:
-  Policy CMP0027 is not set: Conditionally linked imported targets with
-  missing include directories.  Run "cmake --help-policy CMP0027" for policy
-  details.  Use the cmake_policy command to set the policy and suppress this
-  warning.
-
-  Imported target "testTarget" includes non-existent path
-
-    "/does/not/exist"
-
-  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
-
-  \* The path was deleted, renamed, or moved to another location.
-
-  \* An install or uninstall procedure did not complete successfully.
-
-  \* The installation package was faulty and references files it does not
-  provide.

+ 0 - 8
Tests/RunCMake/CMP0027/CMP0027-WARN.cmake

@@ -1,8 +0,0 @@
-
-enable_language(CXX)
-
-add_library(testTarget UNKNOWN IMPORTED)
-set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "/does/not/exist")
-
-add_library(userTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
-target_link_libraries(userTarget PRIVATE $<1:testTarget>)

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

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

+ 0 - 2
Tests/RunCMake/CMP0027/RunCMakeTest.cmake

@@ -1,5 +1,3 @@
 include(RunCMake)
 
 run_cmake(CMP0027-NEW)
-run_cmake(CMP0027-OLD)
-run_cmake(CMP0027-WARN)