File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
3_bidirectional_cxx_interop Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ if("${CMAKE_Swift_COMPILER_VERSION}" VERSION_LESS 5.9)
1616 message (FATAL_ERROR "Bidirectional C++ Interop requires Swift 5.9 or greater. Have ${CMAKE_Swift_COMPILER_VERSION} " )
1717endif ()
1818
19+ if (NOT "${CMAKE_CXX_COMPILER_ID} " STREQUAL "Clang" AND
20+ NOT "${CMAKE_CXX_COMPILER_ID} " STREQUAL "AppleClang" )
21+ message (FATAL_ERROR "Project requires building with Clang.
22+ Have ${CMAKE_CXX_COMPILER_ID} " )
23+ endif ()
24+
1925list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake/modules" )
2026
2127# Set up swiftrt.o and runtime library search paths
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ function(_swift_generate_cxx_header_target target module header)
2222
2323 if (APPLE )
2424 set (SDK_FLAGS "-sdk" "${CMAKE_OSX_SYSROOT} " )
25+ elseif (WIN32 )
26+ set (SDK_FLAGS "-sdk" "$ENV{SDKROOT} " )
2527 endif ()
2628
2729 add_custom_command (
Original file line number Diff line number Diff line change 55#
66# See https://swift.org/LICENSE.txt for license information
77
8+ # Compute the name of the architecture directory on Windows from the CMake
9+ # system processor name.
10+ function (_swift_windows_arch_name output_variable_name target_arch)
11+ if (NOT WIN32 )
12+ return ()
13+ endif ()
14+
15+ if ("${target_arch} " STREQUAL "AMD64" )
16+ set ("${output_variable_name} " "x86_64" PARENT_SCOPE)
17+ elseif ("${target_arch} " STREQUAL "ARM64" )
18+ set ("${output_variable_name} " "aarch64" PARENT_SCOPE)
19+ else ()
20+ message (FATAL_ERROR "Unknown windows architecture: ${target_arch} " )
21+ endif ()
22+ endfunction ()
23+
824# Compute flags and search paths
925# NOTE: This logic will eventually move to CMake
1026function (_setup_swift_paths)
@@ -55,7 +71,11 @@ function(_setup_swift_paths)
5571
5672 link_directories (${SWIFT_LIBRARY_SEARCH_PATHS} )
5773
58- if (NOT APPLE )
74+ if (WIN32 )
75+ _swift_windows_arch_name(SWIFT_WIN_ARCH_DIR "${CMAKE_SYSTEM_PROCESSOR} " )
76+ set (SWIFT_SWIFTRT_FILE "$ENV{SDKROOT} /usr/lib/swift/windows/${SWIFT_WIN_ARCH_DIR} /swiftrt.obj" )
77+ add_link_options ("$<$<LINK_LANGUAGE:Swift>:${SWIFT_SWIFTRT_FILE} >" )
78+ elseif (NOT APPLE )
5979 find_file (SWIFT_SWIFTRT_FILE
6080 swiftrt.o
6181 PATHS ${SWIFT_LIBRARY_SEARCH_PATHS}
You can’t perform that action at this time.
0 commit comments