From a47a853376184031051ed744ed4718a69876002d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 31 Aug 2017 13:04:34 -0400 Subject: [PATCH] target_link_libraries: Allow linking to UNKNOWN IMPORTED GLOBAL libs This combination was accidentally rejected. Allow it and add a test. Fixes: #17245 --- Source/cmTargetLinkLibrariesCommand.cxx | 1 + Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake | 1 + .../target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake | 4 ++++ 3 files changed, 6 insertions(+) create mode 100644 Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index bfae53c798..d146640031 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -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; diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 1466fbf61d..b1c943505b 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -10,3 +10,4 @@ run_cmake(SubDirTarget) run_cmake(SharedDepNotTarget) run_cmake(StaticPrivateDepNotExported) run_cmake(StaticPrivateDepNotTarget) +run_cmake(UNKNOWN-IMPORTED-GLOBAL) diff --git a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake new file mode 100644 index 0000000000..f52fa30bc8 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake @@ -0,0 +1,4 @@ +enable_language(C) +add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) +add_library(mylib empty.c) +target_link_libraries(mylib UnknownImportedGlobal)