浏览代码

CMP0007: Remove support for OLD behavior

Brad King 11 月之前
父节点
当前提交
d77a7e8d1c

+ 5 - 4
Help/policy/CMP0007.rst

@@ -1,6 +1,9 @@
 CMP0007
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 list command no longer ignores empty elements.
 
 This policy determines whether the list command will ignore empty
@@ -11,7 +14,5 @@ elements.  The ``NEW`` behavior for this policy is to correctly count
 empty elements in a list.
 
 .. |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

+ 0 - 5
Modules/CMakeIOSInstallCombined.cmake

@@ -60,9 +60,6 @@ endfunction()
 
 # Get architectures of given SDK (iphonesimulator/iphoneos)
 function(_ios_install_combined_get_valid_archs sdk resultvar)
-  cmake_policy(PUSH)
-  cmake_policy(SET CMP0007 NEW)
-
   if("${resultvar}" STREQUAL "")
     message(FATAL_ERROR "`resultvar` is empty")
   endif()
@@ -77,8 +74,6 @@ function(_ios_install_combined_get_valid_archs sdk resultvar)
   _ios_install_combined_message("Architectures (${sdk}): ${printable}")
 
   set("${resultvar}" "${valid_archs}" PARENT_SCOPE)
-
-  cmake_policy(POP)
 endfunction()
 
 # Make both arch lists a disjoint set by preferring the current SDK

+ 0 - 4
Modules/FindCUDA/run_nvcc.cmake

@@ -50,8 +50,6 @@
 # generated_cubin_file:STRING=<> File to generate.  This argument must be passed
 #                                                   in if build_cubin is true.
 
-cmake_policy(PUSH)
-cmake_policy(SET CMP0007 NEW)
 if(NOT generated_file)
   message(FATAL_ERROR "You must specify generated_file on the command line")
 endif()
@@ -302,5 +300,3 @@ if( build_cubin )
     )
 
 endif()
-
-cmake_policy(POP)

+ 0 - 3
Modules/FindEnvModules.cmake

@@ -268,7 +268,6 @@ endfunction()
 
 #------------------------------------------------------------------------------
 function(env_module_list out_var)
-  cmake_policy(SET CMP0007 NEW)
   env_module(COMMAND -t list OUTPUT_VARIABLE tmp_out)
 
   # Convert output into a CMake list
@@ -286,8 +285,6 @@ endfunction()
 
 #------------------------------------------------------------------------------
 function(env_module_avail)
-  cmake_policy(SET CMP0007 NEW)
-
   if(ARGC EQUAL 1)
     set(mod_prefix)
     set(out_var ${ARGV0})

+ 0 - 2
Modules/FindPython/Support.cmake

@@ -10,8 +10,6 @@
 #
 
 cmake_policy(PUSH)
-# list supports empty elements
-cmake_policy (SET CMP0007 NEW)
 # numbers and boolean constants
 cmake_policy (SET CMP0012 NEW)
 # IN_LIST operator

+ 0 - 6
Modules/FortranCInterface.cmake

@@ -195,9 +195,6 @@ if(FortranCInterface_SOURCE_DIR)
   return()
 endif()
 
-cmake_policy(PUSH)
-cmake_policy(SET CMP0007 NEW)
-
 #-----------------------------------------------------------------------------
 # Verify that C and Fortran are available.
 foreach(lang C Fortran)
@@ -402,6 +399,3 @@ function(FortranCInterface_VERIFY)
       "The output was:\n  ${_output}")
   endif()
 endfunction()
-
-# Restore including context policies.
-cmake_policy(POP)

+ 0 - 23
Source/cmListCommand.cxx

@@ -89,29 +89,6 @@ cm::optional<cmList> GetList(const std::string& var,
   if (!cm::contains(*list, std::string())) {
     return list;
   }
-  // if we have empty elements we need to check policy CMP0007
-  switch (makefile.GetPolicyStatus(cmPolicies::CMP0007)) {
-    case cmPolicies::WARN: {
-      // Default is to warn and use old behavior
-      // OLD behavior is to allow compatibility, so recall
-      // ExpandListArgument without the true which will remove
-      // empty values
-      list->assign(listString);
-      std::string warn =
-        cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0007),
-                 " List has value = [", listString, "].");
-      makefile.IssueMessage(MessageType::AUTHOR_WARNING, warn);
-      return list;
-    }
-    case cmPolicies::OLD:
-      // OLD behavior is to allow compatibility, so recall
-      // ExpandListArgument without the true which will remove
-      // empty values
-      list->assign(listString);
-      return list;
-    case cmPolicies::NEW:
-      return list;
-  }
   return list;
 }
 

