CMP0023: Remove support for OLD behavior

This commit is contained in:
Brad King 2024-11-19 14:32:14 -05:00
parent 033a2dc000
commit 0453f70400
13 changed files with 26 additions and 102 deletions

View File

@ -1,6 +1,9 @@
CMP0023
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
Plain and keyword :command:`target_link_libraries` signatures cannot be mixed.
CMake 2.8.12 introduced the :command:`target_link_libraries` signature using
@ -29,7 +32,5 @@ this policy is to not to allow mixing of the keyword and plain
signatures.
.. |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

@ -83,7 +83,7 @@ class cmMakefile;
SELECT( \
POLICY, CMP0023, \
"Plain and keyword target_link_libraries signatures cannot be mixed.", 2, \
8, 12, WARN) \
8, 12, NEW) \
SELECT(POLICY, CMP0024, "Disallow include export result.", 3, 0, 0, WARN) \
SELECT(POLICY, CMP0025, "Compiler id for Apple Clang is now AppleClang.", \
3, 0, 0, WARN) \

View File

@ -396,41 +396,22 @@ bool TLL::HandleLibrary(ProcessingState currentProcessingState,
if (!this->Target->PushTLLCommandTrace(
sig, this->Makefile.GetBacktrace().Top())) {
std::ostringstream e;
const char* modal = nullptr;
MessageType messageType = MessageType::AUTHOR_WARNING;
switch (this->Makefile.GetPolicyStatus(cmPolicies::CMP0023)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << '\n';
modal = "should";
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
modal = "must";
messageType = MessageType::FATAL_ERROR;
break;
}
if (modal) {
// If the sig is a keyword form and there is a conflict, the existing
// form must be the plain form.
const char* existingSig =
(sig == cmTarget::KeywordTLLSignature ? "plain" : "keyword");
e << "The " << existingSig
<< " signature for target_link_libraries has "
"already been used with the target \""
<< this->Target->GetName()
<< "\". All uses of target_link_libraries with a target " << modal
<< " be either all-keyword or all-plain.\n";
this->Target->GetTllSignatureTraces(e,
sig == cmTarget::KeywordTLLSignature
? cmTarget::PlainTLLSignature
: cmTarget::KeywordTLLSignature);
this->Makefile.IssueMessage(messageType, e.str());
if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
// If the sig is a keyword form and there is a conflict, the existing
// form must be the plain form.
const char* existingSig =
(sig == cmTarget::KeywordTLLSignature ? "plain" : "keyword");
e << "The " << existingSig
<< " signature for target_link_libraries has "
"already been used with the target \""
<< this->Target->GetName()
<< "\". All uses of target_link_libraries with a target must "
<< " be either all-keyword or all-plain.\n";
this->Target->GetTllSignatureTraces(e,
sig == cmTarget::KeywordTLLSignature
? cmTarget::PlainTLLSignature
: cmTarget::KeywordTLLSignature);
this->Makefile.IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
// Handle normal case where the command was called with another keyword than

View File

@ -1,7 +1,5 @@
enable_language(CXX)
cmake_policy(SET CMP0023 NEW)
add_library(somelib empty.cpp)
# This test ensures that some internal mechanisms of cmGeneratorExpression

View File

@ -1,11 +1,11 @@
CMake Error at CMP0023-NEW-2.cmake:11 \(target_link_libraries\):
CMake Error at CMP0023-NEW-2.cmake:9 \(target_link_libraries\):
The plain signature for target_link_libraries has already been used with
the target "foo". All uses of target_link_libraries with a target must be
either all-keyword or all-plain.
The uses of the plain signature are here:
\* CMP0023-NEW-2.cmake:10 \(target_link_libraries\)
\* CMP0023-NEW-2.cmake:8 \(target_link_libraries\)
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)

View File

@ -1,8 +1,6 @@
enable_language(CXX)
cmake_policy(SET CMP0023 NEW)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
add_library(bat SHARED empty_vs6_3.cpp)

View File

@ -1,11 +1,11 @@
CMake Error at CMP0023-NEW.cmake:11 \(target_link_libraries\):
CMake Error at CMP0023-NEW.cmake:9 \(target_link_libraries\):
The plain signature for target_link_libraries has already been used with
the target "foo". All uses of target_link_libraries with a target must be
either all-keyword or all-plain.
The uses of the plain signature are here:
\* CMP0023-NEW.cmake:10 \(target_link_libraries\)
\* CMP0023-NEW.cmake:8 \(target_link_libraries\)
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)

View File

@ -1,8 +1,6 @@
enable_language(CXX)
cmake_policy(SET CMP0023 NEW)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
add_library(bat SHARED empty_vs6_3.cpp)

View File

@ -1,16 +0,0 @@
CMake Warning \(dev\) at CMP0023-WARN-2.cmake:9 \(target_link_libraries\):
Policy CMP0023 is not set: Plain and keyword target_link_libraries
signatures cannot be mixed. Run "cmake --help-policy CMP0023" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
The plain signature for target_link_libraries has already been used with
the target "foo". All uses of target_link_libraries with a target should
be either all-keyword or all-plain.
The uses of the plain signature are here:
\* CMP0023-WARN-2.cmake:8 \(target_link_libraries\)
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)

View File

@ -1,9 +0,0 @@
cmake_policy(VERSION 2.8.11)
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
add_library(bat SHARED empty_vs6_3.cpp)
target_link_libraries(foo bar)
target_link_libraries(foo LINK_PRIVATE bat)

View File

@ -1,16 +0,0 @@
CMake Warning \(dev\) at CMP0023-WARN.cmake:9 \(target_link_libraries\):
Policy CMP0023 is not set: Plain and keyword target_link_libraries
signatures cannot be mixed. Run "cmake --help-policy CMP0023" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
The plain signature for target_link_libraries has already been used with
the target "foo". All uses of target_link_libraries with a target should
be either all-keyword or all-plain.
The uses of the plain signature are here:
\* CMP0023-WARN.cmake:8 \(target_link_libraries\)
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)

View File

@ -1,9 +0,0 @@
cmake_policy(VERSION 2.8.11)
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
add_library(bat SHARED empty_vs6_3.cpp)
target_link_libraries(foo bar)
target_link_libraries(foo PRIVATE bat)

View File

@ -8,9 +8,7 @@ endif()
run_cmake(ConfigCase)
unset(RunCMake_TEST_OPTIONS)
run_cmake(CMP0023-WARN)
run_cmake(CMP0023-NEW)
run_cmake(CMP0023-WARN-2)
run_cmake(CMP0023-NEW-2)
run_cmake(CMP0079-iface-WARN)
run_cmake(CMP0079-iface-OLD)