Skip to content

Commit c39f95b

Browse files
committed
[CMake] Use RPATH_CHANGE instead RPATH_SET
RPATH_SET is not available until cmake 3.21.0. Use RPATH_CHANGE instead. (cherry picked from commit f645069)
1 parent 1e7c84a commit c39f95b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cmake/modules/SetRPATH.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ 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+
# FIXME: Handle non-ELF files. We can't use RPATH_SET because it's only available CMake 3.21.0
10+
execute_process(
11+
COMMAND readelf -Wd "${file}"
12+
COMMAND grep -Po "R(UN)?PATH.*\\[\\K[^\\]]*"
13+
OUTPUT_VARIABLE current_rpath
14+
)
15+
string(STRIP "${current_rpath}" current_rpath)
16+
17+
# NOTE: RPATH_CHANGE is not documented, and works only for ELF and XCOFF.
18+
file(RPATH_CHANGE FILE "${file}" OLD_RPATH "${current_rpath}" NEW_RPATH "${new_rpath}")
1119
endfunction()
1220

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

0 commit comments

Comments
 (0)