Skip to content

Conversation

@Fuad-HH
Copy link

@Fuad-HH Fuad-HH commented Nov 27, 2025

I have added INSTALL_RPATH so that the utilities do not need LD_LIBRARY_PATH set to point to the lib directory.

CMakeLists.txt Outdated
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
)
set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/${relDirRInstallPath})
Copy link

Choose a reason for hiding this comment

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

What sets ORIGIN?

Copy link
Author

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
Comment on lines 182 to 191
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()
Copy link

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.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense. Thanks.

bob handles rpath but hardcodes to lib whereas for shared libs the libs are installed in lib64. lib64 is added
"${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)
Copy link
Author

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?

Copy link

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...):

omega_h/cmake/bob.cmake

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?

Copy link
Author

@Fuad-HH Fuad-HH Dec 3, 2025

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants