mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
CMP0051: Remove support for OLD behavior
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
CMP0051
|
||||
-------
|
||||
|
||||
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||
.. include:: REMOVED_PROLOGUE.txt
|
||||
|
||||
.. versionadded:: 3.1
|
||||
|
||||
List :genex:`TARGET_OBJECTS` in SOURCES target property.
|
||||
@@ -21,7 +24,5 @@ behavior for this policy is to include ``TARGET_OBJECTS`` expressions
|
||||
in the output.
|
||||
|
||||
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.1
|
||||
.. |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
|
||||
|
||||
@@ -60,7 +60,7 @@ using UseTo = cmGeneratorTarget::UseTo;
|
||||
|
||||
template <>
|
||||
cmValue cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
|
||||
cmGeneratorTarget const* tgt, cmMakefile const& /* mf */)
|
||||
cmGeneratorTarget const* tgt)
|
||||
{
|
||||
return tgt->GetSourcesProperty();
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class cmMakefile;
|
||||
SELECT(POLICY, CMP0050, "Disallow add_custom_command SOURCE signatures.", \
|
||||
3, 0, 0, NEW) \
|
||||
SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.", \
|
||||
3, 1, 0, WARN) \
|
||||
3, 1, 0, NEW) \
|
||||
SELECT(POLICY, CMP0052, \
|
||||
"Reject source and build dirs in installed " \
|
||||
"INTERFACE_INCLUDE_DIRECTORIES.", \
|
||||
|
||||
@@ -55,8 +55,7 @@ const std::string& cmTargetPropertyComputer::ImportedLocation<cmTarget>(
|
||||
}
|
||||
|
||||
template <>
|
||||
cmValue cmTargetPropertyComputer::GetSources<cmTarget>(cmTarget const* tgt,
|
||||
cmMakefile const& mf)
|
||||
cmValue cmTargetPropertyComputer::GetSources<cmTarget>(cmTarget const* tgt)
|
||||
{
|
||||
cmBTStringRange entries = tgt->GetSourceEntries();
|
||||
if (entries.empty()) {
|
||||
@@ -68,48 +67,9 @@ cmValue cmTargetPropertyComputer::GetSources<cmTarget>(cmTarget const* tgt,
|
||||
for (auto const& entry : entries) {
|
||||
cmList files{ entry.Value };
|
||||
for (std::string const& file : files) {
|
||||
if (cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") &&
|
||||
file.back() == '>') {
|
||||
std::string objLibName = file.substr(17, file.size() - 18);
|
||||
|
||||
if (cmGeneratorExpression::Find(objLibName) != std::string::npos) {
|
||||
ss << sep;
|
||||
sep = ";";
|
||||
ss << file;
|
||||
continue;
|
||||
}
|
||||
|
||||
bool addContent = false;
|
||||
bool noMessage = true;
|
||||
std::ostringstream e;
|
||||
MessageType messageType = MessageType::AUTHOR_WARNING;
|
||||
switch (mf.GetPolicyStatus(cmPolicies::CMP0051)) {
|
||||
case cmPolicies::WARN:
|
||||
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0051) << "\n";
|
||||
noMessage = false;
|
||||
CM_FALLTHROUGH;
|
||||
case cmPolicies::OLD:
|
||||
break;
|
||||
case cmPolicies::NEW:
|
||||
addContent = true;
|
||||
break;
|
||||
}
|
||||
if (!noMessage) {
|
||||
e << "Target \"" << tgt->GetName()
|
||||
<< "\" contains $<TARGET_OBJECTS> generator expression in its "
|
||||
"sources list. This content was not previously part of the "
|
||||
"SOURCES property when that property was read at configure "
|
||||
"time. Code reading that property needs to be adapted to "
|
||||
"ignore the generator expression using the string(GENEX_STRIP) "
|
||||
"command.";
|
||||
mf.IssueMessage(messageType, e.str());
|
||||
}
|
||||
if (addContent) {
|
||||
ss << sep;
|
||||
sep = ";";
|
||||
ss << file;
|
||||
}
|
||||
} else if (cmGeneratorExpression::Find(file) == std::string::npos) {
|
||||
if ((cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") &&
|
||||
file.back() == '>') ||
|
||||
cmGeneratorExpression::Find(file) == std::string::npos) {
|
||||
ss << sep;
|
||||
sep = ";";
|
||||
ss << file;
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
if (prop == "SOURCES") {
|
||||
return GetSources(tgt, mf);
|
||||
return GetSources(tgt);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -88,5 +88,5 @@ private:
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
static cmValue GetSources(Target const* tgt, cmMakefile const& mf);
|
||||
static cmValue GetSources(Target const* tgt);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
cmake_policy(SET CMP0051 NEW)
|
||||
|
||||
add_library(objects OBJECT empty.cpp)
|
||||
|
||||
add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
^CMake Deprecation Warning at CMP0051-OLD.cmake:2 \(cmake_policy\):
|
||||
The OLD behavior for policy CMP0051 will be removed from a future version
|
||||
of CMake.
|
||||
|
||||
The cmake-policies\(7\) manual explains that the OLD behaviors of all
|
||||
policies are deprecated and that a policy should be set to OLD only under
|
||||
specific short-term circumstances. Projects should be ported to the NEW
|
||||
behavior and not rely on setting a policy to OLD.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
+
|
||||
Sources: "empty.cpp"$
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
cmake_policy(SET CMP0051 OLD)
|
||||
|
||||
add_library(objects OBJECT empty.cpp)
|
||||
|
||||
add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
|
||||
|
||||
get_target_property(srcs empty SOURCES)
|
||||
|
||||
message("Sources: \"${srcs}\"")
|
||||
@@ -1 +0,0 @@
|
||||
add_library(empty2 ../empty.cpp $<TARGET_OBJECTS:objects>)
|
||||
@@ -1 +0,0 @@
|
||||
0
|
||||
@@ -1,31 +0,0 @@
|
||||
CMake Warning \(dev\) at CMP0051-WARN.cmake:6 \(get_target_property\):
|
||||
Policy CMP0051 is not set: List TARGET_OBJECTS in SOURCES target property.
|
||||
Run "cmake --help-policy CMP0051" for policy details. Use the cmake_policy
|
||||
command to set the policy and suppress this warning.
|
||||
|
||||
Target "empty" contains \$<TARGET_OBJECTS> generator expression in its
|
||||
sources list. This content was not previously part of the SOURCES property
|
||||
when that property was read at configure time. Code reading that property
|
||||
needs to be adapted to ignore the generator expression using the
|
||||
string\(GENEX_STRIP\) command.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
Sources: "empty.cpp"
|
||||
*
|
||||
CMake Warning \(dev\) at CMP0051-WARN.cmake:12 \(get_target_property\):
|
||||
Policy CMP0051 is not set: List TARGET_OBJECTS in SOURCES target property.
|
||||
Run "cmake --help-policy CMP0051" for policy details. Use the cmake_policy
|
||||
command to set the policy and suppress this warning.
|
||||
|
||||
Target "empty2" contains \$<TARGET_OBJECTS> generator expression in its
|
||||
sources list. This content was not previously part of the SOURCES property
|
||||
when that property was read at configure time. Code reading that property
|
||||
needs to be adapted to ignore the generator expression using the
|
||||
string\(GENEX_STRIP\) command.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
Sources: "../empty.cpp"$
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
add_library(objects OBJECT empty.cpp)
|
||||
|
||||
add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
|
||||
|
||||
get_target_property(srcs empty SOURCES)
|
||||
|
||||
message("Sources: \"${srcs}\"")
|
||||
|
||||
add_subdirectory(CMP0051-WARN-Dir)
|
||||
|
||||
get_target_property(srcs empty2 SOURCES)
|
||||
|
||||
message("Sources: \"${srcs}\"")
|
||||
@@ -1,3 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(${RunCMake_TEST} CXX)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
include(RunCMake)
|
||||
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
|
||||
|
||||
run_cmake(CMP0051-OLD)
|
||||
run_cmake(CMP0051-NEW)
|
||||
run_cmake(CMP0051-WARN)
|
||||
|
||||
Reference in New Issue
Block a user