mirror of https://github.com/microsoft/vcpkg.git
[vcpkg-scripts] z_vcpkg_fixup_macho_rpath_in_dir: Call install_name_tool only once (#39995)
This commit is contained in:
parent
a2938d0e28
commit
a68201b181
|
|
@ -110,14 +110,14 @@ function(z_vcpkg_fixup_macho_rpath_in_dir)
|
|||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE set_id_error
|
||||
)
|
||||
message(STATUS "Set install name id of '${macho_file}' (To '@rpath/${macho_file_name}')")
|
||||
message(STATUS "Set install name id of '${macho_file}' to '@rpath/${macho_file_name}'")
|
||||
if(NOT "${set_id_error}" STREQUAL "")
|
||||
message(WARNING "Couldn't adjust install name of '${macho_file}': ${set_id_error}")
|
||||
continue()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Clear all existing rpaths
|
||||
# List all existing rpaths
|
||||
execute_process(
|
||||
COMMAND "${otool_cmd}" -l "${macho_file}"
|
||||
OUTPUT_VARIABLE get_rpath_ov
|
||||
|
|
@ -132,18 +132,23 @@ function(z_vcpkg_fixup_macho_rpath_in_dir)
|
|||
string(REGEX MATCHALL "rpath [^\n]+" get_rpath_ov "${get_rpath_ov}")
|
||||
string(REGEX REPLACE "rpath " "" rpath_list "${get_rpath_ov}")
|
||||
|
||||
list(FIND rpath_list "${new_rpath}" has_new_rpath)
|
||||
if(NOT has_new_rpath EQUAL -1)
|
||||
list(REMOVE_AT rpath_list ${has_new_rpath})
|
||||
set(rpath_args)
|
||||
else()
|
||||
set(rpath_args -add_rpath "${new_rpath}")
|
||||
endif()
|
||||
foreach(rpath IN LISTS rpath_list)
|
||||
execute_process(
|
||||
COMMAND "${install_name_tool_cmd}" -delete_rpath "${rpath}" "${macho_file}"
|
||||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE delete_rpath_error
|
||||
)
|
||||
message(STATUS "Remove RPATH from '${macho_file}' ('${rpath}')")
|
||||
list(APPEND rpath_args "-delete_rpath" "${rpath}")
|
||||
endforeach()
|
||||
if(rpath_args STREQUAL "")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Set the new rpath
|
||||
execute_process(
|
||||
COMMAND "${install_name_tool_cmd}" -add_rpath "${new_rpath}" "${macho_file}"
|
||||
COMMAND "${install_name_tool_cmd}" ${rpath_args} "${macho_file}"
|
||||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE set_rpath_error
|
||||
)
|
||||
|
|
@ -153,7 +158,7 @@ function(z_vcpkg_fixup_macho_rpath_in_dir)
|
|||
continue()
|
||||
endif()
|
||||
|
||||
message(STATUS "Adjusted RPATH of '${macho_file}' (To '${new_rpath}')")
|
||||
message(STATUS "Adjusted RPATH of '${macho_file}' to '${new_rpath}'")
|
||||
endforeach()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
|
|
|||
Loading…
Reference in New Issue