diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:20:10 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:20:10 +0900 |
commit | f58f7a233a9b66287e1a0fad0d149e3202a098b4 (patch) | |
tree | cc0cea82fae3f153df9299b27650e17c58da1125 /Source/cmAddLibraryCommand.cxx | |
parent | 46f8b5215bbbfcf4bc0caed1daf52b678fd2b976 (diff) | |
download | cmake-f58f7a233a9b66287e1a0fad0d149e3202a098b4.tar.gz cmake-f58f7a233a9b66287e1a0fad0d149e3202a098b4.tar.bz2 cmake-f58f7a233a9b66287e1a0fad0d149e3202a098b4.zip |
Imported Upstream version 3.18.0upstream/3.18.0
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r-- | Source/cmAddLibraryCommand.cxx | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index f443fc664..3e5d76484 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, @@ -208,14 +219,9 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args, "\" is not a library.")); return false; } - if (aliasedTarget->IsImported() && - !aliasedTarget->IsImportedGloballyVisible()) { - status.SetError(cmStrCat("cannot create ALIAS target \"", libName, - "\" because target \"", aliasedName, - "\" is imported but not globally visible.")); - return false; - } - mf.AddAlias(libName, aliasedName); + mf.AddAlias(libName, aliasedName, + !aliasedTarget->IsImported() || + aliasedTarget->IsImportedGloballyVisible()); return true; } |