Short version
Why is RPATH disabled in CMake by default?
Background
I want to include a dylib file in my plugin and it is present as a bundle resource.
However, on runtime the app is looking into the hardcoded build directory, so if I move the app to another computer, it will complain about missing .dylib.
I found two ways to do this:
1.
CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/../Resources"
But this is an XCode specific flag and it does not feel like a clean solution.
2.
set_property(TARGET ${PROJECT_NAME}_${format} PROPERTY BUILD_RPATH "@loader_path/../Resources" )
AND
set(CMAKE_SKIP_RPATH "NO" CACHE INTERNAL "")
The end goal boils down to these results of running otool -l:
Working
Load command 39
cmd LC_RPATH
cmdsize 40
path @loader_path/…/Resources (offset 12)
Broken
Load command 39
cmd LC_RPATH
cmdsize 64
path /Users/xxx/Dev/git/xxxx/Libraries (offset 12)
So why do I have to force RPATH to be used?
Am I missing something? Is there a cleaner way of doing this?