mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-29 04:09:35 +03:00
Remove MACROS directory property
It did not always contain all macros. We have `if(COMMAND)` now instead. Add policy CMP0217 for compatibility. Fixes: #27765
This commit is contained in:
@@ -100,6 +100,7 @@ Policies Introduced by CMake 4.4
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
CMP0217: The MACROS directory property does not exist anymore. </policy/CMP0217>
|
||||
CMP0216: Swift targets have a default project name. </policy/CMP0216>
|
||||
CMP0215: Ninja generators emit Swift modules separately from compilation. </policy/CMP0215>
|
||||
CMP0214: Honor CMAKE_EXE_LINKER_FLAGS for Swift executable targets. </policy/CMP0214>
|
||||
|
||||
@@ -84,7 +84,6 @@ Properties on Directories
|
||||
/prop_dir/LINK_DIRECTORIES
|
||||
/prop_dir/LINK_OPTIONS
|
||||
/prop_dir/LISTFILE_STACK
|
||||
/prop_dir/MACROS
|
||||
/prop_dir/PARENT_DIRECTORY
|
||||
/prop_dir/RULE_LAUNCH_COMPILE
|
||||
/prop_dir/RULE_LAUNCH_CUSTOM
|
||||
@@ -702,6 +701,7 @@ Deprecated Properties on Directories
|
||||
/prop_dir/COMPILE_DEFINITIONS_CONFIG
|
||||
/prop_dir/INTERPROCEDURAL_OPTIMIZATION
|
||||
/prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG
|
||||
/prop_dir/MACROS
|
||||
/prop_dir/TEST_INCLUDE_FILE
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
CMP0217
|
||||
-------
|
||||
|
||||
.. versionadded:: 4.4
|
||||
|
||||
The :prop_dir:`MACROS` directory property does not exist anymore.
|
||||
|
||||
In CMake 4.3 and below, the macros defined in a directory are registered in the
|
||||
:prop_dir:`MACROS` directory property. However, the property does not have the
|
||||
same scope as macros, so it does not represent the actual list of macros.
|
||||
In CMake 4.4 and above, this property is not longer filled with the defined
|
||||
macros. One may still use :command:`if(COMMAND myMacro) <if(COMMAND)>` to test
|
||||
whether one exists.
|
||||
|
||||
The ``OLD`` behavior for this policy is to store macros definition in the
|
||||
:prop_dir:`MACROS` directory property.
|
||||
The ``NEW`` behavior for this policy is to no longer manage the
|
||||
:prop_dir:`MACROS` directory property.
|
||||
|
||||
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.4
|
||||
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
|
||||
.. include:: include/STANDARD_ADVICE.rst
|
||||
|
||||
.. include:: include/DEPRECATED.rst
|
||||
@@ -1,8 +1,4 @@
|
||||
MACROS
|
||||
------
|
||||
|
||||
List of macro commands available in the current directory.
|
||||
|
||||
This read-only property specifies the list of CMake macros currently
|
||||
defined. It is intended for debugging purposes. See the :command:`macro`
|
||||
command.
|
||||
This directory property does not exist anymore. See policy :policy:`CMP0217`.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
MACROS-directory-property
|
||||
-------------------------
|
||||
|
||||
* The :prop_dir:`MACROS` directory property does not exist anymore. See policy
|
||||
:policy:`CMP0217`.
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmList.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmState.h"
|
||||
#include "cmValue.h"
|
||||
|
||||
@@ -27,7 +28,9 @@ bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
|
||||
if (cmValue varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
|
||||
output = *varsProp;
|
||||
}
|
||||
} else if (args[1] == "MACROS") {
|
||||
} else if (args[1] == "MACROS" &&
|
||||
status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0217) !=
|
||||
cmPolicies::NEW) {
|
||||
output.clear();
|
||||
if (cmValue macrosProp = status.GetMakefile().GetProperty("MACROS")) {
|
||||
output = *macrosProp;
|
||||
|
||||
@@ -171,7 +171,11 @@ bool cmMacroFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
mf.AppendProperty("MACROS", this->Args[0]);
|
||||
if (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0217) !=
|
||||
cmPolicies::NEW) {
|
||||
|
||||
mf.AppendProperty("MACROS", this->Args[0]);
|
||||
}
|
||||
// create a new command and add it to cmake
|
||||
cmMacroHelperCommand f;
|
||||
f.Args = this->Args;
|
||||
|
||||
+8
-4
@@ -647,7 +647,10 @@ class cmMakefile;
|
||||
"Ninja generators emit Swift modules separately from compilation.", \
|
||||
4, 4, 0, WARN) \
|
||||
SELECT(POLICY, CMP0216, "Swift targets have a default project name.", 4, 4, \
|
||||
0, WARN)
|
||||
0, WARN) \
|
||||
SELECT(POLICY, CMP0217, \
|
||||
"The MACROS directory property does not exist anymore.", 4, 4, 0, \
|
||||
WARN)
|
||||
|
||||
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
|
||||
#define CM_FOR_EACH_POLICY_ID(POLICY) \
|
||||
@@ -738,14 +741,15 @@ public:
|
||||
|
||||
/** \brief Always the last entry.
|
||||
*
|
||||
* Useful mostly to avoid adding a comma the last policy when adding a new
|
||||
* one.
|
||||
* Useful mostly to avoid adding a comma the last policy when adding
|
||||
* a new one.
|
||||
*/
|
||||
CMPCOUNT
|
||||
};
|
||||
|
||||
//! convert a string policy ID into a number
|
||||
static bool GetPolicyID(char const* id, /* out */ cmPolicies::PolicyID& pid);
|
||||
static bool GetPolicyID(char const* id,
|
||||
/* out */ cmPolicies::PolicyID& pid);
|
||||
|
||||
//! Return whether a policy has been removed.
|
||||
static bool IsRemoved(cmPolicies::PolicyID id);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmPolicies.h"
|
||||
|
||||
// cmSetDirectoryPropertiesCommand
|
||||
bool cmSetDirectoryPropertiesCommand(std::vector<std::string> const& args,
|
||||
@@ -27,7 +28,9 @@ bool cmSetDirectoryPropertiesCommand(std::vector<std::string> const& args,
|
||||
"Variables and cache variables should be set using SET command");
|
||||
return false;
|
||||
}
|
||||
if (prop == "MACROS") {
|
||||
if (prop == "MACROS" &&
|
||||
status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0217) !=
|
||||
cmPolicies::NEW) {
|
||||
status.SetError(
|
||||
"Commands and macros cannot be set using SET_CMAKE_PROPERTIES");
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
cmake_policy(SET CMP0217 NEW)
|
||||
|
||||
macro(FOO)
|
||||
endmacro()
|
||||
|
||||
get_property(macros DIRECTORY PROPERTY MACROS)
|
||||
if (macros)
|
||||
set(RunCMake_TEST_FAILED "unexpected content for MACROS directory property.")
|
||||
endif()
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
cmake_policy(SET CMP0217 OLD)
|
||||
|
||||
macro(FOO)
|
||||
endmacro()
|
||||
|
||||
get_property(macros DIRECTORY PROPERTY MACROS)
|
||||
if (NOT "FOO" IN_LIST macros)
|
||||
set(RunCMake_TEST_FAILED "unexpected content for MACROS directory property.")
|
||||
endif()
|
||||
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
@@ -0,0 +1,4 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(CMP0217-OLD)
|
||||
run_cmake(CMP0217-NEW)
|
||||
@@ -184,6 +184,7 @@ add_RunCMake_test(CMP0187)
|
||||
if(WIN32)
|
||||
add_RunCMake_test(CMP0212)
|
||||
endif()
|
||||
add_RunCMake_test(CMP0217)
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||
add_RunCMake_test(CMP0194 -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION})
|
||||
|
||||
Reference in New Issue
Block a user