Ensure we use RUNPATH for ovniver

As cmake doesn't provide a way to use the RPATH or the RUNPATH, we
explicitly set the --enable-new-dtags linker flag. If the flag is not
supported by the compiler, the build is aborted.
This commit is contained in:
Rodrigo Arias 2023-12-12 15:46:06 +01:00
parent 6d584c646c
commit bf2b4af15a

View File

@ -74,10 +74,18 @@ target_link_libraries(ovnisort emu parson-static ovni-static)
add_executable(ovnitop ovnitop.c) add_executable(ovnitop ovnitop.c)
target_link_libraries(ovnitop emu parson-static ovni-static) target_link_libraries(ovnitop emu parson-static ovni-static)
# For ovniver we need to ensure we use the RUNPATH not the RPATH.
include(CheckLinkerFlag)
check_linker_flag(C "-Wl,--enable-new-dtags" SUPPORT_ENABLE_NEW_DTAGS)
if (NOT SUPPORT_ENABLE_NEW_DTAGS)
message(FATAL_ERROR "Flag -Wl,--enable-new-dtags not supported, refusing to build ovniver")
endif()
add_executable(ovniver ovniver.c) add_executable(ovniver ovniver.c)
target_link_libraries(ovniver ovni) target_link_libraries(ovniver ovni)
set_property(TARGET ovniver set_property(TARGET ovniver
PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
target_link_options(ovniver PRIVATE "-Wl,--enable-new-dtags")
set(USE_MPI ON CACHE BOOL "Use MPI (required by ovnisync)") set(USE_MPI ON CACHE BOOL "Use MPI (required by ovnisync)")
if(USE_MPI) if(USE_MPI)