Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ add_compile_definitions($<$<COMPILE_LANGUAGE:C,CXX>:HAVE_CONFIG_H>)


if(ENABLE_SWIFT)
include(SwiftSupport)

if(NOT SWIFT_SYSTEM_NAME)
if(APPLE)
set(SWIFT_SYSTEM_NAME macosx)
Expand All @@ -314,7 +316,7 @@ if(ENABLE_SWIFT)
endif()
endif()

set(INSTALL_TARGET_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SWIFT_SYSTEM_NAME}" CACHE PATH "Path where the libraries will be installed")
set(INSTALL_TARGET_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SWIFT_SYSTEM_NAME}/${dispatch_Swift_ARCH}" CACHE PATH "Path where the libraries will be installed")
set(INSTALL_DISPATCH_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/dispatch" CACHE PATH "Path where the headers will be installed for libdispatch")
set(INSTALL_BLOCK_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/Block" CACHE PATH "Path where the headers will be installed for the blocks runtime")
set(INSTALL_OS_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/os" CACHE PATH "Path where the os/ headers will be installed")
Expand Down
34 changes: 32 additions & 2 deletions cmake/modules/SwiftSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,47 @@ if(NOT dispatch_MODULE_TRIPLE)
message(CONFIGURE_LOG "Swift module triple: ${module_triple}")
endif()

if(NOT dispatch_Swift_ARCH)
if(CMAKE_Swift_COMPILER_VERSION VERSION_EQUAL 0.0.0 OR CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2)
# For newer compilers, we can use the -print-target-info command to get the architecture.
set(module_arch_command "${CMAKE_Swift_COMPILER}" -print-target-info)
if(CMAKE_Swift_COMPILER_TARGET)
list(APPEND module_arch_command -target ${CMAKE_Swift_COMPILER_TARGET})
endif()
execute_process(COMMAND ${module_arch_command} OUTPUT_VARIABLE target_info_json)
string(JSON module_arch GET "${target_info_json}" "target" "arch")
else()
# For older compilers, extract the value from `dispatch_MODULE_TRIPLE`.
string(REGEX MATCH "^[^-]+" module_arch "${dispatch_MODULE_TRIPLE}")
endif()

set(dispatch_Swift_ARCH "${module_arch}" CACHE STRING "Arch folder name used to install libraries")
mark_as_advanced(dispatch_Swift_ARCH)

message(CONFIGURE_LOG "Swift arch: ${dispatch_Swift_ARCH}")
endif()

function(install_swift_module target)
get_target_property(module ${target} Swift_MODULE_NAME)
if(NOT module)
set(module ${target})
endif()

if(NOT SWIFT_SYSTEM_NAME)
if(APPLE)
set(SWIFT_SYSTEM_NAME macosx)
else()
set(SWIFT_SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
endif()
endif()
set(INSTALL_SWIFT_MODULE_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SWIFT_SYSTEM_NAME}" CACHE PATH "Path where the swift modules will be installed")

install(
FILES $<TARGET_PROPERTY:${target},Swift_MODULE_DIRECTORY>/${module}.swiftdoc
DESTINATION ${INSTALL_TARGET_DIR}/${module}.swiftmodule
DESTINATION ${INSTALL_SWIFT_MODULE_DIR}/${module}.swiftmodule
RENAME ${dispatch_MODULE_TRIPLE}.swiftdoc)
install(
FILES $<TARGET_PROPERTY:${target},Swift_MODULE_DIRECTORY>/${module}.swiftmodule
DESTINATION ${INSTALL_TARGET_DIR}/${module}.swiftmodule
DESTINATION ${INSTALL_SWIFT_MODULE_DIR}/${module}.swiftmodule
RENAME ${dispatch_MODULE_TRIPLE}.swiftmodule)
endfunction()
2 changes: 0 additions & 2 deletions src/swift/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include(SwiftSupport)

if(HAVE_OBJC)
add_library(DispatchStubs STATIC
DispatchStubs.m)
Expand Down