Allow target_link_libraries with IMPORTED targets.
This makes it possible to use: target_link_libraries(foo LINK_INTERFACE_LIBRARIES bar) where foo is an IMPORTED target. Other tll() signatures are not allowed.
This commit is contained in:
parent
97758f2920
commit
9cfe4f1b76
|
@ -33,6 +33,10 @@ bool cmTargetLinkLibrariesCommand
|
||||||
this->Target =
|
this->Target =
|
||||||
this->Makefile->GetCMakeInstance()
|
this->Makefile->GetCMakeInstance()
|
||||||
->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
|
->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
|
||||||
|
if(!this->Target)
|
||||||
|
{
|
||||||
|
this->Target = this->Makefile->FindTargetToUse(args[0].c_str());
|
||||||
|
}
|
||||||
if(!this->Target)
|
if(!this->Target)
|
||||||
{
|
{
|
||||||
cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
|
cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
|
||||||
|
@ -257,6 +261,16 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
|
||||||
// Handle normal case first.
|
// Handle normal case first.
|
||||||
if(this->CurrentProcessingState != ProcessingLinkInterface)
|
if(this->CurrentProcessingState != ProcessingLinkInterface)
|
||||||
{
|
{
|
||||||
|
if (this->Target->IsImported())
|
||||||
|
{
|
||||||
|
cmOStringStream e;
|
||||||
|
e << "Imported targets may only be used with the "
|
||||||
|
"LINK_INTERFACE_LIBRARIES specifier to target_link_libraries.";
|
||||||
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this->Makefile
|
this->Makefile
|
||||||
->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
|
->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
|
||||||
if (this->CurrentProcessingState != ProcessingPublicInterface)
|
if (this->CurrentProcessingState != ProcessingPublicInterface)
|
||||||
|
|
|
@ -29,6 +29,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
add_library(depA SHARED depA.cpp)
|
add_library(depA SHARED depA.cpp)
|
||||||
generate_export_header(depA)
|
generate_export_header(depA)
|
||||||
|
|
||||||
|
add_library(importedlib UNKNOWN IMPORTED)
|
||||||
|
target_link_libraries(importedlib LINK_INTERFACE_LIBRARIES depA)
|
||||||
|
|
||||||
add_library(depB SHARED depB.cpp)
|
add_library(depB SHARED depB.cpp)
|
||||||
generate_export_header(depB)
|
generate_export_header(depB)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue