summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-02 11:53:34 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-06-02 11:53:40 (GMT)
commit855a7158ed5455f91892d408c4cdbf49e1b232cc (patch)
tree9a1cf511fd9b619e43b3d31599aa87445982d1ca /Source
parent1b0b0c6427f5defe6dc8ede404f36d190276652a (diff)
parent9436ad35df17df89e1a74f91103b04baad085127 (diff)
downloadCMake-855a7158ed5455f91892d408c4cdbf49e1b232cc.zip
CMake-855a7158ed5455f91892d408c4cdbf49e1b232cc.tar.gz
CMake-855a7158ed5455f91892d408c4cdbf49e1b232cc.tar.bz2
Merge topic 'target_link_libraries-self-link-is-an-error'
9436ad35df target_link_libraries: self-link through ALIAS is an error Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4826
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx7
-rw-r--r--Source/cmPolicies.h5
2 files changed, 11 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 39224d1..dcdaaea 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -7030,6 +7030,13 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
// Skip entries that resolve to the target itself or are empty.
std::string name = this->CheckCMP0004(lib);
+ if (this->GetPolicyStatusCMP0108() == cmPolicies::NEW) {
+ // resolve alias name
+ auto target = this->Makefile->FindTargetToUse(name);
+ if (target) {
+ name = target->GetName();
+ }
+ }
if (name == this->GetName() || name.empty()) {
if (name == this->GetName()) {
bool noMessage = false;
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 4dff1d8..a82f421 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -318,6 +318,8 @@ class cmMakefile;
SELECT(POLICY, CMP0106, "The Documentation module is removed.", 3, 18, 0, \
cmPolicies::WARN) \
SELECT(POLICY, CMP0107, "An ALIAS target cannot overwrite another target.", \
+ 3, 18, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0108, "A target cannot link to itself through an alias.", \
3, 18, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
@@ -350,7 +352,8 @@ class cmMakefile;
F(CMP0095) \
F(CMP0099) \
F(CMP0104) \
- F(CMP0105)
+ F(CMP0105) \
+ F(CMP0108)
/** \class cmPolicies
* \brief Handles changes in CMake behavior and policies