mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
target_link_libraries: Return earlier on some error.
This commit is contained in:
@@ -388,27 +388,27 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
|
||||
<< this->Target->GetName()
|
||||
<< "\" which is not built in this directory.";
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
} else {
|
||||
|
||||
cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(lib);
|
||||
|
||||
if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::UNKNOWN_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
|
||||
!tgt->IsExecutableWithExports()) {
|
||||
std::ostringstream e;
|
||||
e << "Target \"" << lib << "\" of type "
|
||||
<< cmState::GetTargetTypeName(tgt->GetType())
|
||||
<< " may not be linked into another target. "
|
||||
<< "One may link only to STATIC or SHARED libraries, or "
|
||||
<< "to executables with the ENABLE_EXPORTS property set.";
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
}
|
||||
|
||||
this->Target->AddLinkLibrary(*this->Makefile, lib, llt);
|
||||
return false;
|
||||
}
|
||||
|
||||
cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(lib);
|
||||
|
||||
if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::UNKNOWN_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
|
||||
!tgt->IsExecutableWithExports()) {
|
||||
std::ostringstream e;
|
||||
e << "Target \"" << lib << "\" of type "
|
||||
<< cmState::GetTargetTypeName(tgt->GetType())
|
||||
<< " may not be linked into another target. "
|
||||
<< "One may link only to STATIC or SHARED libraries, or "
|
||||
<< "to executables with the ENABLE_EXPORTS property set.";
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
}
|
||||
|
||||
this->Target->AddLinkLibrary(*this->Makefile, lib, llt);
|
||||
|
||||
if (this->CurrentProcessingState == ProcessingLinkLibraries) {
|
||||
this->Target->AppendProperty(
|
||||
"INTERFACE_LINK_LIBRARIES",
|
||||
|
||||
Reference in New Issue
Block a user