Fix rpath for private libraries on Linux
authorBenjamin Drung <benjamin.drung@canonical.com>
Thu, 22 Sep 2022 17:52:43 +0000 (19:52 +0200)
committerPeter Michael Green <plugwash@raspbian.org>
Tue, 25 Jun 2024 16:28:26 +0000 (16:28 +0000)
commit0c4d3a954c38b2d354b6d722b9c27f6c3ef098c8
tree66253f1716b676e2ce6db994fdf0ec0d3e2df54c
parente4230b3d97937e2b9c3e4ed6f3fdeda7c16b2e2f
Fix rpath for private libraries on Linux

Installing audacity on Linux will produce private libraries that have
`RUNPATH` set to the build directory instead of the installation
directory.

The root cause is that the library directory is copied to the
installation directory without touching the libraries. The cmake wiki
says in RPATH handling caveats [1]: "Since install-side RPATH tweaking
is an operation that is done by target-specific installation handling,
any target that should have its install RPATH changed (e.g. to
`CMAKE_INSTALL_RPATH`) needs to end up in the installation via an
`install(TARGETS ...)` signature and not via directory-based copying."

So replace `install(DIRECTORY ...)` by individual `install(TARGETS ...)`
for the libraries and modules. Then cmake will replace the `RUNPATH` to
`$ORIGIN/../lib/audacity`, which is still incorrect. Therefore set
`INSTALL_RPATH` explicitly.

Fixes: https://github.com/audacity/audacity/issues/3289
Forwarded: https://github.com/audacity/audacity/pull/3671
[1] https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#caveats
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Gbp-Pq: Name Fix-rpath-for-private-libraries-on-Linux.patch
CMakeLists.txt
cmake-proxies/cmake-modules/AudacityFunctions.cmake
modules/mod-script-pipe/CMakeLists.txt
src/CMakeLists.txt