Set install_name and rpath at link time on macOS - #334
Open
OlafRocket wants to merge 1 commit into
Open
Conversation
The bundle relied on post-build and post-install install_name_tool passes to rewrite library ids and add rpaths. Those ran after codesigning had already happened during macdeployqt, invalidating the signatures they touched. Set the properties at configure time instead, so the linker emits the right paths and no rewriting is needed: - INSTALL_NAME_DIR "@rpath" with BUILD_WITH_INSTALL_NAME_DIR makes internal libraries self-identify as @rpath/libfoo.dylib, replacing the install_name_tool -id pass. - INSTALL_RPATH plus additive BUILD_RPATH on both the libraries and the executable. BUILD_RPATH keeps CMake's linker-derived paths alongside @executable_path/../Frameworks, so build/xSTUDIO.app runs on a fresh checkout without a preceding install. macdeployqt strips the extra rpath on install, leaving the shipped bundle unchanged. Drop the now-redundant fixup_macos_bundle.cmake and the install_name_tool calls in macdeploy.cmake.in, and remove the per-target rpath block in src/global that macros.cmake now covers. Pass -always-overwrite to macdeployqt so a stale bundle from a prior install cannot leave frameworks unsigned. Also document the incremental build workflow in the macOS build guide: after an initial install, cmake --build alone relinks in seconds. Signed-off-by: Olaf <8780533+OlafRocket@users.noreply.github.com>
OlafRocket
force-pushed
the
fix/macos-bundle-rpath
branch
from
September 4, 2026 15:22
f29a868 to
759bb4c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summarize your change.
Set macOS install_name and rpath at link time via CMake target properties, and remove the post-build and post-install install_name_tool passes that previously patched the bundle after the fact.
Describe the reason for the change.
The bundle relied on install_name_tool running after the fact to rewrite library ids and add rpaths. Those passes ran after codesigning had already happened during macdeployqt, invalidating the signatures of every binary they touched.
Setting the paths at configure time means the linker emits them directly, so there is nothing left to rewrite and nothing to invalidate.
A second benefit: using additive BUILD_RPATH rather than BUILD_WITH_INSTALL_RPATH keeps CMake's linker-derived paths in the build-tree binaries. build/xSTUDIO.app now launches from a fresh checkout without a preceding install step, which makes iterating on source changes much faster.
Describe what you have tested and on which operating system.
Built on Mac Air M1, MacOS Sequoia 15.7.4
Add a list of changes, and note any that might need special attention during the review.
cmake/macros.cmake — internal libraries gain INSTALL_NAME_DIR "@rpath" with BUILD_WITH_INSTALL_NAME_DIR, plus INSTALL_RPATH and additive BUILD_RPATH.
src/launch/xstudio/src/CMakeLists.txt — the executable gains the same INSTALL_RPATH / BUILD_RPATH pair; drops the fixup_macos_bundle.cmake post-build command.
src/launch/xstudio/src/fixup_macos_bundle.cmake — deleted, now redundant.
src/launch/xstudio/src/macdeploy.cmake.in — drops the install_name_tool -id / -change calls; passes -always-overwrite to macdeployqt so a stale bundle from a prior install cannot leave frameworks unsigned.
src/global/src/CMakeLists.txt — removes the per-target APPLE rpath block now covered by macros.cmake.
docs/reference/build_guides/macos.md — documents the incremental build workflow.
Notes for review:
BUILD_RPATH is additive, whereas BUILD_WITH_INSTALL_RPATH TRUE would replace CMake's computed build rpath. The additive form is deliberate: it is what allows the build-tree bundle to find Qt and other external dependencies before macdeployqt has copied them in. macdeployqt strips the extra rpath on install, so the shipped bundle is unchanged.
Libraries and the executable are configured consistently; INSTALL_NAME_DIR applies only to the libraries because executables have no install name.
The docs change is included here because the fast-iteration workflow it describes is only possible as a result of this change.
macOS-only. Linux and Windows paths are untouched.