From 78654ee2e151629a6346e758abc895aaec056a5a Mon Sep 17 00:00:00 2001 From: Jordan Date: Thu, 13 Aug 2026 13:22:53 -0700 Subject: [PATCH] Keep build-machine paths out of the Linux RUNPATH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CMakeLists already asked for $ORIGIN, but CMake prepends it to the automatic build-tree RPATH rather than replacing it: because the target links libCr_Core and the OpenCV libs by absolute path, their source-tree directories were appended and shipped inside the binary. Those entries were pure redundancy — POST_BUILD already copies every runtime lib next to the executable, so $ORIGIN alone resolves everything. Their only real effect was to let the loader fall back to the build machine's checkout, which is how the missing OpenCV in the .mcpb (#33) stayed invisible: the bundle tested fine on the machine that built it and failed with exit 127 everywhere else. BUILD_WITH_INSTALL_RPATH makes the build-tree link use INSTALL_RPATH directly and skips the automatic computation, leaving RUNPATH as just $ORIGIN. macOS is left alone — it likely has the same leak, but there is no hardware here to verify it and the CrAdapter layout there is delicate. Fixes #52 Co-Authored-By: Claude Opus 4.6 --- api/server/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/server/CMakeLists.txt b/api/server/CMakeLists.txt index b9050ef..9a74172 100644 --- a/api/server/CMakeLists.txt +++ b/api/server/CMakeLists.txt @@ -86,9 +86,15 @@ if(APPLE) BUILD_RPATH "@executable_path" ) elseif(UNIX) + # Every runtime lib is copied next to the executable below (POST_BUILD), so + # $ORIGIN alone resolves everything — in the build tree and in the .mcpb. + # BUILD_WITH_INSTALL_RPATH stops CMake appending the linked libraries' + # absolute source-tree directories to the build RPATH; those would ship in + # the binary and let it silently fall back to the build machine's checkout, + # masking libs missing from the bundle. set_target_properties(${WEBAPP_TARGET} PROPERTIES - BUILD_RPATH "$ORIGIN" INSTALL_RPATH "$ORIGIN" + BUILD_WITH_INSTALL_RPATH TRUE ) endif()