Browse Source

CMP0041: Remove support for OLD behavior

Brad King 1 năm trước cách đây
mục cha
commit
7193c2d23d

+ 5 - 4
Help/policy/CMP0041.rst

@@ -1,6 +1,9 @@
 CMP0041
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 Error on relative include with generator expression.
 
 Diagnostics in CMake 2.8.12 and lower silently ignored an entry in the
@@ -21,7 +24,5 @@ an error if a generator expression appears in another location and the path is
 relative.
 
 .. |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

+ 7 - 19
Source/cmExportInstallFileGenerator.cxx

@@ -439,24 +439,9 @@ bool cmExportInstallFileGenerator::CheckInterfaceDirs(
     if (cmHasPrefix(li, this->GetImportPrefixWithSlash())) {
       continue;
     }
-    MessageType messageType = MessageType::FATAL_ERROR;
     std::ostringstream e;
     if (genexPos != std::string::npos) {
-      if (prop == "INTERFACE_INCLUDE_DIRECTORIES") {
-        switch (target->GetPolicyStatusCMP0041()) {
-          case cmPolicies::WARN:
-            messageType = MessageType::WARNING;
-            e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0041) << "\n";
-            break;
-          case cmPolicies::OLD:
-            continue;
-          case cmPolicies::NEW:
-            hadFatalError = true;
-            break; // Issue fatal message.
-        }
-      } else {
-        hadFatalError = true;
-      }
+      hadFatalError = true;
     }
     if (!cmSystemTools::FileIsFullPath(li)) {
       /* clang-format off */
@@ -464,7 +449,8 @@ bool cmExportInstallFileGenerator::CheckInterfaceDirs(
            " property contains relative path:\n"
            "  \"" << li << "\"";
       /* clang-format on */
-      target->GetLocalGenerator()->IssueMessage(messageType, e.str());
+      target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
+                                                e.str());
     }
     bool inBinary = isSubDirectory(li, topBinaryDir);
     bool inSource = isSubDirectory(li, topSourceDir);
@@ -516,7 +502,8 @@ bool cmExportInstallFileGenerator::CheckInterfaceDirs(
            " property contains path:\n"
            "  \"" << li << "\"\nwhich is prefixed in the build directory.";
       /* clang-format on */
-      target->GetLocalGenerator()->IssueMessage(messageType, e.str());
+      target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
+                                                e.str());
     }
     if (!inSourceBuild) {
       if (inSource) {
@@ -524,7 +511,8 @@ bool cmExportInstallFileGenerator::CheckInterfaceDirs(
           << " property contains path:\n"
              "  \""
           << li << "\"\nwhich is prefixed in the source directory.";
-        target->GetLocalGenerator()->IssueMessage(messageType, e.str());
+        target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
+                                                  e.str());
       }
     }
   }

+ 1 - 1
Source/cmPolicies.h