+ 1 - 1
Source/cmPolicies.h

@@ -35,7 +35,7 @@ class cmMakefile;
          "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.",   \
          2, 6, 0, NEW)                                                        \
   SELECT(POLICY, CMP0007, "list command no longer ignores empty elements.",   \
-         2, 6, 0, WARN)                                                       \
+         2, 6, 0, NEW)                                                        \
   SELECT(                                                                     \
     POLICY, CMP0008,                                                          \
     "Libraries linked by full-path must have a valid library file name.", 2,  \

+ 7 - 30
Tests/CMakeTests/ListTest.cmake.in

@@ -152,33 +152,10 @@ foreach(cmd IN ITEMS Find Get Insert Length Remove_At)
   check_cmake_test_single(List "${cmd}-List-Only" "${_test_file_name}")
 endforeach()
 
-set(thelist "" NEW OLD)
-
-foreach (_pol ${thelist})
-    cmake_policy(SET CMP0007 ${_pol})
-    list(GET thelist 1 thevalue)
-    if (NOT thevalue STREQUAL _pol)
-        message(SEND_ERROR "returned element '${thevalue}', but expected '${_pol}'")
-    endif()
-endforeach (_pol)
-
-block(SCOPE_FOR POLICIES)
-  cmake_policy(SET CMP0007 NEW)
-  set(result andy bill brad ken bob)
-  list(INSERT result 1 "")
-  TEST("INSERT result 1 \"\"" "andy;;bill;brad;ken;bob")
-  list(INSERT result 4 ";")
-  TEST("INSERT result 1 ;" "andy;;bill;brad;;;ken;bob")
-  list(INSERT result 0 "x")
-  TEST("INSERT result 1 x" "x;andy;;bill;brad;;;ken;bob")
-endblock()
-block(SCOPE_FOR POLICIES)
-  cmake_policy(SET CMP0007 OLD)
-  set(result andy bill brad ken bob)
-  list(INSERT result 1 "")
-  TEST("INSERT result 1 \"\"" "andy;;bill;brad;ken;bob")
-  list(INSERT result 4 ";")
-  TEST("INSERT result 1 ;" "andy;bill;brad;ken;;;bob")
-  list(INSERT result 0 "x")
-  TEST("INSERT result 1 x" "x;andy;bill;brad;ken;bob")
-endblock()
+set(result andy bill brad ken bob)
+list(INSERT result 1 "")
+TEST("INSERT result 1 \"\"" "andy;;bill;brad;ken;bob")
+list(INSERT result 4 ";")
+TEST("INSERT result 1 ;" "andy;;bill;brad;;;ken;bob")
+list(INSERT result 0 "x")
+TEST("INSERT result 1 x" "x;andy;;bill;brad;;;ken;bob")

+ 16 - 45
Tests/RunCMake/GenEx-LIST/INSERT.cmake.in

@@ -46,52 +46,23 @@ if (NOT output STREQUAL listvar)
   list (APPEND errors "returns bad value: ${output}")
 endif()
 
-block(SCOPE_FOR POLICIES)
-  cmake_policy(SET CMP0007 NEW)
-
-  set(listvar "0;1;2;3;4")
-  list(INSERT listvar 1 "")
-  set (output "$<LIST:INSERT,0;1;2;3;4,1,>")
-  if (NOT output STREQUAL listvar)
-    list (APPEND errors "returns bad value: ${output}")
-  endif()
-
-  list(INSERT listvar 4 ";")
-  set (output "$<LIST:INSERT,0;;1;2;3;4,4,;>")
-  if (NOT output STREQUAL listvar)
-    list (APPEND errors "returns bad value: ${output}")
-  endif()
-
-  list(INSERT listvar 0 "x")
-  set (output "$<LIST:INSERT,0;;1;2;;;3;4,0,x>")
-  if (NOT output STREQUAL listvar)
-    list (APPEND errors "returns bad value: ${output}")
-  endif()
-endblock()
-block(SCOPE_FOR POLICIES)
-  set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "")
-  cmake_policy(SET CMP0007 OLD)
-
-  set(listvar "0;1;2;3;4")
-  list(INSERT listvar 1 "")
-  set (output "$<LIST:INSERT,0;1;2;3;4,1,>")
-  if (NOT output STREQUAL listvar)
-    list (APPEND errors "returns bad value: ${output}")
-  endif()
-
-  list(INSERT listvar 4 ";")
-  set (output "$<LIST:INSERT,0;1;2;3;4,4,;>")
-  if (NOT output STREQUAL listvar)
-    list (APPEND errors "returns bad value: ${output}")
-  endif()
+set(listvar "0;1;2;3;4")
+list(INSERT listvar 1 "")
+set (output "$<LIST:INSERT,0;1;2;3;4,1,>")
+if (NOT output STREQUAL listvar)
+  list (APPEND errors "returns bad value: ${output}")
+endif()
 
