How do we set multiple RPATH directories on a target in CMake on MacOS? On Linux, we can just use a colon-separated list:
set_target_properties(mytarget
PROPERTIES
INSTALL_RPATH "\$ORIGIN/../lib:\$ORIGIN/../thirdparty/lib"
)
On MacOS, we can technically add a colon separated list and otool -l
should show it, but these directories aren't searched:
set_target_properties(mytarget
PROPERTIES
INSTALL_RPATH "@loader_path/../lib:@loader_path/../thirdparty/lib"
)
Normally, if I were going to have multiple RPATH directories on MacOS, I'd send multiple linker flags, and these flags would show up separately with otool -l
. Something like:
g++-mp-4.7 mytarget.cpp -o mytarget -Wl,-rpath,@loader_path/../lib,-rpath,@loader_path/../thirdparty/lib
Which gives:
Load command 15
cmd LC_RPATH
cmdsize 32
path @loader_path/../lib (offset 12)
Load command 16
cmd LC_RPATH
cmdsize 48
path @loader_path/../thirdparty/lib (offset 12)
How do I recreate this behavior with CMake?