Commit d75cad01 authored by Brad King's avatar Brad King
Browse files

Fix rpath-link for shared lib with only private deps

Under CMP0022 NEW behavior, the link interface is explicit even if there
are no public dependencies (`INTERFACE_LINK_LIBRARIES` is not set).
Mark it as such to activate our tracking of private runtime dependencies
of shared libraries for generation of `-rpath-link` flags.

Fixes: #19556
parent 4b2e1fc9
...@@ -5660,7 +5660,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( ...@@ -5660,7 +5660,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
return; return;
} }
iface.Exists = true; iface.Exists = true;
iface.Explicit = explicitLibraries != nullptr; iface.Explicit = cmp0022NEW || explicitLibraries != nullptr;
if (explicitLibraries) { if (explicitLibraries) {
// The interface libraries have been explicitly set. // The interface libraries have been explicitly set.
......
cmake_minimum_required (VERSION 2.6) cmake_minimum_required (VERSION 3.15)
project(RuntimePath C) project(RuntimePath C)
# Add a simple chain of shared libraries that must be found. # Add a simple chain of shared libraries that must be found.
...@@ -31,3 +31,14 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG) ...@@ -31,3 +31,14 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)
set_property(TARGET bar2 PROPERTY LIBRARY_OUTPUT_DIRECTORY A) set_property(TARGET bar2 PROPERTY LIBRARY_OUTPUT_DIRECTORY A)
target_link_libraries(bar2 foo2) target_link_libraries(bar2 foo2)
endif() endif()
# Add a library that is missing the rpath for its dependency.
add_library(bar1_no_rpath SHARED bar1.c)
set_property(TARGET bar1_no_rpath PROPERTY LIBRARY_OUTPUT_DIRECTORY B)
set_property(TARGET bar1_no_rpath PROPERTY SKIP_BUILD_RPATH 1)
target_link_libraries(bar1_no_rpath PRIVATE foo1)
# Add an executable linking to the library with a missing dependency rpath.
# CMake should generate the proper rpath-link flag to find it at build time.
add_executable(main_with_bar1_no_rpath main.c)
target_link_libraries(main_with_bar1_no_rpath bar1_no_rpath)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment