Procházet zdrojové kódy

CMP0019: Remove support for OLD behavior

Brad King před 1 rokem
rodič
revize
092d6de4be

+ 5 - 4
Help/policy/CMP0019.rst

@@ -1,6 +1,9 @@
 CMP0019
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 Do not re-expand variables in include and link information.
 
 CMake 2.8.10 and lower re-evaluated values given to the
@@ -16,7 +19,5 @@ strict compatibility.  The ``NEW`` behavior for this policy is to leave
 the values untouched.
 
 .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.11
-.. |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

+ 0 - 91
Source/cmMakefile.cxx

@@ -1007,9 +1007,6 @@ void cmMakefile::GeneratorAction::operator()(cmLocalGenerator& lg,
 
 void cmMakefile::DoGenerate(cmLocalGenerator& lg)
 {
-  // do all the variable expansions here
-  this->ExpandVariablesCMP0019();
-
   // give all the commands a chance to do something
   // after the file has been parsed before generation
   for (auto& action : this->GeneratorActions) {
@@ -2303,94 +2300,6 @@ cmSourceGroup* cmMakefile::FindSourceGroup(
 }
 #endif
 
-static bool mightExpandVariablesCMP0019(const char* s)
-{
-  return s && *s && strstr(s, "${") && strchr(s, '}');
-}
-
-void cmMakefile::ExpandVariablesCMP0019()
-{
-  // Drop this ancient compatibility behavior with a policy.
-  cmPolicies::PolicyStatus pol = this->GetPolicyStatus(cmPolicies::CMP0019);
-  if (pol != cmPolicies::OLD && pol != cmPolicies::WARN) {
-    return;
-  }
-
-  std::string e;
-
-  cmValue includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
-  if (includeDirs && mightExpandVariablesCMP0019(includeDirs->c_str())) {
-    std::string dirs = *includeDirs;
-    this->ExpandVariablesInString(dirs, true, true);
-    if (pol == cmPolicies::WARN && dirs != *includeDirs) {
-      e = cmStrCat("Evaluated directory INCLUDE_DIRECTORIES\n  ", *includeDirs,
-                   "\nas\n  ", dirs, '\n');
-    }
-    this->SetProperty("INCLUDE_DIRECTORIES", dirs);
-  }
-
-  // Also for each target's INCLUDE_DIRECTORIES property:
-  for (auto& target : this->Targets) {
-    cmTarget& t = target.second;
-    if (t.GetType() == cmStateEnums::INTERFACE_LIBRARY ||
-        t.GetType() == cmStateEnums::GLOBAL_TARGET) {
-      continue;
-    }
-    includeDirs = t.GetProperty("INCLUDE_DIRECTORIES");
-    if (includeDirs && mightExpandVariablesCMP0019(includeDirs->c_str())) {
-      std::string dirs = *includeDirs;
-      this->ExpandVariablesInString(dirs, true, true);
-      if (pol == cmPolicies::WARN && dirs != *includeDirs) {
-        e += cmStrCat("Evaluated target ", t.GetName(),
-                      " INCLUDE_DIRECTORIES\n  ", *includeDirs, "\nas\n  ",
-                      dirs, '\n');
-      }
-      t.SetProperty("INCLUDE_DIRECTORIES", dirs);
-    }
-  }
-
-  if (cmValue linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
-    if (mightExpandVariablesCMP0019(linkDirsProp->c_str())) {
-      std::string d = *linkDirsProp;
-      const std::string orig = d;
-      this->ExpandVariablesInString(d, true, true);
-      if (pol == cmPolicies::WARN && d != orig) {
-        e += cmStrCat("Evaluated link directories\n  ", orig, "\nas\n  ", d,
-                      '\n');
-      }
-    }
-  }
-
-  if (cmValue linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
-    cmList linkLibs{ *linkLibsProp };
-
-    for (auto l = linkLibs.begin(); l != linkLibs.end(); ++l) {
-      std::string libName = *l;
-      if (libName == "optimized"_s || libName == "debug"_s) {
-        ++l;
-        libName = *l;
-      }
-      if (mightExpandVariablesCMP0019(libName.c_str())) {
-        const std::string orig = libName;
-        this->ExpandVariablesInString(libName, true, true);
-        if (pol == cmPolicies::WARN && libName != orig) {
-          e += cmStrCat("Evaluated link library\n  ", orig, "\nas\n  ",
-                        libName, '\n');
-        }
-      }
-    }
-  }
-
-  if (!e.empty()) {
-    auto m = cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0019),
-                      "\n"
-                      "The following variable evaluations were encountered:\n",
-                      e);
-    this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING, m,
-                                           this->Backtrace);
-  }
-}
-
 bool cmMakefile::IsOn(const std::string& name) const
 {
   return this->GetDefinition(name).IsOn();

+ 0 - 5
Source/cmMakefile.h

@@ -717,11 +717,6 @@ public:
    */
   void RemoveVariablesInString(std::string& source, bool atOnly = false) const;
 
-  /**
-   * Expand variables in the makefiles ivars such as link directories etc
-   */
-  void ExpandVariablesCMP0019();
-
   /**
    * Replace variables and #cmakedefine lines in the given string.
    * See cmConfigureFileCommand for details.

+ 1 - 1
Source/cmPolicies.h

@@ -69,7 +69,7 @@ class cmMakefile;
          "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", 2, 8, 9, NEW)  \
   SELECT(POLICY, CMP0019,                                                     \
          "Do not re-expand variables in include and link information.", 2, 8, \
-         11, WARN)                                                            \
+         11, NEW)                                                             \
   SELECT(POLICY, CMP0020,                                                     \
          "Automatically link Qt executables to qtmain target on Windows.", 2, \
          8, 11, WARN)                                                         \

+ 0 - 1
Tests/RunCMake/CMP0019/CMP0019-NEW.cmake

@@ -1,2 +1 @@
-cmake_policy(SET CMP0019 NEW)
 include(CMP0019-code.cmake)

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

@@ -1,10 +0,0 @@
-^CMake Deprecation Warning at CMP0019-OLD\.cmake:[0-9]+ \(cmake_policy\):
-  The OLD behavior for policy CMP0019 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:[0-9]+ \(include\)$

+ 0 - 2
Tests/RunCMake/CMP0019/CMP0019-OLD.cmake

@@ -1,2 +0,0 @@
-cmake_policy(SET CMP0019 OLD)
-include(CMP0019-code.cmake)

+ 0 - 40
Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt

@@ -1,40 +0,0 @@
-^CMake Warning \(dev\) in CMakeLists\.txt:
-  Policy CMP0019 is not set: Do not re-expand variables in include and link
-  information.  Run "cmake --help-policy CMP0019" for policy details.  Use
-  the cmake_policy command to set the policy and suppress this warning.
-
-  The following variable evaluations were encountered:
-
-  Evaluated directory INCLUDE_DIRECTORIES
-
-    /usr/include/\${VAR_INCLUDE};/usr/include/normal
-
-  as
-
-    /usr/include/VAL_INCLUDE;/usr/include/normal
-
-  Evaluated target some_target INCLUDE_DIRECTORIES
-
-    /usr/include/\${VAR_INCLUDE};/usr/include/normal
-
-  as
-
-    /usr/include/VAL_INCLUDE;/usr/include/normal
-
-  Evaluated link directories
-
-    /usr/lib/\${VAR_LINK_DIRS};/usr/lib/normal
-
-  as
-
-    /usr/lib/VAL_LINK_DIRS;/usr/lib/normal
-
-  Evaluated link library
-
-    \${VAR_LINK_LIBS}
-
-  as
-
-    VAL_LINK_LIBS
-
-This warning is for project developers.  Use -Wno-dev to suppress it.$

+ 0 - 1
Tests/RunCMake/CMP0019/CMP0019-WARN.cmake

@@ -1 +0,0 @@
-include(CMP0019-code.cmake)

+ 2 - 2
Tests/RunCMake/CMP0019/CMakeLists.txt

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

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

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