diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-05-28 12:52:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-05-28 16:56:59 (GMT) |
commit | 1eca5993e21eeefa8a0c8d4e41b559c1d32c495a (patch) | |
tree | 224acb0649ebc5e8198b311950f7f30da4c606f0 /Source/cmAddLibraryCommand.cxx | |
parent | 04b9b2b5f363d792719238046a18aac867be3254 (diff) | |
download | CMake-1eca5993e21eeefa8a0c8d4e41b559c1d32c495a.zip CMake-1eca5993e21eeefa8a0c8d4e41b559c1d32c495a.tar.gz CMake-1eca5993e21eeefa8a0c8d4e41b559c1d32c495a.tar.bz2 |
ALIAS target: cannot overwrite an existing target
Fixes: #19616
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r-- | Source/cmAddLibraryCommand.cxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index f443fc6..d79c04f 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -9,6 +9,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmPolicies.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -181,6 +182,16 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args, return false; } + if (mf.GetPolicyStatus(cmPolicies::CMP0107) == cmPolicies::NEW) { + // Make sure the target does not already exist. + if (mf.FindTargetToUse(libName)) { + status.SetError(cmStrCat( + "cannot create ALIAS target \"", libName, + "\" because another target with the same name already exists.")); + return false; + } + } + std::string const& aliasedName = *s; if (mf.IsAlias(aliasedName)) { status.SetError(cmStrCat("cannot create ALIAS target \"", libName, |