From 36fffb673af2f8d4ed75e4d36c92c34e14723f67 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2024 13:33:30 -0500 Subject: [PATCH] CMP0062: Remove support for OLD behavior --- Help/policy/CMP0062.rst | 9 +++-- Source/cmInstallCommand.cxx | 40 ++++--------------- Source/cmPolicies.h | 2 +- Tests/RunCMake/install/CMP0062-NEW-stderr.txt | 1 - Tests/RunCMake/install/CMP0062-NEW.cmake | 3 -- Tests/RunCMake/install/CMP0062-OLD-result.txt | 1 - Tests/RunCMake/install/CMP0062-OLD-stderr.txt | 20 ---------- Tests/RunCMake/install/CMP0062-OLD.cmake | 6 --- .../RunCMake/install/CMP0062-WARN-result.txt | 1 - .../RunCMake/install/CMP0062-WARN-stderr.txt | 16 -------- Tests/RunCMake/install/CMP0062-WARN.cmake | 5 --- Tests/RunCMake/install/RunCMakeTest.cmake | 2 - 12 files changed, 14 insertions(+), 92 deletions(-) delete mode 100644 Tests/RunCMake/install/CMP0062-OLD-result.txt delete mode 100644 Tests/RunCMake/install/CMP0062-OLD-stderr.txt delete mode 100644 Tests/RunCMake/install/CMP0062-OLD.cmake delete mode 100644 Tests/RunCMake/install/CMP0062-WARN-result.txt delete mode 100644 Tests/RunCMake/install/CMP0062-WARN-stderr.txt delete mode 100644 Tests/RunCMake/install/CMP0062-WARN.cmake diff --git a/Help/policy/CMP0062.rst b/Help/policy/CMP0062.rst index e0cf71ba32..c785b466c3 100644 --- a/Help/policy/CMP0062.rst +++ b/Help/policy/CMP0062.rst @@ -1,6 +1,9 @@ CMP0062 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + .. versionadded:: 3.3 Disallow :command:`install` of :command:`export` result. @@ -24,7 +27,5 @@ an :command:`export()` command. The ``NEW`` behavior for this policy is not to allow installing the result of an :command:`export()` command. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3 -.. |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/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 04634ab820..f747a7d56c 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -1597,41 +1597,17 @@ bool HandleFilesMode(std::vector const& args, return false; } - cmPolicies::PolicyStatus policyStatus = - helper.Makefile->GetPolicyStatus(cmPolicies::CMP0062); - cmGlobalGenerator* gg = helper.Makefile->GetGlobalGenerator(); for (std::string const& file : filesVector) { if (gg->IsExportedTargetsFile(file)) { - const char* modal = nullptr; - std::ostringstream e; - MessageType messageType = MessageType::AUTHOR_WARNING; - - switch (policyStatus) { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0062) << "\n"; - modal = "should"; - CM_FALLTHROUGH; - case cmPolicies::OLD: - break; - case cmPolicies::NEW: - modal = "may"; - messageType = MessageType::FATAL_ERROR; - break; - } - if (modal) { - e << "The file\n " << file - << "\nwas generated by the export() " - "command. It " - << modal - << " not be installed with the " - "install() command. Use the install(EXPORT) mechanism " - "instead. See the cmake-packages(7) manual for more.\n"; - helper.Makefile->IssueMessage(messageType, e.str()); - if (messageType == MessageType::FATAL_ERROR) { - return false; - } - } + helper.Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("The file\n ", file, '\n', + "was generated by the export() command. " + "It may not be installed with the install() command. " + "Use the install(EXPORT) mechanism instead. " + "See the cmake-packages(7) manual for more.")); + return false; } } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index f234d1582f..15d6449bca 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -182,7 +182,7 @@ class cmMakefile; "CTest does not by default tell make to ignore errors (-i).", 3, 3, \ 0, NEW) \ SELECT(POLICY, CMP0062, "Disallow install() of export() result.", 3, 3, 0, \ - WARN) \ + NEW) \ SELECT(POLICY, CMP0063, \ "Honor visibility properties for all target types.", 3, 3, 0, WARN) \ SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, WARN) \ diff --git a/Tests/RunCMake/install/CMP0062-NEW-stderr.txt b/Tests/RunCMake/install/CMP0062-NEW-stderr.txt index b03f629e8f..570966faa1 100644 --- a/Tests/RunCMake/install/CMP0062-NEW-stderr.txt +++ b/Tests/RunCMake/install/CMP0062-NEW-stderr.txt @@ -6,6 +6,5 @@ CMake Error at CMP0062-NEW.cmake:[0-9]+ \(install\): was generated by the export\(\) command. It may not be installed with the install\(\) command. Use the install\(EXPORT\) mechanism instead. See the cmake-packages\(7\) manual for more. - Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/install/CMP0062-NEW.cmake b/Tests/RunCMake/install/CMP0062-NEW.cmake index 9e7a5fb82f..94e4d0b2ae 100644 --- a/Tests/RunCMake/install/CMP0062-NEW.cmake +++ b/Tests/RunCMake/install/CMP0062-NEW.cmake @@ -1,6 +1,3 @@ -cmake_policy(VERSION 3.2) -cmake_policy(SET CMP0062 NEW) - add_library(iface INTERFACE) export(TARGETS iface FILE "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake" DESTINATION cmake) diff --git a/Tests/RunCMake/install/CMP0062-OLD-result.txt b/Tests/RunCMake/install/CMP0062-OLD-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/install/CMP0062-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/install/CMP0062-OLD-stderr.txt b/Tests/RunCMake/install/CMP0062-OLD-stderr.txt deleted file mode 100644 index 0a2981e941..0000000000 --- a/Tests/RunCMake/install/CMP0062-OLD-stderr.txt +++ /dev/null @@ -1,20 +0,0 @@ -^CMake Deprecation Warning at CMP0062-OLD\.cmake:[0-9]+ \(cmake_policy\): - Compatibility with CMake < 3\.10 will be removed from a future version of - CMake\. - - Update the VERSION argument value\. Or, use the \.\.\. syntax - to tell CMake that the project requires at least but has been updated - to work with policies introduced by or earlier\. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -+ -CMake Deprecation Warning at CMP0062-OLD\.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0062 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\) diff --git a/Tests/RunCMake/install/CMP0062-OLD.cmake b/Tests/RunCMake/install/CMP0062-OLD.cmake deleted file mode 100644 index 8874923b4c..0000000000 --- a/Tests/RunCMake/install/CMP0062-OLD.cmake +++ /dev/null @@ -1,6 +0,0 @@ -cmake_policy(VERSION 3.2) -cmake_policy(SET CMP0062 OLD) - -add_library(iface INTERFACE) -export(TARGETS iface FILE "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake" DESTINATION cmake) diff --git a/Tests/RunCMake/install/CMP0062-WARN-result.txt b/Tests/RunCMake/install/CMP0062-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/install/CMP0062-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/install/CMP0062-WARN-stderr.txt b/Tests/RunCMake/install/CMP0062-WARN-stderr.txt deleted file mode 100644 index 12ae745733..0000000000 --- a/Tests/RunCMake/install/CMP0062-WARN-stderr.txt +++ /dev/null @@ -1,16 +0,0 @@ -CMake Warning \(dev\) at CMP0062-WARN.cmake:[0-9]+ \(install\): - Policy CMP0062 is not set: Disallow install\(\) of export\(\) result. Run - "cmake --help-policy CMP0062" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. - - The file - - .*Tests/RunCMake/install/CMP0062-WARN-build/exported.cmake - - was generated by the export\(\) command. It should not be installed with the - install\(\) command. Use the install\(EXPORT\) mechanism instead. See the - cmake-packages\(7\) manual for more. - -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/install/CMP0062-WARN.cmake b/Tests/RunCMake/install/CMP0062-WARN.cmake deleted file mode 100644 index 018f82275a..0000000000 --- a/Tests/RunCMake/install/CMP0062-WARN.cmake +++ /dev/null @@ -1,5 +0,0 @@ -cmake_policy(VERSION 3.2) - -add_library(iface INTERFACE) -export(TARGETS iface FILE "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake" DESTINATION cmake) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 39c3373dd4..3a121c0b0e 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -88,9 +88,7 @@ run_cmake(EXPORT-NamelinkOnly) run_cmake(EXPORT-SeparateNamelink) run_cmake(EXPORT-TargetTwice) run_cmake(EXPORT-InterfaceLinkNoexist) -run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) -run_cmake(CMP0062-WARN) run_cmake(CMP0087-OLD) run_cmake(CMP0087-NEW) run_cmake(CMP0087-WARN)