Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit e4bc8c9

Browse files
committed
build: install into the macOS style paths
Install the module into the macOS style paths which are honoured on both macOS and non-macOS targets. This simplifies the install rules across all the targets.
1 parent cd281df commit e4bc8c9

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

Sources/Tensor/CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ add_library(Tensor SHARED
44
set_target_properties(Tensor PROPERTIES
55
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
66

7+
get_swift_host_arch(swift_arch)
8+
get_swift_host_os(swift_os)
79
install(TARGETS Tensor
8-
ARCHIVE DESTINATION lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
9-
LIBRARY DESTINATION lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
10+
ARCHIVE DESTINATION lib/swift/${swift_os}
11+
LIBRARY DESTINATION lib/swift/${swift_os}
1012
RUNTIME DESTINATION bin)
11-
get_swift_host_arch(swift_arch)
12-
install(FILES
13-
$<TARGET_PROPERTY:Tensor,Swift_MODULE_DIRECTORY>/Tensor.swiftdoc
14-
$<TARGET_PROPERTY:Tensor,Swift_MODULE_DIRECTORY>/Tensor.swiftmodule
15-
DESTINATION lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>/${swift_arch})
13+
install(FILES $<TARGET_PROPERTY:Tensor,Swift_MODULE_DIRECTORY>/Tensor.swiftdoc
14+
DESTINATION lib/swift/${swift_os}/Tensor.swiftmodule
15+
RENAME ${swift_arch}.swiftdoc)
16+
install(FILES $<TARGET_PROPERTY:Tensor,Swift_MODULE_DIRECTORY>/Tensor.swiftmodule
17+
DESTINATION lib/swift/${swift_os}/Tensor.swiftmodule
18+
RENAME ${swift_arch}.swiftmodule)

Sources/TensorFlow/CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ target_link_libraries(TensorFlow PRIVATE
6363
CTensorFlow
6464
Tensor)
6565

66+
get_swift_host_arch(swift_arch)
67+
get_swift_host_os(swift_os)
6668
install(TARGETS TensorFlow
67-
ARCHIVE DESTINATION lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
68-
LIBRARY DESTINATION lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
69+
ARCHIVE DESTINATION lib/swift/${swift_os}
70+
LIBRARY DESTINATION lib/swift/${swift_os}
6971
RUNTIME DESTINATION bin)
70-
get_swift_host_arch(swift_arch)
71-
install(FILES
72-
$<TARGET_PROPERTY:TensorFlow,Swift_MODULE_DIRECTORY>/TensorFlow.swiftdoc
73-
$<TARGET_PROPERTY:TensorFlow,Swift_MODULE_DIRECTORY>/TensorFlow.swiftmodule
74-
DESTINATION lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>/${swift_arch})
72+
install(FILES $<TARGET_PROPERTY:TensorFlow,Swift_MODULE_DIRECTORY>/TensorFlow.swiftdoc
73+
DESTINATION lib/swift/${swift_os}/TensorFlow.swiftmodule
74+
RENAME ${swift_arch}.swiftdoc)
75+
install(FILES $<TARGET_PROPERTY:TensorFlow,Swift_MODULE_DIRECTORY>/TensorFlow.swiftmodule
76+
DESTINATION lib/swift/${swift_os}/TensorFlow.swiftmodule
77+
RENAME ${swift_arch}.swiftmodule)

cmake/modules/SwiftSupport.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ function(get_swift_host_arch result_var_name)
3535
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}")
3636
endif()
3737
endfunction()
38+
39+
function(get_swift_host_os result_var_name)
40+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
41+
set(result_var_name "macosx" PARENT_SCOPE)
42+
else()
43+
string(TOLOWER ${CMAKE_SYSTEM_NAME} cmake_system_name_lc)
44+
set(result_var_name ${cmake_system_name_lc} PARENT_SCOPE)
45+
endif()
46+
endfunction()

0 commit comments

Comments
 (0)