-
Notifications
You must be signed in to change notification settings - Fork 204
[cmake] Set up rpath for macOS binaries #1732
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Returns the architecture name in a variable | ||
# | ||
# Usage: | ||
# get_swift_host_arch(result_var_name) | ||
# | ||
# Sets ${result_var_name} with the converted architecture name derived from | ||
# CMAKE_SYSTEM_PROCESSOR. | ||
function(get_swift_host_arch result_var_name) | ||
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") | ||
set("${result_var_name}" "x86_64" PARENT_SCOPE) | ||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64") | ||
if(NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET OR | ||
"${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "") | ||
set("${result_var_name}" "aarch64" PARENT_SCOPE) | ||
else() | ||
set("${result_var_name}" "arm64" PARENT_SCOPE) | ||
endif() | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64") | ||
set("${result_var_name}" "powerpc64" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64le") | ||
set("${result_var_name}" "powerpc64le" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "s390x") | ||
set("${result_var_name}" "s390x" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv6l") | ||
set("${result_var_name}" "armv6" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a") | ||
set("${result_var_name}" "armv7" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l") | ||
set("${result_var_name}" "armv7" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64") | ||
set("${result_var_name}" "amd64" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64") | ||
set("${result_var_name}" "x86_64" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64") | ||
set("${result_var_name}" "itanium" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86") | ||
set("${result_var_name}" "i686" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686") | ||
set("${result_var_name}" "i686" PARENT_SCOPE) | ||
else() | ||
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}") | ||
endif() | ||
endfunction() | ||
|
||
# Returns the os name in a variable | ||
# | ||
# Usage: | ||
# get_swift_host_os(result_var_name) | ||
# | ||
# | ||
# Sets ${result_var_name} with the converted OS name derived from | ||
# CMAKE_SYSTEM_NAME. | ||
function(get_swift_host_os result_var_name) | ||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
set(${result_var_name} macosx PARENT_SCOPE) | ||
else() | ||
string(TOLOWER ${CMAKE_SYSTEM_NAME} cmake_system_name_lc) | ||
set(${result_var_name} ${cmake_system_name_lc} PARENT_SCOPE) | ||
endif() | ||
endfunction() | ||
|
||
function(_install_target module) | ||
get_swift_host_os(swift_os) | ||
get_target_property(type ${module} TYPE) | ||
|
||
if(type STREQUAL STATIC_LIBRARY) | ||
set(swift swift_static) | ||
else() | ||
set(swift swift) | ||
endif() | ||
|
||
install(TARGETS ${module} | ||
ARCHIVE DESTINATION lib/${swift}/${swift_os} | ||
LIBRARY DESTINATION lib/${swift}/${swift_os} | ||
RUNTIME DESTINATION bin) | ||
if(type STREQUAL EXECUTABLE) | ||
return() | ||
endif() | ||
|
||
get_swift_host_arch(swift_arch) | ||
get_target_property(module_name ${module} Swift_MODULE_NAME) | ||
if(NOT module_name) | ||
set(module_name ${module}) | ||
endif() | ||
|
||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc | ||
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule | ||
RENAME ${swift_arch}.swiftdoc) | ||
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule | ||
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule | ||
RENAME ${swift_arch}.swiftmodule) | ||
else() | ||
install(FILES | ||
$<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc | ||
$<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule | ||
DESTINATION lib/${swift}/${swift_os}/${swift_arch}) | ||
endif() | ||
endfunction() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed, since there's another copy in
@executable_path/../lib/swift/macosx
. I've already submitted a pull to remove this copy, swiftlang/swift#77647.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on how
swift-llbuild
is built, but after further discussions, it seemslib/swift/macosx
is the wrong directory for dynamic libraries and they should be inlib
instead. I am closing this PR for now.