Reputation: 9428
On the question CMAKE RPATH not working - could not find shared object file I see how to set CMAKE_INSTALL_RPATH
for a single path, but I need it for multiple paths. I tried these using but I did not worked:
SET( CMAKE_INSTALL_RPATH "/opt/my/lib;/other/lib" )
SET( CMAKE_INSTALL_RPATH "/opt/my/lib:/other/lib" )
On the question How to set multiple RPATH directories using CMake on MacOS I see I can set multiple paths with semicolon ;
for a target, but I would like to set it for all targets instead of setting it for each one. Is there a equivalent of set_target_properties
for all targets (including subprojects) ? For example:
set_target_properties(alltargets
PROPERTIES
INSTALL_RPATH "/opt/my/lib;/other/lib"
)
Upvotes: 3
Views: 3583
Reputation: 9428
After testing, it seems the first option using semicolons as separator is working SET( CMAKE_INSTALL_RPATH "/opt/my/lib;/other/lib" )
. For reference, there is the cmake documentation, but I did not found this answer there: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
The thing I do not know about is how I can use something like set_target_properties
for all my alltargets
automatically.
Upvotes: 0
Reputation: 9291
Snippet:
# note: macOS is APPLE and also UNIX !
if(APPLE)
set_target_properties(foo PROPERTIES
INSTALL_RPATH "@loader_path;@loader_path/...")
elseif(UNIX)
set_target_properties(foo PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/...")
endif()
Related CMake variable:
Related CMP:
Upvotes: 5