diff --git a/Help/policy/CMP0038.rst b/Help/policy/CMP0038.rst index b0de8ca9c0..df147dee89 100644 --- a/Help/policy/CMP0038.rst +++ b/Help/policy/CMP0038.rst @@ -1,6 +1,9 @@ CMP0038 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + Targets may not link directly to themselves. CMake 2.8.12 and lower allowed a build target to link to itself directly with @@ -12,7 +15,5 @@ in their own link implementation. The ``NEW`` behavior for this policy is to report an error if a target attempts to link to itself. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.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 diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index febab4be4e..f000c32a17 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -1189,30 +1189,11 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( } if (name == this->GetName() || name.empty()) { if (name == this->GetName()) { - bool noMessage = false; - MessageType messageType = MessageType::FATAL_ERROR; - std::ostringstream e; - switch (this->GetPolicyStatusCMP0038()) { - case cmPolicies::WARN: { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n"; - messageType = MessageType::AUTHOR_WARNING; - } break; - case cmPolicies::OLD: - noMessage = true; - break; - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if (!noMessage) { - e << "Target \"" << this->GetName() << "\" links to itself."; - this->LocalGenerator->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->GetBacktrace()); - if (messageType == MessageType::FATAL_ERROR) { - return; - } - } + this->LocalGenerator->GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Target \"", this->GetName(), "\" links to itself."), + this->GetBacktrace()); + return; } continue; } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 9acdb29db0..71ed73acbc 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -119,7 +119,7 @@ class cmMakefile; "pattern.", \ 3, 0, 0, NEW) \ SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3, \ - 0, 0, WARN) \ + 0, 0, NEW) \ SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.", \ 3, 0, 0, WARN) \ SELECT(POLICY, CMP0040, \ diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt index 3d0a428e18..96857584d6 100644 --- a/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at CMP0038-NEW.cmake:3 \(add_library\): +CMake Error at CMP0038-NEW.cmake:1 \(add_library\): Target "self_link" links to itself. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake b/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake index 6296b839a2..0e3df1d957 100644 --- a/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake @@ -1,4 +1,2 @@ - -cmake_policy(SET CMP0038 NEW) add_library(self_link empty.cpp) target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt deleted file mode 100644 index c754128616..0000000000 --- a/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at CMP0038-OLD.cmake:2 \(cmake_policy\): - The OLD behavior for policy CMP0038 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:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake b/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake deleted file mode 100644 index 37528218ca..0000000000 --- a/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -cmake_policy(SET CMP0038 OLD) -add_library(self_link empty.cpp) -target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt b/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt deleted file mode 100644 index 64631e7ffd..0000000000 --- a/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Warning \(dev\) at CMP0038-WARN.cmake:2 \(add_library\): - Policy CMP0038 is not set: Targets may not link directly to themselves. - Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. - - Target "self_link" links to itself. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake b/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake deleted file mode 100644 index 5b92d09518..0000000000 --- a/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake +++ /dev/null @@ -1,3 +0,0 @@ - -add_library(self_link empty.cpp) -target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMakeLists.txt b/Tests/RunCMake/CMP0038/CMakeLists.txt index a06591c31f..c814f14935 100644 --- a/Tests/RunCMake/CMP0038/CMakeLists.txt +++ b/Tests/RunCMake/CMP0038/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0038/RunCMakeTest.cmake b/Tests/RunCMake/CMP0038/RunCMakeTest.cmake index 3e7b5f3b56..06f88081b1 100644 --- a/Tests/RunCMake/CMP0038/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0038/RunCMakeTest.cmake @@ -1,6 +1,3 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) -run_cmake(CMP0038-WARN) run_cmake(CMP0038-NEW) -run_cmake(CMP0038-OLD) diff --git a/Tests/RunCMake/target_link_libraries/CMP0108-self-link.cmake b/Tests/RunCMake/target_link_libraries/CMP0108-self-link.cmake index 07a3490dd4..2b522f19fb 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0108-self-link.cmake +++ b/Tests/RunCMake/target_link_libraries/CMP0108-self-link.cmake @@ -1,5 +1,4 @@ -cmake_policy (SET CMP0038 NEW) cmake_policy (SET CMP0042 NEW) enable_language(C)