CMake: Enable finding the Swift -target flag in more cases

When the detected SDK for CMAKE_OSX_SYSROOT and friends has the same
version as your current macOS system version, CMake helpfully doesn't
set CMAKE_OSX_DEPLOYMENT_TARGET. Unfortunately, in this case, swiftc
will default to macOS 10.4, which is absolutely ancient. Grab the target
triple from the -print-target-info JSON when CMAKE_OSX_DEPLOYMENT_TARGET
is not provided at configure time.
This commit is contained in:
Andrew Kaster 2024-09-21 12:55:52 -06:00 committed by Andrew Kaster
commit 7ab1d117f1
Notes: github-actions[bot] 2024-09-23 17:07:23 +00:00
2 changed files with 14 additions and 3 deletions

View file

@ -18,7 +18,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/GenerateSwiftHeader.cmake)
# FIXME: https://gitlab.kitware.com/cmake/cmake/-/issues/26174
if (APPLE)
set(CMAKE_Swift_COMPILER_TARGET "${CMAKE_SYSTEM_PROCESSOR}-apple-macosx${CMAKE_OSX_DEPLOYMENT_TARGET}")
set(CMAKE_Swift_COMPILER_TARGET "${SWIFT_TARGET_TRIPLE}")
endif()
set(VFS_OVERLAY_DIRECTORY "${CMAKE_BINARY_DIR}/vfs_overlays" CACHE PATH "Directory to put VFS overlays in")