mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
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:
parent
ee54f9ee95
commit
7ab1d117f1
Notes:
github-actions[bot]
2024-09-23 17:07:23 +00:00
Author: https://github.com/ADKaster Commit: https://github.com/LadybirdBrowser/ladybird/commit/7ab1d117f15 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1477
2 changed files with 14 additions and 3 deletions
|
@ -25,7 +25,7 @@ endfunction()
|
|||
# NOTE: This logic will eventually move to CMake
|
||||
function(_setup_swift_paths)
|
||||
# If we haven't set the swift library search paths, do that now
|
||||
if(NOT SWIFT_LIBRARY_SEARCH_PATHS OR NOT SWIFT_INCLUDE_PATHS)
|
||||
if(NOT SWIFT_LIBRARY_SEARCH_PATHS OR NOT SWIFT_INCLUDE_PATHS OR (APPLE AND NOT SWIFT_TARGET_TRIPLE))
|
||||
if(APPLE)
|
||||
set(SDK_FLAGS "-sdk" "${CMAKE_OSX_SYSROOT}")
|
||||
endif()
|
||||
|
@ -38,6 +38,17 @@ function(_setup_swift_paths)
|
|||
OUTPUT_VARIABLE SWIFT_TARGET_INFO
|
||||
)
|
||||
|
||||
# FIXME: https://gitlab.kitware.com/cmake/cmake/-/issues/26174
|
||||
if (APPLE)
|
||||
if (CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set(SWIFT_TARGET_TRIPLE "${CMAKE_SYSTEM_PROCESSOR}-apple-macosx${CMAKE_OSX_DEPLOYMENT_TARGET}" CACHE STRING "Swift target triple")
|
||||
else()
|
||||
string(JSON SWIFT_TARGET_TARGET GET ${SWIFT_TARGET_INFO} "target")
|
||||
string(JSON SWIFT_TARGET_TARGET_TRIPLE GET ${SWIFT_TARGET_TARGET} "triple")
|
||||
set(SWIFT_TARGET_TRIPLE ${SWIFT_TARGET_TARGET_TRIPLE} CACHE STRING "Swift target triple")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# extract search paths from swift driver response
|
||||
string(JSON SWIFT_TARGET_PATHS GET ${SWIFT_TARGET_INFO} "paths")
|
||||
|
||||
|
@ -72,7 +83,7 @@ function(_setup_swift_paths)
|
|||
set(SWIFT_TOOLCHAIN_INCLUDE_DIR "${SWIFT_RUNTIME_RESOURCE_PATH}/../../include")
|
||||
cmake_path(ABSOLUTE_PATH SWIFT_TOOLCHAIN_INCLUDE_DIR NORMALIZE)
|
||||
if (NOT IS_DIRECTORY "${SWIFT_TOOLCHAIN_INCLUDE_DIR}")
|
||||
message(WARNING "Expected toolchain include dir ${SWIFT_TOOLCHAIN_INCLUDE_DIR} does not exist")
|
||||
message(WARNING "Expected toolchain include dir ${SWIFT_TOOLCHAIN_INCLUDE_DIR} does not exist")
|
||||
endif()
|
||||
set(SWIFT_INCLUDE_PATHS ${SWIFT_TOOLCHAIN_INCLUDE_DIR} CACHE FILEPATH "Swift interop include paths")
|
||||
endif()
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue