summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-05-30 09:45:53 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-05-30 09:47:39 (GMT)
commit9436ad35df17df89e1a74f91103b04baad085127 (patch)
tree03dd545967151a213153304db2bafcdb3ce3987c /Source
parent67dd68765700bbd6a981700c04f45b28cdc85587 (diff)
downloadCMake-9436ad35df17df89e1a74f91103b04baad085127.zip
CMake-9436ad35df17df89e1a74f91103b04baad085127.tar.gz
CMake-9436ad35df17df89e1a74f91103b04baad085127.tar.bz2
target_link_libraries: self-link through ALIAS is an error
Fixes: #19617
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 f2a51ab..24a1dde 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -7031,6 +7031,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