@@ -128,7 +128,7 @@ class cmMakefile;
          3, 0, 0, NEW)                                                        \
   SELECT(POLICY, CMP0041,                                                     \
          "Error on relative include with generator expression.", 3, 0, 0,     \
-         WARN)                                                                \
+         NEW)                                                                 \
   SELECT(POLICY, CMP0042, "MACOSX_RPATH is enabled by default.", 3, 0, 0,     \
          WARN)                                                                \
   SELECT(POLICY, CMP0043, "Ignore COMPILE_DEFINITIONS_<Config> properties.",  \

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

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

@@ -1,12 +0,0 @@
-
-cmake_policy(SET CMP0041 OLD)
-
-add_library(foo empty.cpp)
-set_property(TARGET foo
-  PROPERTY INTERFACE_INCLUDE_DIRECTORIES
-    include/$<TARGET_PROPERTY:NAME>
-    ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME>
-    ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME>
-)
-install(TARGETS foo EXPORT FooExport DESTINATION lib)
-install(EXPORT FooExport DESTINATION lib/cmake)

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

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

+ 0 - 32
Tests/RunCMake/CMP0041/CMP0041-WARN-stderr.txt

@@ -1,32 +0,0 @@
-CMake Warning in CMakeLists.txt:
-  Policy CMP0041 is not set: Error on relative include with generator
-  expression.  Run "cmake --help-policy CMP0041" for policy details.  Use the
-  cmake_policy command to set the policy and suppress this warning.
-
-  Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains relative path:
-
-    "include/\$<TARGET_PROPERTY:NAME>"
-
-
-CMake Warning in CMakeLists.txt:
-  Policy CMP0041 is not set: Error on relative include with generator
-  expression.  Run "cmake --help-policy CMP0041" for policy details.  Use the
-  cmake_policy command to set the policy and suppress this warning.
-
-  Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path:
-
-    ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>"
-
-  which is prefixed in the source directory.
-
-
-CMake Warning in CMakeLists.txt:
-  Policy CMP0041 is not set: Error on relative include with generator
-  expression.  Run "cmake --help-policy CMP0041" for policy details.  Use the
-  cmake_policy command to set the policy and suppress this warning.
-
-  Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path:
-
-    ".*/Tests/RunCMake/CMP0041/CMP0041-WARN-build/include/\$<TARGET_PROPERTY:NAME>"
-
-  which is prefixed in the build directory.

+ 0 - 10
Tests/RunCMake/CMP0041/CMP0041-WARN.cmake

@@ -1,10 +0,0 @@
-
-add_library(foo empty.cpp)
-set_property(TARGET foo
-  PROPERTY INTERFACE_INCLUDE_DIRECTORIES
-    include/$<TARGET_PROPERTY:NAME>
-    ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME>
-    ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME>
-)
-install(TARGETS foo EXPORT FooExport DESTINATION lib)
-install(EXPORT FooExport DESTINATION lib/cmake)

+ 0 - 10
Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt

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

@@ -1,11 +0,0 @@
-
-cmake_policy(SET CMP0041 OLD)
-
-add_library(foo empty.cpp)
-target_include_directories(foo INTERFACE
-  include/$<TARGET_PROPERTY:NAME>
-  ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME>
-  ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME>
-)
-install(TARGETS foo EXPORT FooExport DESTINATION lib)
-install(EXPORT FooExport DESTINATION lib/cmake)

+ 0 - 1
Tests/RunCMake/CMP0041/CMP0041-tid-WARN-result.txt

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

+ 0 - 34
Tests/RunCMake/CMP0041/CMP0041-tid-WARN-stderr.txt

@@ -1,34 +0,0 @@
-CMake Warning in CMakeLists.txt:
-  Policy CMP0041 is not set: Error on relative include with generator
-  expression.  Run "cmake --help-policy CMP0041" for policy details.  Use the
-  cmake_policy command to set the policy and suppress this warning.
-
-  Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path:
-
-    ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>"
-
-  which is prefixed in the source directory.
-
-
-CMake Warning in CMakeLists.txt:
-  Policy CMP0041 is not set: Error on relative include with generator
-  expression.  Run "cmake --help-policy CMP0041" for policy details.  Use the
-  cmake_policy command to set the policy and suppress this warning.
-
-  Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path:
-
-    ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>"
-
-  which is prefixed in the source directory.
-
-
-CMake Warning in CMakeLists.txt:
-  Policy CMP0041 is not set: Error on relative include with generator
-  expression.  Run "cmake --help-policy CMP0041" for policy details.  Use the
-  cmake_policy command to set the policy and suppress this warning.
-
-  Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path:
-
-    ".*/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-build/include/\$<TARGET_PROPERTY:NAME>"
-
-  which is prefixed in the build directory.

+ 0 - 9
Tests/RunCMake/CMP0041/CMP0041-tid-WARN.cmake

@@ -1,9 +0,0 @@
-
-add_library(foo empty.cpp)
-target_include_directories(foo INTERFACE
-  include/$<TARGET_PROPERTY:NAME>
-  ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME>
-  ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME>
-)
-install(TARGETS foo EXPORT FooExport DESTINATION lib)
-install(EXPORT FooExport DESTINATION lib/cmake)

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

@@ -1,16 +1,11 @@
 include(RunCMake)
-set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
 
 # Protect tests from running inside the default install prefix.
 set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/NotDefaultPrefix")
 
-run_cmake(CMP0041-OLD)
 run_cmake(CMP0041-NEW)
-run_cmake(CMP0041-WARN)
 
 # Protect tests from running inside the default install prefix.
 set(RunCMake_TEST_OPTIONS "--install-prefix ${RunCMake_BINARY_DIR}/NotDefaultPrefix")
 
-run_cmake(CMP0041-tid-OLD)
 run_cmake(CMP0041-tid-NEW)
-run_cmake(CMP0041-tid-WARN)