-
Notifications
You must be signed in to change notification settings - Fork 10
Description
When MSTK is built as a shared library via cmake, and then installed, it loses its RPATHs. This results in, e.g.:
$> ldd libmstk
linux-vdso.so.1 (0x00007ffe4b385000)
libexodus.so.2 => not found
libmetis.so => /home/uec/codes/ats/amanzi-tpls/install-master/relwithdebinfo/lib/libmetis.so (0x00007f3a8cacb000)
...
I have to admit, I have no clue why some things end up sticking (e.g. metis) and some don't (e.g. SEACAS). It is possibly because libmstk got installed in the same directory as libmetis.so.
Adding the following magic cmake to your CMakeLists.txt seems to fix this. We had to do the same to Amanzi to get Trilinos and other not-in-the-same-install-path libraries to keep their rpaths so we don't have to set LD_LIBRARY_PATH to get things to run.
# shared libraries tweaks: enforcing absolute path
if (BUILD_SHARED_LIBS)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_RPATH}")
else()
SET(CMAKE_SKIP_INSTALL_RPATH ON CACHE BOOL "Turn off for static install." FORCE)
SET(CMAKE_SKIP_RPATH ON CACHE BOOL "Turn off for static install." FORCE)
endif()
After adding this to MSTK's CMakeList.txt, I get:
$> ldd libmstk.so
linux-vdso.so.1 (0x00007ffcfe393000)
libexodus.so.2 => /home/uec/codes/ats/amanzi-tpls/install-master/relwithdebinfo/SEACAS/lib/libexodus.so.2 (0x00007f16837cb000)
libmetis.so => /home/uec/codes/ats/amanzi-tpls/install-master/relwithdebinfo/lib/libmetis.so (0x00007f1683761000)
...
And so I can run meshconvert etc without setting the LD_LIBARY_PATH explicitly.
Would you be willing to add something like this to MSTK or should I patch it in Amanzi?