From 2d92f08ebddbc5fde82157aac7c291cfe0f18ec4 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de> Date: Tue, 16 Apr 2024 17:39:02 +0200 Subject: [PATCH] target_link_options instead of setting property --- App/CMakeLists.txt | 15 ++++++--------- cmake/BornAgain/MakeLib.cmake | 11 ++++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 7eeb2d25c1f..f8716dd0fe5 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -59,8 +59,8 @@ if(WIN32) endif() if(LINUX) - set(link_flags "-Wl,--disable-new-dtags,-rpath,\$ORIGIN/../lib") - set_target_properties(${executable_name} PROPERTIES LINK_OPTIONS ${link_flags}) + target_link_options(${executable_name} PRIVATE + "-Wl,--disable-new-dtags,-rpath=\$ORIGIN/../lib") endif() if(APPLE) @@ -71,14 +71,11 @@ if(APPLE) PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${BUILD_VAR_DIR}/Info.plist) if(BA_APPLE_BUNDLE) - set(link_flags - "-Wl,-rpath,@loader_path/../lib -Wl,-rpath,@loader_path/../Frameworks/ \ --Wl,-rpath,@loader_path/../lib/BornAgain-${PROJECT_VERSION}/") - else() - set(link_flags "-Wl,-rpath,\ -@loader_path/../../../lib/BornAgain-${PROJECT_VERSION}/") + target_link_options(${executable_name} PRIVATE + "-Wl,-rpath,@loader_path/../lib:@loader_path/../Frameworks") endif() - set_target_properties(${executable_name} PROPERTIES LINK_OPTIONS ${link_flags}) + target_link_options(${executable_name} PRIVATE + "-Wl,-rpath,@loader_path/../../../lib/BornAgain-${PROJECT_VERSION}") endif() # ----------------------------------------------------------------------------- diff --git a/cmake/BornAgain/MakeLib.cmake b/cmake/BornAgain/MakeLib.cmake index 26263ba0c2e..c6db5cc5934 100644 --- a/cmake/BornAgain/MakeLib.cmake +++ b/cmake/BornAgain/MakeLib.cmake @@ -68,17 +68,18 @@ function(MakeLib lib) get_target_property(lib_dir ${lib} LIBRARY_OUTPUT_DIRECTORY) get_target_property(lib_name ${lib} _BASEFILENAME) - set(BornAgain_LIBRARIES "$CACHE{BornAgain_LIBRARIES};${lib_dir}/${lib_name}" CACHE INTERNAL "BornAgain libraries") + set(BornAgain_LIBRARIES "$CACHE{BornAgain_LIBRARIES};${lib_dir}/${lib_name}" + CACHE INTERNAL "BornAgain libraries") # Set runtime-location of library dependencies if(LINUX) - set(link_flags "-Wl,--disable-new-dtags,-rpath,\$ORIGIN:\$ORIGIN/extra") - set_target_properties(${lib} PROPERTIES LINK_OPTIONS ${link_flags}) + target_link_options(${lib} PRIVATE + "-Wl,--disable-new-dtags,-rpath,\$ORIGIN:\$ORIGIN/extra") endif() if(APPLE AND (BA_APPLE_BUNDLE OR BA_WHEEL)) - set(link_flags "-Wl,-rpath,@loader_path -Wl,-rpath,@loader_path/extra") - set_target_properties(${lib} PROPERTIES LINK_OPTIONS ${link_flags}) + target_link_options(${lib} PRIVATE + "-Wl,-rpath,@loader_path:@loader_path/extra") endif() -- GitLab