Skip to content

Commit 82c5274

Browse files
committed
Non-Darwin SDKs product results in per-arch directories.
Depends on swiftlang/swift#19432 Unix (other than Darwin) and Windows do not support fat binaries. However, the build system was placing the build results in the platform/OS folder, instead of the per-architecture folder. Having two architectures side by side was impossible. After applying the above patch in the Swift compiler, non-Darwin platforms will look into the per-architecture folders, so the sibling projects need to leave the products in the right place.
1 parent 65d0eea commit 82c5274

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,24 @@ add_custom_target(check-xctest
133133

134134
string(TOLOWER ${CMAKE_SYSTEM_NAME} SWIFT_OS)
135135

136+
get_swift_host_arch(SWIFT_HOST_ARCH)
137+
136138
install(FILES
137139
${CMAKE_CURRENT_BINARY_DIR}/swift/XCTest.swiftdoc
138140
${CMAKE_CURRENT_BINARY_DIR}/swift/XCTest.swiftmodule
139141
DESTINATION
140-
${CMAKE_INSTALL_FULL_LIBDIR}/swift/${SWIFT_OS}/${CMAKE_SYSTEM_PROCESSOR})
142+
${CMAKE_INSTALL_FULL_LIBDIR}/swift/${SWIFT_OS}/${SWIFT_HOST_ARCH})
141143
install(FILES
142144
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}XCTest${CMAKE_SHARED_LIBRARY_SUFFIX}
143145
DESTINATION
144146
${CMAKE_INSTALL_FULL_LIBDIR})
145147
# NOTE(compnerd) stage a compatibility copy in the swift resource dir
148+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
149+
set(DESTINATION_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/swift/${SWIFT_OS})
150+
else()
151+
set(DESTINATION_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/swift/${SWIFT_OS}/${SWIFT_HOST_ARCH})
152+
endif()
146153
install(FILES
147154
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}XCTest${CMAKE_SHARED_LIBRARY_SUFFIX}
148155
DESTINATION
149-
${CMAKE_INSTALL_FULL_LIBDIR}/swift/${SWIFT_OS})
150-
156+
${DESTINATION_DIR})

cmake/modules/SwiftSupport.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,35 @@ function(add_swift_executable executable)
131131
add_swift_target(${executable} ${ARGN})
132132
endfunction()
133133

134+
# Returns the current achitecture name in a variable
135+
#
136+
# Usage:
137+
# get_swift_host_arch(result_var_name)
138+
#
139+
# If the current architecture is supported by Swift, sets ${result_var_name}
140+
# with the sanitized host architecture name derived from CMAKE_SYSTEM_PROCESSOR.
141+
function(get_swift_host_arch result_var_name)
142+
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
143+
set("${result_var_name}" "x86_64" PARENT_SCOPE)
144+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
145+
set("${result_var_name}" "aarch64" PARENT_SCOPE)
146+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
147+
set("${result_var_name}" "powerpc64" PARENT_SCOPE)
148+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64le")
149+
set("${result_var_name}" "powerpc64le" PARENT_SCOPE)
150+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "s390x")
151+
set("${result_var_name}" "s390x" PARENT_SCOPE)
152+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv6l")
153+
set("${result_var_name}" "armv6" PARENT_SCOPE)
154+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
155+
set("${result_var_name}" "armv7" PARENT_SCOPE)
156+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
157+
set("${result_var_name}" "x86_64" PARENT_SCOPE)
158+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64")
159+
set("${result_var_name}" "itanium" PARENT_SCOPE)
160+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
161+
set("${result_var_name}" "i686" PARENT_SCOPE)
162+
else()
163+
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}")
164+
endif()
165+
endfunction()

0 commit comments

Comments
 (0)