CMP0004: Remove support for OLD behavior

This commit is contained in:
Brad King
2024-11-07 14:25:05 -05:00
parent 9dd9321a18
commit 2a0a7401ce
7 changed files with 11 additions and 48 deletions

View File

@@ -1,6 +1,9 @@
CMP0004
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
Libraries linked may not have leading or trailing whitespace.
CMake versions 2.4 and below silently removed leading and trailing
@@ -20,7 +23,5 @@ target is created by an :command:`add_executable` or :command:`add_library`
command.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.6.0
.. |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

@@ -4744,27 +4744,11 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
}
if (lib != item) {
cmake* cm = this->LocalGenerator->GetCMakeInstance();
switch (this->GetPolicyStatusCMP0004()) {
case cmPolicies::WARN: {
std::ostringstream w;
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n"
<< "Target \"" << this->GetName() << "\" links to item \"" << item
<< "\" which has leading or trailing whitespace.";
cm->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
this->GetBacktrace());
}
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
case cmPolicies::NEW: {
std::ostringstream e;
e << "Target \"" << this->GetName() << "\" links to item \"" << item
<< "\" which has leading or trailing whitespace. "
<< "This is now an error according to policy CMP0004.";
cm->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->GetBacktrace());
} break;
}
std::ostringstream e;
e << "Target \"" << this->GetName() << "\" links to item \"" << item
<< "\" which has leading or trailing whitespace. "
<< "This is now an error according to policy CMP0004.";
cm->IssueMessage(MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
}
return lib;
}

View File

@@ -27,7 +27,7 @@ class cmMakefile;
2, 6, 0, NEW) \
SELECT(POLICY, CMP0004, \
"Libraries linked may not have leading or trailing whitespace.", 2, \
6, 0, WARN) \
6, 0, NEW) \
SELECT(POLICY, CMP0005, \
"Preprocessor definition values are now escaped automatically.", 2, \
6, 0, WARN) \

View File

@@ -1 +0,0 @@
1

View File

@@ -1,2 +0,0 @@
Target "bat" links to item " bar " which has leading or trailing
whitespace. This is now an error according to policy CMP0004.

View File

@@ -1,18 +0,0 @@
cmake_policy(SET CMP0004 OLD)
add_library(foo SHARED empty.cpp)
add_library(bar SHARED empty.cpp)
add_library(bing SHARED empty.cpp)
add_library(bung SHARED empty.cpp)
cmake_policy(SET CMP0004 NEW)
add_library(bat SHARED empty.cpp)
target_link_libraries(foo "$<1: bar >")
target_link_libraries(bing "$<$<NOT:$<TARGET_POLICY:CMP0004>>: bar >")
target_link_libraries(bung "$<$<TARGET_POLICY:CMP0004>: bar >")
# The line below causes the error because the policy is NEW when bat
# is created.
target_link_libraries(bat "$<1: bar >")

View File

@@ -1,5 +1,4 @@
include(RunCMake)
run_cmake(CMP0004-OLD)
run_cmake(CMP0004-NEW)
run_cmake(CMP0004-policy-genex)