From df169c89c312f7dc586fbadf5f40edf4d39274bb Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Tue, 15 Nov 2022 10:12:59 +0100 Subject: [PATCH] Use RPATH for the MPI library --- src/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 30e8a2e..2875534 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,6 +50,13 @@ if(POLICY CMP0074) endif() find_package(MPI REQUIRED) + +if(NOT MPI_USE_RUNPATH) + # Ensure we use RPATH (not RUNPATH) to link with MPI library, so we are + # protected against LD_LIBRARY_PATH overrides. + target_link_options(MPI::MPI_C INTERFACE "LINKER:--disable-new-dtags") +endif() + add_executable(ovnisync ovnisync.c) target_link_libraries(ovnisync m MPI::MPI_C)