Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Dont clear executable runtime path when installing #2454

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

erlingrj
Copy link
Collaborator

@erlingrj erlingrj commented Jan 5, 2025

While messing around with https://github.com/lf-lang/mujoco-c I was struggling with linking with an external shared object and the final LF binary not finding the shared library. It turns out that CMake by default clears the runtime path (RPATH) of an executable when it is installed (cmake --target install), so the binaries found in src-gen/MyApp/build/MyApp would run and find the shared object, but not the binary that was put in bin.

This PR sets a CMake variable to disable this clearing of the RPATH. I cannot say I fully understand why this is the default behavior of CMake and if there are any pitfalls of disabling it. Maybe @tanneberger knows something?

@erlingrj erlingrj added enhancement Enhancement of existing feature c Related to C target cmake labels Jan 5, 2025
@erlingrj erlingrj requested a review from edwardalee January 5, 2025 18:39
Copy link
Collaborator

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change (as with most cmake magic), but I don't see any potential harm.

@erlingrj erlingrj added this pull request to the merge queue Jan 6, 2025
Merged via the queue into master with commit 35ebba7 Jan 6, 2025
23 checks passed
@erlingrj erlingrj deleted the cmake-dont-clear-rpath branch January 6, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c Related to C target cmake enhancement Enhancement of existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants