-
Notifications
You must be signed in to change notification settings - Fork 11
RPATH for targets #189
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
base: master
Are you sure you want to change the base?
RPATH for targets #189
Conversation
CMakeLists.txt
Outdated
| ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} | ||
| ) | ||
| set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/${relDirRInstallPath}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What sets ORIGIN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It points to the binary/library directory and doesn't need to be set. More here: https://stackoverflow.com/questions/77347280/what-is-the-origin-token-in-cmake
CMakeLists.txt
Outdated
| if(${PROJECT_NAME}_ENABLE_GNUINSTALLDIRS) # for GNUInstallDirs | ||
| file(RELATIVE_PATH relDirRInstallPath | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} | ||
| ) | ||
| set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/${relDirRInstallPath}) | ||
| else() | ||
| # not robust | ||
| set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/../lib64 $ORIGIN/../lib) | ||
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be best to put this logic into cmake/bob.cmake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Thanks.
| "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) | ||
| if("${isSystemDir}" STREQUAL "-1") | ||
| set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" PARENT_SCOPE) | ||
| set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" "${CMAKE_INSTALL_PREFIX}/lib64" PARENT_SCOPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the lib64 here solved the issue. @cwsmith, is it fine? Or, is there any better way to do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bob.cmake will set BOB_LIB_DESTINATION based on whether or not GNUInstallDirs is enabled (default is on... I've never seen a build with it off...):
Lines 77 to 90 in e8fe57b
| option(${PROJECT_NAME}_ENABLE_GNUINSTALLDIRS "Use the GNUInstallDirs install dir paths" TRUE) | |
| include(GNUInstallDirs) | |
| if(${PROJECT_NAME}_ENABLE_GNUINSTALLDIRS) | |
| set(BOB_LIB_DESTINATION ${CMAKE_INSTALL_LIBDIR}) | |
| set(BOB_BIN_DESTINATION ${CMAKE_INSTALL_BINDIR}) | |
| else() | |
| if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | |
| set(BOB_LIB_DESTINATION "bin") | |
| set(BOB_BIN_DESTINATION "bin") | |
| else() | |
| set(BOB_LIB_DESTINATION "lib") | |
| set(BOB_BIN_DESTINATION "bin") | |
| endif() | |
| endif() |
Given that, I think it would be best to do the following:
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${BOB_LIB_DESTINATION}" PARENT_SCOPE)
Can you give this a shot to see if it works as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it. Just checked again. It does not add the lib64 or even lib as RPATH in the binary. Here's the RPATH the installed binary has
Library rpath: [/opt/scorec/spack/rhel9/v0201_4/install/linux-rhel9-x86_64/gcc-7.4.0/gcc-12.3.0-iil3lnovyknyxf7pec36wljem3fntjd5/lib64:/users/hasanm4/lore/wsources/omega_h/build-kokkos/install/:/users/hasanm4/lore/wsources/omega_h/kokkos/build-omp/install/lib64:/opt/scorec/spack/rhel9/v0201_4/install/linux-rhel9-x86_64/gcc-12.3.0/zlib-1.2.13-mjocrm2cwyth6kvpmj3yrg52ulwd64ow/lib]
I have added
INSTALL_RPATHso that the utilities do not needLD_LIBRARY_PATHset to point to the lib directory.