From 9b449e9c5d79465a807c052c6707e83a1df9efbc Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Aug 2015 09:56:54 -0400 Subject: [PATCH] cmComputeLinkInformation: Lookup a target only if we have one The change in commit 27252b24 (cmComputeLinkInformation: Simplify generator object access, 2015-08-02) broke the conditional use of a target introduced in commit 41abdc17 (cmGeneratorTarget: Move GetSOName from cmTarget, 2015-08-04). Restore the conditional lookup. Add a test case that hacks platform information variables to trigger this code everywhere. --- Source/cmComputeLinkInformation.cxx | 2 +- .../RunCMake/target_link_libraries/RunCMakeTest.cmake | 1 + .../target_link_libraries/SharedDepNotTarget.cmake | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c16472ef5..32f5d684d 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -760,7 +760,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = 0; // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 533c6a15e..8307607bc 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -7,3 +7,4 @@ run_cmake(CMP0023-NEW-2) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) run_cmake(SubDirTarget) +run_cmake(SharedDepNotTarget) diff --git a/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake new file mode 100644 index 000000000..bab537edb --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake @@ -0,0 +1,10 @@ +enable_language(C) +set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") +add_library(imported SHARED IMPORTED) +set_target_properties(imported PROPERTIES + IMPORTED_LOCATION "imported" + IMPORTED_LINK_DEPENDENT_LIBRARIES "/path/to/libSharedDep.so" + ) +add_executable(empty empty.c) +target_link_libraries(empty imported)