CMP0064: Remove support for OLD behavior

This commit is contained in:
Brad King 2024-12-13 13:50:18 -05:00
parent d88047c329
commit d9dd38cccf
13 changed files with 7 additions and 73 deletions

View File

@ -1,6 +1,9 @@
CMP0064
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
.. versionadded:: 3.4
Recognize ``TEST`` as a operator for the :command:`if` command.
@ -12,7 +15,5 @@ The ``OLD`` behavior for this policy is to ignore the ``TEST`` operator.
The ``NEW`` behavior is to interpret the ``TEST`` operator.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.4
.. |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

View File

@ -218,7 +218,6 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
cmListFileBacktrace bt)
: Makefile(makefile)
, Backtrace(std::move(bt))
, Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064))
, Policy139Status(makefile.GetPolicyStatus(cmPolicies::CMP0139))
{
}
@ -426,26 +425,6 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
{
for (auto args = newArgs.make2ArgsIterator(); args.current != newArgs.end();
args.advance(newArgs)) {
auto policyCheck = [&, this](const cmPolicies::PolicyID id,
const cmPolicies::PolicyStatus status,
const cm::static_string_view kw) {
if (status == cmPolicies::WARN && this->IsKeyword(kw, *args.current)) {
std::ostringstream e;
e << cmPolicies::GetPolicyWarning(id) << "\n"
<< kw
<< " will be interpreted as an operator "
"when the policy is set to NEW. "
"Since the policy is not set the OLD behavior will be used.";
this->Makefile.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
}
};
// NOTE Checking policies for warnings are not require an access to the
// next arg. Check them first!
policyCheck(cmPolicies::CMP0064, this->Policy64Status, keyTEST);
// NOTE Fail fast: All the predicates below require the next arg to be
// valid
if (args.next == newArgs.end()) {
@ -533,10 +512,6 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
}
// does a test exist
else if (this->IsKeyword(keyTEST, *args.current)) {
if (this->Policy64Status == cmPolicies::OLD ||
this->Policy64Status == cmPolicies::WARN) {
continue;
}
newArgs.ReduceOneArg(
static_cast<bool>(this->Makefile.GetTest(args.next->GetValue())),
args);

View File

@ -66,6 +66,5 @@ private:
cmMakefile& Makefile;
cmListFileBacktrace Backtrace;
cmPolicies::PolicyStatus Policy64Status;
cmPolicies::PolicyStatus Policy139Status;
};

View File

@ -185,7 +185,7 @@ class cmMakefile;
NEW) \
SELECT(POLICY, CMP0063, \
"Honor visibility properties for all target types.", 3, 3, 0, NEW) \
SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, WARN) \
SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, NEW) \
SELECT(POLICY, CMP0065, \
"Do not add flags to export symbols from executables without " \
"the ENABLE_EXPORTS target property.", \

View File

@ -1,5 +1,3 @@
cmake_policy(SET CMP0064 NEW)
if(NOT TEST TestThatDoesNotExist)
message(STATUS "if NOT TestThatDoesNotExist is true")
endif()

View File

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

View File

@ -1,7 +0,0 @@
cmake_policy(SET CMP0064 OLD)
if(TEST)
message(FATAL_ERROR "TEST was not recognized to be undefined")
else()
message(STATUS "TEST was treated as a variable")
endif()

View File

@ -1,10 +0,0 @@
CMake Warning \(dev\) at CMP0064-WARN.cmake:3 \(if\):
Policy CMP0064 is not set: Support new TEST if\(\) operator. Run "cmake
--help-policy CMP0064" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
TEST will be interpreted as an operator when the policy is set to NEW.
Since the policy is not set the OLD behavior will be used.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,7 +0,0 @@
if(TEST)
message(FATAL_ERROR "TEST was not recognized to be undefined")
else()
message(STATUS "TEST was treated as a variable")
endif()

View File

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

View File

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

View File

@ -1,4 +1,3 @@
cmake_policy(SET CMP0064 NEW)
if(TEST TestThatDoesNotExist)
message(FATAL_ERROR "if TestThatDoesNotExist is true")
else()

View File

@ -1,4 +1,3 @@
cmake_policy(SET CMP0064 NEW)
add_test(NAME TestThatExists COMMAND ${CMAKE_COMMAND} -E echo "A CMake Test")
if(TEST TestThatExists)
message(STATUS "if TestThatExists is true")