title: cmake: specifying the install relative path to imported shared library
body: <p>I would like to link against an imported shared library:</p>
  <pre><code>add_library(drivers SHARED IMPORTED)
  set_target_properties(
    drivers
    PROPERTIES IMPORTED_LOCATION
    ${CMAKE_CURRENT_SOURCE_DIR}/lib/libdrivers.so
    )
  </code></pre>
  <p>The library I would like to link against is a pybind11 binding library. I try to setup <code>rpath</code> so that libdrivers.so will be found in the same directory as the bindings library.</p>
  <pre><code>pybind11_add_module(pybind11_bindings MODULE srcpy/bindings.cpp)
  set_target_properties(pybind11_bindings PROPERTIES
      LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/myproject
      OUTPUT_NAME &quot;bindings&quot;
      SKIP_BUILD_RPATH FALSE
       BUILD_WITH_INSTALL_RPATH TRUE
    )
  target_link_libraries(pybind11_bindings
    PRIVATE drivers
    )
  set_target_properties(pybind11_bindings PROPERTIES 
  INSTALL_RPATH &quot;\$ORIGIN&quot;)
  set_target_properties(pybind11_bindings PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
  </code></pre>
  <p>Things are installed:</p>
  <pre><code>install(IMPORTED_RUNTIME_ARTIFACTS drivers
    LIBRARY DESTINATION ${PMYROJECT_INSTALL_PREFIX}
    COMPONENT bindings
    )
  
  install(
      TARGETS pybind11_bindings
      COMPONENT bindings
      LIBRARY DESTINATION ${MYPROJECT_INSTALL_PREFIX}
      ARCHIVE DESTINATION ${MYPROJECT_INSTALL_PREFIX}
      RUNTIME DESTINATION ${MYPROJECT_INSTALL_PREFIX}
      )
  </code></pre>
  <p>To complicate things a bit, this is part of a setuptools project installed with pip and using cmake-build-extension: <a href="https://github.com/diegoferigo/cmake-build-extension" rel="nofollow noreferrer">https://github.com/diegoferigo/cmake-build-extension</a></p>
  <p>After <code>pip install .</code> is called, the <code>site-packages</code> folder has the expected content, i.e. <code>site-packages/myproject</code> contains <code>bindings.cpython-38-x86_64-linux-gnu.so</code> and <code>libdrivers.so</code>.</p>
  <p>but:</p>
  <pre><code>ldd bindings.cpython-38-x86_64-linux-gnu.so
  </code></pre>
  <blockquote>
  <p>../../lib/libdrivers.so =&gt; not found</p>
  </blockquote>
  <p>Also:</p>
  <pre><code>objdump -x bindings.cpython-310-x86_64-linux-gnu.so | grep RPATH
  </code></pre>
  <p>does not provide any output !</p>
  <p>Instead, <code>objdump -x bindings.cpython-310-x86_64-linux-gnu.so</code> output:</p>
  <pre><code>Dynamic Section:
    NEEDED               ../../lib/libdrivers.so
  </code></pre>
  <p>does not show anything,so it does not seem the rpath has been set as desired. Anything I may be doing wrong ?</p>