diff --git a/cmake/Platform/Linux/Install_linux.cmake b/cmake/Platform/Linux/Install_linux.cmake index 08bb9f807e..b3e2093b65 100644 --- a/cmake/Platform/Linux/Install_linux.cmake +++ b/cmake/Platform/Linux/Install_linux.cmake @@ -6,4 +6,20 @@ # # -include(cmake/Platform/Common/Install_common.cmake) \ No newline at end of file +#! ly_install_code_function_override: Linux-specific copy function to handle RPATH fixes +set(ly_copy_template [[ +function(ly_copy source_file target_directory) + file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + get_filename_component(target_filename_ext "${source_file}" LAST_EXT) + if("${source_file}" MATCHES "qt/plugins" AND "${target_filename_ext}" STREQUAL ".so") + get_filename_component(target_filename "${source_file}" NAME) + file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..") + endif() +endfunction()]]) + +function(ly_install_code_function_override) + string(CONFIGURE "${ly_copy_template}" ly_copy_function_linux @ONLY) + install(CODE "${ly_copy_function_linux}") +endfunction() + +include(cmake/Platform/Common/Install_common.cmake)