mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Swift: Extract pointer size from Swift compiler
The target info in Swift 6.2 and newer supports emitting the pointer size for a given target triple. We can use that to set the Swift data pointer size, and the `CMAKE_SIZEOF_VOID_P`. Fixes: #26649
This commit is contained in:
@@ -139,6 +139,10 @@ if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 5.2)
|
||||
message(CONFIGURE_LOG "Swift target info:\n" "${swift_target_info}")
|
||||
string(JSON module_triple GET "${swift_target_info}" "target" "moduleTriple")
|
||||
set(CMAKE_Swift_MODULE_TRIPLE ${module_triple})
|
||||
|
||||
if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2)
|
||||
string(JSON CMAKE_Swift_SIZEOF_DATA_PTR GET "${swift_target_info}" "target" "pointerWidthInBytes")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT _CMAKE_TOOLCHAIN_LOCATION)
|
||||
|
||||
@@ -18,3 +18,8 @@ set(CMAKE_Swift_COMPILER_USE_OLD_DRIVER "@CMAKE_Swift_COMPILER_USE_OLD_DRIVER@")
|
||||
set(CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES@")
|
||||
|
||||
set(CMAKE_Swift_MODULE_TRIPLE "@CMAKE_Swift_MODULE_TRIPLE@")
|
||||
set(CMAKE_Swift_SIZEOF_DATA_PTR "@CMAKE_Swift_SIZEOF_DATA_PTR@")
|
||||
|
||||
if(NOT CMAKE_SIZEOF_VOID_P AND CMAKE_Swift_SIZEOF_DATA_PTR)
|
||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_Swift_SIZEOF_DATA_PTR}")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user