apple / swift-cmake-examples

Apache License 2.0
99 stars 9 forks source link

Updates for building bidirectional-C++-interop on Windows #1

Closed etcwilde closed 12 months ago

etcwilde commented 12 months ago

There were some holes for building the bidirectional Swift-C++ example on Windows. This patches those up.

First, Windows wasn't finding the standard library when generating the bridging header for the Swift library. Second, Windows likes using MSVC, which was not amused by the generated header. This adds a check to ensure we're using Clang or AppleClang. Third, the swiftrt file lives in the SDK instead of the toolchain on Windows, unlike on Linux. The driver reports the location of the toolchain libraries with -print-target-info, but does not for the SDK, so we have to grab the file manually. It would be nice if we could make the platforms more consistent, but this is a fix for now.

With these three changes, I was able to build and run the bidirectional C++ interop on Windows, built in Visual Studio.