Selaa lähdekoodia

CMP0035: Remove support for OLD variable_requires command

Brad King 11 kuukautta sitten
vanhempi
sitoutus
5b255fe7da

+ 4 - 3
Help/policy/CMP0035.rst

@@ -1,12 +1,13 @@
 CMP0035
 -------
 
+.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
+.. include:: REMOVED_PROLOGUE.txt
+
 The :command:`variable_requires` command should not be called.
 
 This command was introduced in November 2001 to perform some conditional
 logic.  It has long been replaced by the :command:`if` command.
 
 .. |disallowed_version| replace:: 3.0
-.. include:: DISALLOWED_COMMAND.txt
-
-.. include:: DEPRECATED.txt
+.. include:: REMOVED_COMMAND.txt

+ 0 - 2
Source/CMakeLists.txt

@@ -752,8 +752,6 @@ add_library(
   cmTryRunCommand.h
   cmUnsetCommand.cxx
   cmUnsetCommand.h
-  cmVariableRequiresCommand.cxx
-  cmVariableRequiresCommand.h
   cmVariableWatchCommand.cxx
   cmVariableWatchCommand.h
   cmWhileCommand.cxx

+ 3 - 4
Source/cmCommands.cxx

@@ -109,7 +109,6 @@
 #  include "cmRemoveDefinitionsCommand.h"
 #  include "cmSourceGroupCommand.h"
 #  include "cmTargetLinkDirectoriesCommand.h"
-#  include "cmVariableRequiresCommand.h"
 #  include "cmVariableWatchCommand.h"
 #  include "cmWriteFileCommand.h"
 #endif
@@ -312,9 +311,9 @@ void GetProjectCommands(cmState* state)
   state->AddRemovedCommand(
     "utility_source",
     "The utility_source command has been removed; see CMP0034.");
-  state->AddDisallowedCommand(
-    "variable_requires", cmVariableRequiresCommand, cmPolicies::CMP0035,
-    "The variable_requires command should not be called; see CMP0035.");
+  state->AddRemovedCommand(
+    "variable_requires",
+    "The variable_requires command has been removed; see CMP0035.");
 #endif
 }
 

+ 1 - 2
Source/cmPolicies.h

