Skip to content

Commit 84a4bed

Browse files
authored
Merge pull request #2513 from etcwilde/generalize-swift-module-triple
Generalize computing SWIFT_HOST_MODULE_TRIPLE
2 parents 247e3ce + 50babe2 commit 84a4bed

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

CMakeLists.txt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,12 @@ endif()
6363

6464
# Determine the module triple.
6565
if("${SWIFT_HOST_MODULE_TRIPLE}" STREQUAL "")
66-
# FIXME: This is a hack. It's all a hack. Windows isn't setting
67-
# CMAKE_Swift_COMPILER_TARGET.
66+
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
6867
if(CMAKE_Swift_COMPILER_TARGET)
69-
string(REGEX REPLACE "macosx[0-9]+([.][0-9]+)?" "macos" SWIFT_HOST_MODULE_TRIPLE
70-
${CMAKE_Swift_COMPILER_TARGET})
71-
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
72-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
73-
set(SWIFT_HOST_MODULE_TRIPLE "x86_64-unknown-windows-msvc")
74-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64")
75-
set(SWIFT_HOST_MODULE_TRIPLE "aarch64-unknown-windows-msvc")
76-
else()
77-
message(FATAL_ERROR "Unrecognized architecture for Windows host")
78-
endif()
79-
else()
80-
execute_process(COMMAND ${CMAKE_Swift_COMPILER} -print-target-info OUTPUT_VARIABLE target_info)
81-
string(JSON SWIFT_HOST_MODULE_TRIPLE GET ${target_info} target moduleTriple)
68+
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
8269
endif()
70+
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
71+
string(JSON SWIFT_HOST_MODULE_TRIPLE GET "${target_info_json}" "target" "moduleTriple")
8372
endif()
8473
message(STATUS "Module triple: ${SWIFT_HOST_MODULE_TRIPLE}")
8574

0 commit comments

Comments
 (0)