Skip to content

build: delegate rpath handling to CMake #29453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2583,12 +2583,6 @@ function(_add_swift_executable_single name)
LINK_LIBRARIES_VAR_NAME link_libraries
LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories)

if(${SWIFTEXE_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
list(APPEND link_flags
"-Xlinker" "-rpath"
"-Xlinker" "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
endif()

_list_add_string_suffix(
"${SWIFTEXE_SINGLE_LINK_LIBRARIES}"
"-${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}-${SWIFTEXE_SINGLE_ARCHITECTURE}"
Expand Down Expand Up @@ -2637,6 +2631,11 @@ function(_add_swift_executable_single name)
if (SWIFT_PARALLEL_LINK_JOBS)
set_property(TARGET ${name} PROPERTY JOB_POOL_LINK swift_link_job_pool)
endif()
if(${SWIFTEXE_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
set_target_properties(${name} PROPERTIES
BUILD_WITH_INSTALL_RPATH YES
INSTALL_RPATH "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
endif()
set_output_directory(${name}
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/AddSwiftUnittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function(add_swift_unittest test_dirname)
endif()

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
LINK_FLAGS " -Xlinker -rpath -Xlinker ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/macosx")
set_target_properties(${test_dirname} PROPERTIES
BUILD_RPATH ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/macosx)
elseif("${SWIFT_HOST_VARIANT}" STREQUAL "android")
swift_android_lib_for_arch(${SWIFT_HOST_VARIANT_ARCH} android_system_libs)
set_property(TARGET "${test_dirname}" APPEND PROPERTY LINK_DIRECTORIES
Expand Down
12 changes: 4 additions & 8 deletions tools/swift-syntax-parser-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ target_link_libraries(swift-syntax-parser-test
libSwiftSyntaxParser
)

if(APPLE)
# Prioritize finding the parser library from the build/lib directory.
# Otherwise it may find it from the 'lib/swift/macosx' directory which could
# be out-of-date.
get_target_property(link_flags swift-syntax-parser-test LINK_FLAGS)
set(link_flags "-Xlinker -rpath -Xlinker @executable_path/../lib ${link_flags}")
set_property(TARGET swift-syntax-parser-test PROPERTY
LINK_FLAGS "${link_flags}")
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set_target_properties(swift-syntax-parser-test PROPERTIES
BUILD_WITH_INSTALL_RPATH YES
INSTALL_RPATH @executable_path/../lib)
endif()

set_property(TARGET swift-syntax-parser-test APPEND_STRING PROPERTY
Expand Down
11 changes: 3 additions & 8 deletions unittests/SyntaxParser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ target_link_libraries(SwiftSyntaxParserTests
PRIVATE
libSwiftSyntaxParser)

if(APPLE)
# Prioritize finding the parser library from the build/lib directory.
# Otherwise it may find it from the 'lib/swift/macosx' directory which could
# be out-of-date.
get_target_property(link_flags SwiftSyntaxParserTests LINK_FLAGS)
set(link_flags "-Xlinker -rpath -Xlinker ${SWIFT_LIBRARY_OUTPUT_INTDIR} ${link_flags}")
set_property(TARGET SwiftSyntaxParserTests PROPERTY
LINK_FLAGS "${link_flags}")
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set_target_properties(SwiftSyntaxParserTests PROPERTIES
BUILD_RPATH ${SWIFT_LIBRARY_OUTPUT_INTDIR})
endif()

set_property(TARGET SwiftSyntaxParserTests APPEND_STRING PROPERTY
Expand Down