@@ -111,8 +111,7 @@ class cmMakefile;
   SELECT(POLICY, CMP0034, "The utility_source command should not be called.", \
          3, 0, 0, NEW)                                                        \
   SELECT(POLICY, CMP0035,                                                     \
-         "The variable_requires command should not be called.", 3, 0, 0,      \
-         WARN)                                                                \
+         "The variable_requires command should not be called.", 3, 0, 0, NEW) \
   SELECT(POLICY, CMP0036, "The build_name command should not be called.", 3,  \
          0, 0, WARN)                                                          \
   SELECT(POLICY, CMP0037,                                                     \

+ 0 - 64
Source/cmVariableRequiresCommand.cxx

@@ -1,64 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
-   file Copyright.txt or https://cmake.org/licensing for details.  */
-#include "cmVariableRequiresCommand.h"
-
-#include "cmExecutionStatus.h"
-#include "cmMakefile.h"
-#include "cmState.h"
-#include "cmStringAlgorithms.h"
-#include "cmSystemTools.h"
-#include "cmValue.h"
-
-// cmLibraryCommand
-bool cmVariableRequiresCommand(std::vector<std::string> const& args,
-                               cmExecutionStatus& status)
-{
-  if (args.size() < 3) {
-    status.SetError("called with incorrect number of arguments");
-    return false;
-  }
-
-  std::string const& testVariable = args[0];
-  if (!status.GetMakefile().IsOn(testVariable)) {
-    return true;
-  }
-  std::string const& resultVariable = args[1];
-  bool requirementsMet = true;
-  std::string notSet;
-  bool hasAdvanced = false;
-  cmState* state = status.GetMakefile().GetState();
-  for (unsigned int i = 2; i < args.size(); ++i) {
-    if (!status.GetMakefile().IsOn(args[i])) {
-      requirementsMet = false;
-      notSet += args[i];
-      notSet += "\n";
-      if (state->GetCacheEntryValue(args[i]) &&
-          state->GetCacheEntryPropertyAsBool(args[i], "ADVANCED")) {
-        hasAdvanced = true;
-      }
-    }
-  }
-  cmValue reqVar = status.GetMakefile().GetDefinition(resultVariable);
-  // if reqVar is unset, then set it to requirementsMet
-  // if reqVar is set to true, but requirementsMet is false , then
-  // set reqVar to false.
-  if (!reqVar || (!requirementsMet && status.GetMakefile().IsOn(*reqVar))) {
-    status.GetMakefile().AddDefinitionBool(resultVariable, requirementsMet);
-  }
-
-  if (!requirementsMet) {
-    std::string message =
-      cmStrCat("Variable assertion failed:\n", testVariable,
-               " Requires that the following unset variables are set:\n",
-               notSet, "\nPlease set them, or set ", testVariable,
-               " to false, and re-configure.\n");
-    if (hasAdvanced) {
-      message +=
-        "One or more of the required variables is advanced."
-        "  To set the variable, you must turn on advanced mode in cmake.";
-    }
-    cmSystemTools::Error(message);
-  }
-
-  return true;
-}

+ 0 - 13
Source/cmVariableRequiresCommand.h

@@ -1,13 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
-   file Copyright.txt or https://cmake.org/licensing for details.  */
-#pragma once
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-#include <string>
-#include <vector>
-
-class cmExecutionStatus;
-
-bool cmVariableRequiresCommand(std::vector<std::string> const& args,
-                               cmExecutionStatus& status);

+ 1 - 8
Tests/Complex/Executable/complex.cxx

@@ -243,7 +243,7 @@ int main()
 #endif
 
   // ----------------------------------------------------------------------
-  // Test SET, VARIABLE_REQUIRES
+  // Test SET
 
 #ifdef SHOULD_NOT_BE_DEFINED
   cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
@@ -269,13 +269,6 @@ int main()
   cmPassed("ONE_VAR_AND_INDENTED is defined.");
 #endif
 
-#ifndef ONE_VAR_IS_DEFINED
-  cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
-           "ONE_VAR_IS_DEFINED is not defined.");
-#else
-  cmPassed("ONE_VAR_IS_DEFINED is defined.");
-#endif
-
 #ifdef ZERO_VAR
   cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
 #else

+ 0 - 9
Tests/Complex/VarTests.cmake

@@ -16,15 +16,6 @@ set(ONE_VAR_AND_INDENTED 1)
 set(ONE_VAR2 1)
 set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
 
-#
-# Test VARIABLE_REQUIRES
-#
-block(SCOPE_FOR POLICIES)
-cmake_policy(VERSION 2.8.12) # old enough to not set CMP0035
-variable_requires(ONE_VAR
-                  ONE_VAR_IS_DEFINED ONE_VAR)
-endblock()
-
 #
 # Test various IF/ELSE combinations
 #

+ 1 - 2
Tests/Complex/cmTestConfigure.h.in

@@ -1,8 +1,7 @@
-// Test SET, VARIABLE_REQUIRES
+// Test SET
 
 #cmakedefine ONE_VAR
 #  cmakedefine ONE_VAR_AND_INDENTED
-#cmakedefine ONE_VAR_IS_DEFINED
 #cmakedefine ZERO_VAR
 #  cmakedefine ZERO_VAR_AND_INDENTED
 

+ 1 - 8
Tests/ComplexOneConfig/Executable/complex.cxx

@@ -243,7 +243,7 @@ int main()
 #endif
 
   // ----------------------------------------------------------------------
-  // Test SET, VARIABLE_REQUIRES
+  // Test SET
 
 #ifdef SHOULD_NOT_BE_DEFINED
   cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
@@ -269,13 +269,6 @@ int main()
   cmPassed("ONE_VAR_AND_INDENTED is defined.");
 #endif
 
