Skip to content

Commit b4e7d09

Browse files
committed
[CMake] Use RPATH_CHANGE instead RPATH_SET
RPATH_SET is not available until cmake 3.21.0. Use RPATH_CHANGE instead.
1 parent dc68773 commit b4e7d09

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cmake/modules/SetRPATH.cmake

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ function(swift_get_set_rpath_script_file out_var)
44
set(${out_var} "${SWIFT_SET_RPATH_SCRIPT_FILE}" PARENT_SCOPE)
55
endfunction()
66

7-
# Actual RPATH_SET operation to the file.
7+
# Actual RPATH_CHANGE operation to the file.
88
function(_swift_set_rpath_impl file new_rpath)
9-
# NOTE: RPATH_SET is not documented, and works only for ELF and XCOFF.
10-
file(RPATH_SET FILE "${file}" NEW_RPATH "${new_rpath}")
9+
execute_process(
10+
COMMAND readelf -Wd "${file}"
11+
COMMAND grep -Po "R(UN)?PATH.*\\[\\K[^\\]]*"
12+
OUTPUT_VARIABLE current_rpath
13+
)
14+
string(STRIP "${current_rpath}" current_rpath)
15+
16+
# NOTE: RPATH_CHANGE is not documented, and works only for ELF and XCOFF.
17+
file(RPATH_CHANGE FILE "${file}" OLD_RPATH "${current_rpath}" NEW_RPATH "${new_rpath}")
1118
endfunction()
1219

1320
# For 'cmake -P <scirpt>'.

0 commit comments

Comments
 (0)