CMP0060: Remove support for OLD behavior

This commit is contained in:
Brad King 2024-12-11 16:32:10 -05:00
parent 1393fbf13f
commit 3dc19e24cb
21 changed files with 17 additions and 111 deletions

View File

@ -59,7 +59,8 @@ Each ``<item>`` may be:
There are some cases where CMake may ask the linker to search for
the library (e.g. ``/usr/lib/libfoo.so`` becomes ``-lfoo``), such
as when a shared library is detected to have no ``SONAME`` field.
See policy :policy:`CMP0060` for discussion of another case.
In CMake versions prior to 4.0, see policy :policy:`CMP0060` for
discussion of another case.
If the library file is in a macOS framework, the ``Headers`` directory
of the framework will also be processed as a

View File

@ -1,6 +1,9 @@
CMP0060
-------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
.. versionadded:: 3.3
Link libraries by full path even in implicit directories.
@ -59,11 +62,9 @@ The ``NEW`` behavior for this policy is to link libraries by full path even
if they are in implicit link directories.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.3
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn by default
.. include:: STANDARD_ADVICE.txt
.. |WARNED_OR_DID_NOT_WARN| replace:: did *not* warn by default
.. include:: REMOVED_EPILOGUE.txt
See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0060 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
.. include:: DEPRECATED.txt
variable to control the warning in CMake versions before 4.0.

View File

@ -31,9 +31,9 @@ Some toolchains read implicit directories from an environment variable such as
consistent when operating in a given build tree because CMake saves the value
detected when first creating a build tree.
If policy :policy:`CMP0060` is not set to ``NEW``, then when a library in one
of these directories is given by full path to :command:`target_link_libraries`
CMake will generate the ``-l<name>`` form on link lines for historical
purposes.
In CMake versions prior to 4.0, if policy :policy:`CMP0060` is not set
to ``NEW``, then when a library in one of these directories is given by
full path to :command:`target_link_libraries` CMake will generate the
``-l<name>`` form on link lines for historical purposes.
See also the :variable:`CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES` variable.

View File

@ -12,8 +12,8 @@ only for the policies that do not warn by default:
policy :policy:`CMP0047` in CMake versions before 4.0.
* ``CMAKE_POLICY_WARNING_CMP0056`` controlled the warning for
policy :policy:`CMP0056` in CMake versions before 4.0.
* ``CMAKE_POLICY_WARNING_CMP0060`` controls the warning for
policy :policy:`CMP0060`.
* ``CMAKE_POLICY_WARNING_CMP0060`` controlled the warning for
policy :policy:`CMP0060` in CMake versions before 4.0.
* ``CMAKE_POLICY_WARNING_CMP0065`` controls the warning for
policy :policy:`CMP0065`.
* ``CMAKE_POLICY_WARNING_CMP0066`` controls the warning for

View File

@ -24,7 +24,6 @@
#include "cmMessageType.h"
#include "cmOrderDirectories.h"
#include "cmPlaceholderExpander.h"
#include "cmPolicies.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateTypes.h"
@ -421,9 +420,6 @@ cmComputeLinkInformation::cmComputeLinkInformation(
this->OrderDependentRPath->SetImplicitDirectories(this->ImplicitLinkDirs);
this->OrderDependentRPath->AddLanguageDirectories(this->RuntimeLinkDirs);
}
this->CMP0060Warn = this->Makefile->PolicyOptionalWarningEnabled(
"CMAKE_POLICY_WARNING_CMP0060");
}
cmComputeLinkInformation::~cmComputeLinkInformation() = default;
@ -650,22 +646,6 @@ bool cmComputeLinkInformation::Compute()
// Add implicit language runtime libraries and directories.
this->AddImplicitLinkInfo();
if (!this->CMP0060WarnItems.empty()) {
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0060) << "\n"
"Some library files are in directories implicitly searched by "
"the linker when invoked for " << this->LinkLanguage << ":\n"
" " << cmJoin(this->CMP0060WarnItems, "\n ") << "\n"
"For compatibility with older versions of CMake, the generated "
"link line will ask the linker to search for these by library "
"name."
;
/* clang-format on */
this->CMakeInstance->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
this->Target->GetBacktrace());
}
// Record targets referenced by $<TARGET_OBJECTS:...> sources.
this->AddExternalObjectTargets();
@ -1765,39 +1745,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(LinkEntry const& entry)
return false;
}
// Check the policy for whether we should use the approach below.
switch (this->Target->GetPolicyStatusCMP0060()) {
case cmPolicies::WARN:
if (this->CMP0060Warn) {
// Print the warning at most once for this item.
std::string const& wid =
cmStrCat("CMP0060-WARNING-GIVEN-", item.Value);
if (!this->CMakeInstance->GetPropertyAsBool(wid)) {
this->CMakeInstance->SetProperty(wid, "1");
this->CMP0060WarnItems.insert(item.Value);
}
}
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
return false;
}
// Many system linkers support multiple architectures by
// automatically selecting the implicit linker search path for the
// current architecture. If the library appears in an implicit link
// directory then just report the file name without the directory
// portion. This will allow the system linker to locate the proper
// library for the architecture at link time.
LinkEntry fileEntry{ entry };
fileEntry.Item = file;
this->AddUserItem(fileEntry);
// Make sure the link directory ordering will find the library.
this->OrderLinkerSearchPath->AddLinkLibrary(item.Value);
return true;
return false;
}
void cmComputeLinkInformation::AddUserItem(LinkEntry const& entry)

