1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

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
This commit is contained in:
Brad King
2018-05-10 09:54:23 -04:00
parent fbe6cd1596
commit e567d7eb63
3 changed files with 25 additions and 2 deletions

View File

@@ -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;
}