Fix RPATH issues for qt/plugin binaries (#2018)
- Add special handling for shared objects copied from qt/plugins to correct the RPATH to reflect destination folder Signed-off-by: spham-amzn <spham@amazon.com>
This commit is contained in:
@@ -5,5 +5,5 @@
|
||||
#
|
||||
#
|
||||
|
||||
set(LY_RUNTIME_DEPENDENCIES_TEMPLATE ${LY_ROOT_FOLDER}/cmake/Platform/Common/runtime_dependencies_common.cmake.in)
|
||||
set(LY_RUNTIME_DEPENDENCIES_TEMPLATE ${LY_ROOT_FOLDER}/cmake/Platform/Linux/runtime_dependencies_linux.cmake.in)
|
||||
include(cmake/Platform/Common/RuntimeDependencies_common.cmake)
|
||||
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of "if(NOT ${same_location})"
|
||||
|
||||
function(ly_copy source_file target_directory)
|
||||
get_filename_component(target_filename "${source_file}" NAME)
|
||||
get_filename_component(target_filename_ext "${source_file}" LAST_EXT)
|
||||
cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location)
|
||||
if(NOT ${same_location})
|
||||
file(LOCK ${target_directory}/${target_filename}.lock GUARD FUNCTION TIMEOUT 300)
|
||||
if("${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}")
|
||||
file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
|
||||
|
||||
# Special case, shared libraries that are copied from qt/plugins have their RPATH set to \$ORIGIN/../../lib
|
||||
# which is the correct relative path based on the source location. But when we copy it to their subfolder,
|
||||
# the rpath needs to be adjusted to the parent ($ORIGIN/..)
|
||||
if("${source_file}" MATCHES "qt/plugins" AND "${target_filename_ext}" STREQUAL ".so")
|
||||
file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@LY_COPY_COMMANDS@
|
||||
Reference in New Issue
Block a user