CMP0021: Remove support for OLD behavior

This commit is contained in:
Brad King 2024-11-18 18:22:24 -05:00
parent 094b42b643
commit e31d1c7600
8 changed files with 9 additions and 56 deletions

View File

@ -1,6 +1,9 @@
CMP0021
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
Fatal error on relative paths in :prop_tgt:`INCLUDE_DIRECTORIES` target
property.
@ -15,7 +18,5 @@ policy is to issue a ``FATAL_ERROR`` if ``INCLUDE_DIRECTORIES`` contains a
relative path.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.12
.. |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

@ -185,7 +185,6 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt,
if (!cmSystemTools::FileIsFullPath(entryInclude)) {
std::ostringstream e;
bool noMessage = false;
MessageType messageType = MessageType::FATAL_ERROR;
if (!targetName.empty()) {
/* clang-format off */
@ -194,27 +193,13 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt,
" \"" << entryInclude << "\"";
/* clang-format on */
} else {
switch (tgt->GetPolicyStatusCMP0021()) {
case cmPolicies::WARN: {
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n";
messageType = MessageType::AUTHOR_WARNING;
} break;
case cmPolicies::OLD:
noMessage = true;
break;
case cmPolicies::NEW:
// Issue the fatal message.
break;
}
e << "Found relative path while evaluating include directories of "
"\""
<< tgt->GetName() << "\":\n \"" << entryInclude << "\"\n";
}
if (!noMessage) {
tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
if (messageType == MessageType::FATAL_ERROR) {
return;
}
tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
if (messageType == MessageType::FATAL_ERROR) {
return;
}
}

View File

@ -76,7 +76,7 @@ class cmMakefile;
SELECT( \
POLICY, CMP0021, \
"Fatal error on relative paths in INCLUDE_DIRECTORIES target property.", \
2, 8, 12, WARN) \
2, 8, 12, NEW) \
SELECT(POLICY, CMP0022, \
"INTERFACE_LINK_LIBRARIES defines the link interface.", 2, 8, 12, \
WARN) \

View File

@ -1,14 +0,0 @@
cmake_policy(SET CMP0021 OLD)
add_executable(cmp0021exe main.cpp)
if(NOT CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/includes")
execute_process(COMMAND ${CMAKE_COMMAND} -E
copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
"${CMAKE_CURRENT_BINARY_DIR}/includes"
)
endif()
set_property(TARGET cmp0021exe PROPERTY
INCLUDE_DIRECTORIES includes/cmp0021)

View File

@ -1,2 +0,0 @@
#define CMP0021_DEFINE

View File

@ -1,11 +0,0 @@
#include "cmp0021.h"
#ifndef CMP0021_DEFINE
# error Expected CMP0021_DEFINE
#endif
int main(int, char**)
{
return 0;
}

View File

@ -206,7 +206,3 @@ get_target_property(incs empty_entry_test INCLUDE_DIRECTORIES)
if (NOT incs STREQUAL ";/one/two")
message(SEND_ERROR "Empty include_directories entry was not ignored.")
endif()
if(NOT CMAKE_GENERATOR STREQUAL "Xcode" AND NOT CMAKE_GENERATOR MATCHES "Ninja")
add_subdirectory(CMP0021)
endif()

View File

@ -1,7 +1,5 @@
enable_language(CXX)
cmake_policy(SET CMP0021 NEW)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<1:foo>")