mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
Install swiftmodules with the full module triple expected by the compiler instead of attempting to compute the correct architecture name in CMake.
58 lines
1.7 KiB
CMake
58 lines
1.7 KiB
CMake
#[[
|
|
This source file is part of the Swift Collections Open Source Project
|
|
|
|
Copyright (c) 2021 - 2024 Apple Inc. and the Swift project authors
|
|
Licensed under Apache License v2.0 with Runtime Library Exception
|
|
|
|
See https://swift.org/LICENSE.txt for license information
|
|
#]]
|
|
|
|
# Returns the os name in a variable
|
|
#
|
|
# Usage:
|
|
# get_swift_host_os(result_var_name)
|
|
#
|
|
#
|
|
# Sets ${result_var_name} with the converted OS name derived from
|
|
# CMAKE_SYSTEM_NAME.
|
|
function(get_swift_host_os result_var_name)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
|
set(${result_var_name} macosx PARENT_SCOPE)
|
|
else()
|
|
string(TOLOWER ${CMAKE_SYSTEM_NAME} cmake_system_name_lc)
|
|
set(${result_var_name} ${cmake_system_name_lc} PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
|
|
function(_install_target module)
|
|
get_swift_host_os(swift_os)
|
|
get_target_property(type ${module} TYPE)
|
|
|
|
if(type STREQUAL STATIC_LIBRARY)
|
|
set(swift swift_static)
|
|
else()
|
|
set(swift swift)
|
|
endif()
|
|
|
|
install(TARGETS ${module}
|
|
ARCHIVE DESTINATION lib/${swift}/${swift_os}
|
|
LIBRARY DESTINATION lib/${swift}/${swift_os}
|
|
RUNTIME DESTINATION bin)
|
|
if(type STREQUAL EXECUTABLE)
|
|
return()
|
|
endif()
|
|
|
|
get_target_property(module_name ${module} Swift_MODULE_NAME)
|
|
if(NOT module_name)
|
|
set(module_name ${module})
|
|
endif()
|
|
|
|
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
|
|
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
|
|
RENAME ${SwiftCollections_MODULE_TRIPLE}.swiftdoc)
|
|
|
|
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
|
|
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
|
|
RENAME ${SwiftCollections_MODULE_TRIPLE}.swiftmodule)
|
|
endfunction()
|