diff --git a/Help/policy/CMP0051.rst b/Help/policy/CMP0051.rst index e049bbaf1a..ae4498ad32 100644 --- a/Help/policy/CMP0051.rst +++ b/Help/policy/CMP0051.rst @@ -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 diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b6d14e8cfc..39f6966f85 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -60,7 +60,7 @@ using UseTo = cmGeneratorTarget::UseTo; template <> cmValue cmTargetPropertyComputer::GetSources( - cmGeneratorTarget const* tgt, cmMakefile const& /* mf */) + cmGeneratorTarget const* tgt) { return tgt->GetSourcesProperty(); } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a7ae22eebb..d546aa6417 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -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.", \ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c75462820f..530967efbe 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -55,8 +55,7 @@ const std::string& cmTargetPropertyComputer::ImportedLocation( } template <> -cmValue cmTargetPropertyComputer::GetSources(cmTarget const* tgt, - cmMakefile const& mf) +cmValue cmTargetPropertyComputer::GetSources(cmTarget const* tgt) { cmBTStringRange entries = tgt->GetSourceEntries(); if (entries.empty()) { @@ -68,48 +67,9 @@ cmValue cmTargetPropertyComputer::GetSources(cmTarget const* tgt, for (auto const& entry : entries) { cmList files{ entry.Value }; for (std::string const& file : files) { - if (cmHasLiteralPrefix(file, "$') { - 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 $ 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, "$') || + cmGeneratorExpression::Find(file) == std::string::npos) { ss << sep; sep = ";"; ss << file; diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h index ea50f290fc..248ea03b89 100644 --- a/Source/cmTargetPropertyComputer.h +++ b/Source/cmTargetPropertyComputer.h @@ -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 - static cmValue GetSources(Target const* tgt, cmMakefile const& mf); + static cmValue GetSources(Target const* tgt); }; diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake index f304bf186c..144c98247c 100644 --- a/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake +++ b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake @@ -1,6 +1,3 @@ - -cmake_policy(SET CMP0051 NEW) - add_library(objects OBJECT empty.cpp) add_library(empty empty.cpp $) diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt deleted file mode 100644 index e1c44e507f..0000000000 --- a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt +++ /dev/null @@ -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"$ diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake b/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake deleted file mode 100644 index 0243e944cf..0000000000 --- a/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake +++ /dev/null @@ -1,10 +0,0 @@ - -cmake_policy(SET CMP0051 OLD) - -add_library(objects OBJECT empty.cpp) - -add_library(empty empty.cpp $) - -get_target_property(srcs empty SOURCES) - -message("Sources: \"${srcs}\"") diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-Dir/CMakeLists.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-Dir/CMakeLists.txt deleted file mode 100644 index 77cbad53ef..0000000000 --- a/Tests/RunCMake/CMP0051/CMP0051-WARN-Dir/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(empty2 ../empty.cpp $) diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt deleted file mode 100644 index 78c6b6d30f..0000000000 --- a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt +++ /dev/null @@ -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 \$ 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 \$ 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"$ diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake b/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake deleted file mode 100644 index 744598fcbf..0000000000 --- a/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake +++ /dev/null @@ -1,14 +0,0 @@ - -add_library(objects OBJECT empty.cpp) - -add_library(empty empty.cpp $) - -get_target_property(srcs empty SOURCES) - -message("Sources: \"${srcs}\"") - -add_subdirectory(CMP0051-WARN-Dir) - -get_target_property(srcs empty2 SOURCES) - -message("Sources: \"${srcs}\"") diff --git a/Tests/RunCMake/CMP0051/CMakeLists.txt b/Tests/RunCMake/CMP0051/CMakeLists.txt index 3482e6baf2..c814f14935 100644 --- a/Tests/RunCMake/CMP0051/CMakeLists.txt +++ b/Tests/RunCMake/CMP0051/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0051/RunCMakeTest.cmake b/Tests/RunCMake/CMP0051/RunCMakeTest.cmake index 955d8987ce..74015c386e 100644 --- a/Tests/RunCMake/CMP0051/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0051/RunCMakeTest.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)