CMP0062: Remove support for OLD behavior

This commit is contained in:
Brad King
2024-12-13 13:33:30 -05:00
parent 789a7d73d4
commit 36fffb673a
12 changed files with 14 additions and 92 deletions

View File

@@ -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

View File

@@ -1597,41 +1597,17 @@ bool HandleFilesMode(std::vector<std::string> 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;
}
}

View File

@@ -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) \

View File

@@ -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\)

View File

@@ -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)

View File

@@ -1 +0,0 @@
0

View File

@@ -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 <min> value\. Or, use the <min>\.\.\.<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> 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\)

View File

@@ -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)

View File

@@ -1 +0,0 @@
0

View File

@@ -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.

View File

@@ -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)

View File

@@ -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)