target_link_libraries: Allow linking to UNKNOWN IMPORTED GLOBAL libs

This combination was accidentally rejected.  Allow it and add a test.

Fixes: #17245
This commit is contained in:
Brad King 2017-08-31 13:04:34 -04:00
parent 4f96641ba2
commit a47a853376
3 changed files with 6 additions and 0 deletions

View File

@ -366,6 +366,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& 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;

View File

@ -10,3 +10,4 @@ run_cmake(SubDirTarget)
run_cmake(SharedDepNotTarget)
run_cmake(StaticPrivateDepNotExported)
run_cmake(StaticPrivateDepNotTarget)
run_cmake(UNKNOWN-IMPORTED-GLOBAL)

View File

@ -0,0 +1,4 @@
enable_language(C)
add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL)
add_library(mylib empty.c)
target_link_libraries(mylib UnknownImportedGlobal)