CMP0059: Remove support for OLD behavior

This commit is contained in:
Brad King
2024-12-11 16:26:19 -05:00
parent 8f9f01b24d
commit 1393fbf13f
16 changed files with 7 additions and 124 deletions
+5 -4
View File
@@ -1,6 +1,9 @@
CMP0059
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
.. versionadded:: 3.3
Do not treat ``DEFINITIONS`` as a built-in directory property.
@@ -14,7 +17,5 @@ so far to the :command:`add_definitions` command. The ``NEW`` behavior is
to behave as a normal user-defined directory property.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3
.. |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
-24
View File
@@ -5,14 +5,10 @@
#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmSystemTools.h"
#include "cmValue.h"
namespace {
void StoreResult(cmMakefile& makefile, std::string const& variable,
const char* prop);
void StoreResult(cmMakefile& makefile, std::string const& variable,
cmValue prop);
}
@@ -78,31 +74,11 @@ bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args,
return false;
}
if (*i == "DEFINITIONS") {
switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0059)) {
case cmPolicies::WARN:
status.GetMakefile().IssueMessage(
MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
CM_FALLTHROUGH;
case cmPolicies::OLD:
StoreResult(status.GetMakefile(), variable,
status.GetMakefile().GetDefineFlagsCMP0059());
return true;
case cmPolicies::NEW:
break;
}
}
StoreResult(status.GetMakefile(), variable, dir->GetProperty(*i));
return true;
}
namespace {
void StoreResult(cmMakefile& makefile, std::string const& variable,
const char* prop)
{
makefile.AddDefinition(variable, prop ? prop : "");
}
void StoreResult(cmMakefile& makefile, std::string const& variable,
cmValue prop)
{
-15
View File
@@ -12,7 +12,6 @@
#include "cmGlobalGenerator.h"
#include "cmInstalledFile.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmProperty.h"
#include "cmPropertyDefinition.h"
@@ -370,20 +369,6 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
}
}
if (propertyName == "DEFINITIONS") {
switch (mf->GetPolicyStatus(cmPolicies::CMP0059)) {
case cmPolicies::WARN:
mf->IssueMessage(MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
CM_FALLTHROUGH;
case cmPolicies::OLD:
return StoreResult(infoType, status.GetMakefile(), variable,
mf->GetDefineFlagsCMP0059());
case cmPolicies::NEW:
break;
}
}
// Get the property.
return StoreResult(infoType, status.GetMakefile(), variable,
mf->GetProperty(propertyName));
-12
View File
@@ -1245,9 +1245,6 @@ void cmMakefile::AddDefineFlag(std::string const& flag)
return;
}
// Update the string used for the old DEFINITIONS property.
s_AddDefineFlag(flag, this->DefineFlagsOrig);
// If this is really a definition, update COMPILE_DEFINITIONS.
if (this->ParseDefineFlag(flag, false)) {
return;
@@ -1281,9 +1278,6 @@ void cmMakefile::RemoveDefineFlag(std::string const& flag)
return;
}
// Update the string used for the old DEFINITIONS property.
s_RemoveDefineFlag(flag, this->DefineFlagsOrig);
// If this is really a definition, update COMPILE_DEFINITIONS.
if (this->ParseDefineFlag(flag, true)) {
return;
@@ -1357,7 +1351,6 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
// define flags
this->DefineFlags = parent->DefineFlags;
this->DefineFlagsOrig = parent->DefineFlagsOrig;
// Include transform property. There is no per-config version.
{
@@ -3977,11 +3970,6 @@ cmStateSnapshot cmMakefile::GetStateSnapshot() const
return this->StateSnapshot;
}
const char* cmMakefile::GetDefineFlagsCMP0059() const
{
return this->DefineFlagsOrig.c_str();
}
cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id,
bool parent_scope) const
{
-5
View File
@@ -1006,8 +1006,6 @@ public:
cmStateSnapshot GetStateSnapshot() const;
const char* GetDefineFlagsCMP0059() const;
void EnforceDirectoryLevelRules() const;
void AddEvaluationFile(
@@ -1134,9 +1132,6 @@ protected:
std::string ComplainFileRegularExpression;
std::string DefineFlags;
// Track the value of the computed DEFINITIONS property.
std::string DefineFlagsOrig;
#if !defined(CMAKE_BOOTSTRAP)
std::vector<cmSourceGroup> SourceGroups;
size_t ObjectLibrariesSourceGroupIndex;
+1 -1
View File
@@ -174,7 +174,7 @@ class cmMakefile;
NEW) \
SELECT(POLICY, CMP0059, \
"Do not treat DEFINITIONS as a built-in directory property.", 3, 3, \
0, WARN) \
0, NEW) \
SELECT(POLICY, CMP0060, \
"Link libraries by full path even in implicit directories.", 3, 3, \
0, WARN) \
@@ -1 +0,0 @@
0
-3
View File
@@ -1,6 +1,3 @@
cmake_policy(SET CMP0059 NEW)
add_definitions(-DSOME_DEF)
get_property(defs DIRECTORY .
@@ -1 +0,0 @@
0
@@ -1,2 +0,0 @@
DEFS: -DSOME_DEF
CUSTOM CONTENT: -DSOME_DEF
-17
View File
@@ -1,17 +0,0 @@
cmake_policy(SET CMP0059 OLD)
add_definitions(-DSOME_DEF)
get_property(defs DIRECTORY .
PROPERTY DEFINITIONS
)
message("DEFS:${defs}")
set_property(DIRECTORY .
PROPERTY DEFINITIONS CUSTOM_CONTENT
)
get_property(content DIRECTORY .
PROPERTY DEFINITIONS
)
message("CUSTOM CONTENT:${content}")
@@ -1 +0,0 @@
0
@@ -1,18 +0,0 @@
CMake Warning \(dev\) at CMP0059-WARN.cmake:6 \(get_property\):
Policy CMP0059 is not set: Do not treat DEFINITIONS as a built-in directory
property. Run "cmake --help-policy CMP0059" 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.
DEFS: -DSOME_DEF
CMake Warning \(dev\) at CMP0059-WARN.cmake:14 \(get_property\):
Policy CMP0059 is not set: Do not treat DEFINITIONS as a built-in directory
property. Run "cmake --help-policy CMP0059" 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.
CUSTOM CONTENT: -DSOME_DEF
-17
View File
@@ -1,17 +0,0 @@
add_definitions(-DSOME_DEF)
get_property(defs DIRECTORY .
PROPERTY DEFINITIONS
)
message("DEFS:${defs}")
set_property(DIRECTORY .
PROPERTY DEFINITIONS CUSTOM_CONTENT
)
get_property(content DIRECTORY .
PROPERTY DEFINITIONS
)
message("CUSTOM CONTENT:${content}")
+1 -1
View File
@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
@@ -1,5 +1,3 @@
include(RunCMake)
run_cmake(CMP0059-OLD)
run_cmake(CMP0059-NEW)
run_cmake(CMP0059-WARN)