Skip to content

Commit 0071efe

Browse files
committed
[CMake] Cope with the lack of CMAKE_Swift_COMPILER_TARGET on Windows
1 parent ffdd338 commit 0071efe

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ if (NOT SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
4444
$<$<COMPILE_LANGUAGE:Swift>:-disable-implicit-string-processing-module-import>)
4545
endif()
4646

47+
# Determine the module triple.
48+
# FIXME: This is a hack. It's all a hack.
49+
if(CMAKE_Swift_COMPILER_TARGET)
50+
string(REGEX REPLACE "macosx[0-9]+([.][0-9]+)?" "macos" SWIFT_MODULE_TRIPLE
51+
${CMAKE_Swift_COMPILER_TARGET})
52+
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
53+
set(SWIFT_MODULE_TRIPLE "${CMAKE_SYSTEM_PROCESSOR}-unknown-windows-msvc")
54+
endif()
55+
56+
message(STATUS "Module triple: ${SWIFT_MODULE_TRIPLE}")
57+
4758
# Force single-threaded-only syntax trees to eliminate the Darwin
4859
# dependency in the compiler.
4960
add_compile_definitions(

cmake/modules/AddSwiftHostLibrary.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ function(add_swift_host_library name)
1616
# Add this to the list of exported targets.
1717
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS ${name})
1818

19-
# Determine the module triple based on the target triple.
20-
# FIXME: We would prefer to have build-script tell us.
21-
string(REGEX REPLACE "macosx[0-9]+([.][0-9]+)?" "macos" module_triple
22-
${CMAKE_Swift_COMPILER_TARGET})
23-
2419
# Determine where Swift modules will be built and installed.
2520
set(module_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
2621
set(module_base "${module_dir}/${name}.swiftmodule")
27-
set(module_file "${module_base}/${module_triple}.swiftmodule")
28-
set(module_interface_file "${module_base}/${module_triple}.swiftinterface")
29-
set(module_sourceinfo_file "${module_base}/${module_triple}.swiftsourceinfo")
22+
set(module_file "${module_base}/${SWIFT_MODULE_TRIPLE}.swiftmodule")
23+
set(module_interface_file "${module_base}/${SWIFT_MODULE_TRIPLE}.swiftinterface")
24+
set(module_sourceinfo_file "${module_base}/${SWIFT_MODULE_TRIPLE}.swiftsourceinfo")
3025

3126
# Add a custom target to create the module directory.
3227
add_custom_command(

0 commit comments

Comments
 (0)