From 4a9961d8cf2feee533979cd8f58fe53906cf03cc Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Tue, 10 Sep 2024 12:16:36 +0200 Subject: [PATCH] Set RPATH for the loader (#550) --- docs/building_and_running_tests.rst | 3 --- docs/using_onemkl_with_cmake.rst | 12 ------------ src/CMakeLists.txt | 4 ++++ 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/docs/building_and_running_tests.rst b/docs/building_and_running_tests.rst index 43d3431af..114e4492d 100644 --- a/docs/building_and_running_tests.rst +++ b/docs/building_and_running_tests.rst @@ -46,6 +46,3 @@ To run the tests, either run test binaries individually, or use ``ctest`` CMake For more ``ctest`` options, refer to `ctest manual page `_. -When running tests you may encounter the issue ``BACKEND NOT FOUND EXCEPTION``, -you may need to add your ``/lib`` to your -``LD_LIBRARY_PATH`` on Linux. diff --git a/docs/using_onemkl_with_cmake.rst b/docs/using_onemkl_with_cmake.rst index 5fb497362..03f828bf4 100644 --- a/docs/using_onemkl_with_cmake.rst +++ b/docs/using_onemkl_with_cmake.rst @@ -50,12 +50,6 @@ during the build. To check for the existence of backends, CMake's ``if(TARGET message(FATAL_ERROR "oneMKL Interfaces was not built with CuFFT backend") endif() - -If oneMKL Interfaces has been installed to a non-standard location, the -operating system may not find the backend libraries when they're lazily loaded -at runtime. To make sure they're found you may need to set -``LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH`` on Linux. - .. _using_with_fetchcontent: Using CMake's FetchContent @@ -93,10 +87,4 @@ against particular backends (as required for static dispatch of oneAPI calls to a particular backend), use the target ``onemkl__``. For example, ``onemkl_dft_cufft``. -When using the run-time dispatch mechanism, it is likely that the operating -system will not find the backend libraries when they're loaded at runtime. To -make sure they're found you may need to set -``LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH`` on Linux. - - .. _FetchContent: https://cmake.org/cmake/help/latest/module/FetchContent.html diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b632c1bd..0beadc3ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,10 @@ if(BUILD_SHARED_LIBS) set (ONEMKL_LIBS ${TARGET_DOMAINS}) list(TRANSFORM ONEMKL_LIBS PREPEND onemkl_) target_link_libraries(onemkl PUBLIC ${ONEMKL_LIBS}) + set_target_properties(onemkl PROPERTIES + INSTALL_RPATH "\$ORIGIN" + BUILD_WITH_INSTALL_RPATH TRUE + ) # Add the library to install package foreach(domain_lib ${ONEMKL_LIBS})