mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
build: delegate rpath handling to CMake
This moves the rpath handling to the build system rather than trying to figure out the correct flags to pass to the driver.
This commit is contained in:
@@ -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}"
|
||||
@@ -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})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user