View File

@ -239,7 +239,6 @@ private:
// Additional paths configured by the runtime linker
std::vector<std::string> RuntimeLinkDirs;
std::set<std::string> CMP0060WarnItems;
// Dependent library path computation.
std::unique_ptr<cmOrderDirectories> OrderDependentRPath;
// Runtime path computation.
@ -252,7 +251,6 @@ private:
bool LinkWithRuntimePath;
bool LinkTypeEnabled;
bool ArchivesMayBeShared;
bool CMP0060Warn;
void AddLibraryRuntimeInfo(std::string const& fullPath,
const cmGeneratorTarget* target);

View File

@ -177,7 +177,7 @@ class cmMakefile;
0, NEW) \
SELECT(POLICY, CMP0060, \
"Link libraries by full path even in implicit directories.", 3, 3, \
0, WARN) \
0, NEW) \
SELECT(POLICY, CMP0061, \
"CTest does not by default tell make to ignore errors (-i).", 3, 3, \
0, WARN) \

View File

@ -1,2 +1 @@
cmake_policy(SET CMP0060 NEW)
include(CMP0060-Common.cmake)

View File

@ -1 +0,0 @@
LINKFLAG_CMP0060_LINKSUFFIX

View File

@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0060-OLD.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0060 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,2 +0,0 @@
cmake_policy(SET CMP0060 OLD)
include(CMP0060-Common.cmake)

View File

@ -1 +0,0 @@
LINKFLAG_CMP0060_LINKSUFFIX

View File

@ -1 +0,0 @@
include(CMP0060-Common.cmake)

View File

@ -1 +0,0 @@
LINKFLAG_CMP0060_LINKSUFFIX

View File

@ -1,16 +0,0 @@
^CMake Warning \(dev\) at CMP0060-Common.cmake:[0-9]+ \(add_executable\):
Policy CMP0060 is not set: Link libraries by full path even in implicit
directories. Run "cmake --help-policy CMP0060" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Some library files are in directories implicitly searched by the linker
when invoked for C:
.*/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-build/lib/(lib)?CMP0060.(a|lib|l)
For compatibility with older versions of CMake, the generated link line
will ask the linker to search for these by library name.
Call Stack \(most recent call first\):
CMP0060-WARN-ON.cmake:[0-9]+ \(include\)
CMakeLists.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$

View File

@ -1,2 +0,0 @@
set(CMAKE_POLICY_WARNING_CMP0060 1)
include(CMP0060-Common.cmake)

View File

@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.10)
project(${RunCMake_TEST} C)
include(${RunCMake_TEST}.cmake)

View File

@ -1,5 +1,4 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
function(run_cmake_CMP0060 CASE)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0060-${CASE}-build)
@ -14,7 +13,4 @@ function(run_cmake_CMP0060 CASE)
)
endfunction()
run_cmake_CMP0060(OLD)
run_cmake_CMP0060(WARN-OFF)
run_cmake_CMP0060(WARN-ON)
run_cmake_CMP0060(NEW)