-  list(INSERT listvar 0 "x")
-  set (output "$<LIST:INSERT,0;1;2;3;4,0,x>")
-  if (NOT output STREQUAL listvar)
-    list (APPEND errors "returns bad value: ${output}")
-  endif()
+list(INSERT listvar 4 ";")
+set (output "$<LIST:INSERT,0;;1;2;3;4,4,;>")
+if (NOT output STREQUAL listvar)
+  list (APPEND errors "returns bad value: ${output}")
+endif()
 
-  unset(CMAKE_WARN_DEPRECATED CACHE)
-endblock()
+list(INSERT listvar 0 "x")
+set (output "$<LIST:INSERT,0;;1;2;;;3;4,0,x>")
+if (NOT output STREQUAL listvar)
+  list (APPEND errors "returns bad value: ${output}")
+endif()
 
 check_errors("LIST:INSERT..." ${errors})

+ 0 - 2
Tests/RunCMake/function/CMAKE_CURRENT_FUNCTION.cmake

@@ -80,8 +80,6 @@ endfunction()
 
 calling_macro()
 
-cmake_policy(SET CMP0007 NEW)
-
 # ATTENTION `CMAKE_CURRENT_LIST_LINE` can't be used in `math()'
 function(print_self)
     file(STRINGS "${CMAKE_CURRENT_FUNCTION_LIST_FILE}" _lines)

+ 0 - 18
Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt

@@ -1,18 +0,0 @@
-^CMake Deprecation Warning at GET-CMP0007-WARN\.cmake:1 \(cmake_policy\):
-  Compatibility with CMake < 3\.10 will be removed from a future version of
-  CMake\.
-
-  Update the VERSION argument <min> value\.  Or, use the <min>\.\.\.<max> syntax
-  to tell CMake that the project requires at least <min> but has been updated
-  to work with policies introduced by <max> or earlier\.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
-+
-CMake Warning \(dev\) at GET-CMP0007-WARN\.cmake:4 \(list\):
-  Policy CMP0007 is not set: list command no longer ignores empty elements.
-  Run "cmake --help-policy CMP0007" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.  List has value =
-  \[;NEW;OLD\].
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
-This warning is for project developers.  Use -Wno-dev to suppress it.$

+ 0 - 7
Tests/RunCMake/list/GET-CMP0007-WARN.cmake

@@ -1,7 +0,0 @@
-cmake_policy(VERSION 2.4)
-set(thelist "" NEW OLD)
-
-list(GET thelist 1 thevalue)
-if (NOT thevalue STREQUAL "OLD")
-    message(SEND_ERROR "returned element '${thevalue}', but expected 'OLD'")
-endif()

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

@@ -7,7 +7,6 @@ run_cmake(EmptyInsert-1)
 
 run_cmake(NoArguments)
 run_cmake(InvalidSubcommand)
-run_cmake(GET-CMP0007-WARN)
 
 run_cmake(FILTER-REGEX-InvalidRegex)
 run_cmake(GET-InvalidIndex)