Skip to content

Commit 4bfbfe9

Browse files
committed
[build][android] set INSTALL_RPATH properly for shared libraries
Host libraries will likely all need ORIGIN set, whereas only set it for target libraries that will be packaged with a native toolchain on Android.
1 parent 270f734 commit 4bfbfe9

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -628,14 +628,9 @@ function(_add_swift_host_library_single target)
628628
PROPERTIES
629629
INSTALL_RPATH "$ORIGIN:/usr/lib/swift/cygwin")
630630
elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID")
631-
# Only set the install RPATH if cross-compiling the host tools, in which
632-
# case both the NDK and Sysroot paths must be set.
633-
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "" AND
634-
NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
635-
set_target_properties("${target}"
636-
PROPERTIES
637-
INSTALL_RPATH "$ORIGIN")
638-
endif()
631+
set_target_properties("${target}"
632+
PROPERTIES
633+
INSTALL_RPATH "$ORIGIN")
639634
endif()
640635

641636
set_target_properties("${target}" PROPERTIES BUILD_WITH_INSTALL_RPATH YES)

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,9 @@ function(_add_swift_target_library_single target name)
527527
if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
528528
set_target_properties("${target}" PROPERTIES NO_SONAME TRUE)
529529
endif()
530-
# Only set the install RPATH if cross-compiling the host tools, in which
531-
# case both the NDK and Sysroot paths must be set.
532-
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "" AND
533-
NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
530+
# Only set the install RPATH if the toolchain and stdlib will be in Termux
531+
# or some other native sysroot on Android.
532+
if(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
534533
set_target_properties("${target}"
535534
PROPERTIES
536535
INSTALL_RPATH "$ORIGIN")

0 commit comments

Comments
 (0)