-#ifndef ONE_VAR_IS_DEFINED
-  cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
-           "ONE_VAR_IS_DEFINED is not defined.");
-#else
-  cmPassed("ONE_VAR_IS_DEFINED is defined.");
-#endif
-
 #ifdef ZERO_VAR
   cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
 #else

+ 0 - 9
Tests/ComplexOneConfig/VarTests.cmake

@@ -16,15 +16,6 @@ set(ONE_VAR_AND_INDENTED 1)
 set(ONE_VAR2 1)
 set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
 
-#
-# Test VARIABLE_REQUIRES
-#
-block(SCOPE_FOR POLICIES)
-cmake_policy(VERSION 2.8.12) # old enough to not set CMP0035
-variable_requires(ONE_VAR
-                  ONE_VAR_IS_DEFINED ONE_VAR)
-endblock()
-
 #
 # Test various IF/ELSE combinations
 #

+ 1 - 2
Tests/ComplexOneConfig/cmTestConfigure.h.in

@@ -1,8 +1,7 @@
-// Test SET, VARIABLE_REQUIRES
+// Test SET
 
 #cmakedefine ONE_VAR
 #  cmakedefine ONE_VAR_AND_INDENTED
-#cmakedefine ONE_VAR_IS_DEFINED
 #cmakedefine ZERO_VAR
 #  cmakedefine ZERO_VAR_AND_INDENTED
 

+ 2 - 2
Tests/RunCMake/DisallowedCommands/CMP0035-NEW-stderr.txt

@@ -1,4 +1,4 @@
-CMake Error at CMP0035-NEW.cmake:2 \(variable_requires\):
-  The variable_requires command should not be called; see CMP0035.
+CMake Error at CMP0035-NEW.cmake:1 \(variable_requires\):
+  The variable_requires command has been removed; see CMP0035.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

+ 0 - 1
Tests/RunCMake/DisallowedCommands/CMP0035-NEW.cmake

@@ -1,2 +1 @@
-cmake_policy(SET CMP0035 NEW)
 variable_requires()

+ 0 - 1
Tests/RunCMake/DisallowedCommands/CMP0035-OLD-result.txt

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

+ 0 - 4
Tests/RunCMake/DisallowedCommands/CMP0035-OLD-stderr.txt

@@ -1,4 +0,0 @@
-CMake Error at CMP0035-OLD.cmake:2 \(variable_requires\):
-  variable_requires called with incorrect number of arguments
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)

+ 0 - 2
Tests/RunCMake/DisallowedCommands/CMP0035-OLD.cmake

@@ -1,2 +0,0 @@
-cmake_policy(SET CMP0035 OLD)
-variable_requires()

+ 0 - 1
Tests/RunCMake/DisallowedCommands/CMP0035-WARN-result.txt

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

+ 0 - 12
Tests/RunCMake/DisallowedCommands/CMP0035-WARN-stderr.txt

@@ -1,12 +0,0 @@
-CMake Warning \(dev\) at CMP0035-WARN.cmake:1 \(variable_requires\):
-  Policy CMP0035 is not set: The variable_requires command should not be
-  called.  Run "cmake --help-policy CMP0035" for policy details.  Use the
-  cmake_policy command to set the policy and suppress this warning.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
-This warning is for project developers.  Use -Wno-dev to suppress it.
-
-CMake Error at CMP0035-WARN.cmake:1 \(variable_requires\):
-  variable_requires called with incorrect number of arguments
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)

+ 0 - 1
Tests/RunCMake/DisallowedCommands/CMP0035-WARN.cmake

@@ -1 +0,0 @@
-variable_requires()

+ 1 - 1
Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake

@@ -7,6 +7,7 @@ foreach(p
     CMP0032
     CMP0033
     CMP0034
+    CMP0035
     )
   run_cmake(${p}-NEW)
 endforeach()
@@ -14,7 +15,6 @@ endforeach()
 return()
 
 foreach(p
-    CMP0035
     CMP0036
     )
   run_cmake(${p}-WARN)