summaryrefslogtreecommitdiffstats
path: root/Source/cmAddLibraryCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-05-10 13:54:23 (GMT)
committerBrad King <brad.king@kitware.com>2018-05-10 13:57:31 (GMT)
commite567d7eb639b43c2256340acdf4b0053dec0018a (patch)
tree79d902c898966289a2e5959954a3c064e4dd723a /Source/cmAddLibraryCommand.cxx
parentfbe6cd1596bf280edd49aeb8f981f99d7cd8beb3 (diff)
downloadCMake-e567d7eb639b43c2256340acdf4b0053dec0018a.zip
CMake-e567d7eb639b43c2256340acdf4b0053dec0018a.tar.gz
CMake-e567d7eb639b43c2256340acdf4b0053dec0018a.tar.bz2
add_library: Restore error on alias of non-global imported target
In commit v3.11.0-rc1~433^2~1 (Add support for IMPORTED GLOBAL targets to be aliased, 2017-09-14) we accidentally dropped the error on calling `add_library` to alias an imported target that is not globally visible. The `add_executable` command's equivalent check was properly updated. Restore the check in `add_library` with the same update. Also fix the test case accordingly. Fixes: #17982
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r--Source/cmAddLibraryCommand.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 1278232..7792235 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -228,6 +228,14 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
this->SetError(e.str());
return false;
}
+ if (aliasedTarget->IsImported() &&
+ !aliasedTarget->IsImportedGloballyVisible()) {
+ std::ostringstream e;
+ e << "cannot create ALIAS target \"" << libName << "\" because target \""
+ << aliasedName << "\" is imported but not globally visible.";
+ this->SetError(e.str());
+ return false;
+ }
this->Makefile->AddAlias(libName, aliasedName);
return true;
}