forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
232 lines (203 loc) · 7.09 KB
/
Copy pathCMakeLists.txt
File metadata and controls
232 lines (203 loc) · 7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
set(sources
AssertionReporting.h
CoreFoundationShims.h
FoundationShims.h
GlobalObjects.h
HeapObject.h
KeyPath.h
LibcOverlayShims.h
LibcShims.h
MetadataSections.h
Random.h
RefCount.h
Reflection.h
RuntimeShims.h
RuntimeStubs.h
SwiftStdbool.h
SwiftStddef.h
SwiftStdint.h
System.h
Target.h
ThreadLocalStorage.h
UnicodeShims.h
Visibility.h
_SwiftConcurrency.h
CoreMediaOverlayShims.h
DispatchOverlayShims.h
NetworkOverlayShims.h
OSOverlayShims.h
ObjectiveCOverlayShims.h
SafariServicesOverlayShims.h
AppKitOverlayShims.h
UIKitOverlayShims.h
XCTestOverlayShims.h
XPCOverlayShims.h
CoreFoundationOverlayShims.h
CFCharacterSetShims.h
CFHashingShims.h
FoundationOverlayShims.h
FoundationShimSupport.h
NSCalendarShims.h
NSCharacterSetShims.h
NSCoderShims.h
NSDataShims.h
NSDictionaryShims.h
NSErrorShims.h
NSFileManagerShims.h
NSIndexPathShims.h
NSIndexSetShims.h
NSKeyedArchiverShims.h
NSLocaleShims.h
NSTimeZoneShims.h
NSUndoManagerShims.h
ClockKitOverlayShims.h
module.modulemap
)
set(output_dir "${SWIFTLIB_DIR}/shims")
set(output_dir_static "${SWIFTSTATICLIB_DIR}/shims")
add_custom_command(
OUTPUT "${output_dir}"
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}")
if(SWIFT_BUILD_STATIC_STDLIB)
add_custom_command(
OUTPUT "${output_dir_static}"
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir_static}")
endif()
set(outputs)
foreach(input ${sources})
add_custom_command(
OUTPUT "${output_dir}/${input}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
COMMAND
"${CMAKE_COMMAND}" "-E" "copy_if_different"
"${CMAKE_CURRENT_SOURCE_DIR}/${input}"
"${output_dir}/${input}"
COMMENT "Copying ${input} to ${output_dir}")
list(APPEND outputs "${output_dir}/${input}")
if(SWIFT_BUILD_STATIC_STDLIB)
add_custom_command(
OUTPUT "${output_dir_static}/${input}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
COMMAND
"${CMAKE_COMMAND}" "-E" "copy_if_different"
"${CMAKE_CURRENT_SOURCE_DIR}/${input}"
"${output_dir_static}/${input}"
COMMENT "Copying ${input} to ${output_dir_static}")
list(APPEND outputs "${output_dir_static}/${input}")
endif()
endforeach()
# Put the output dir itself last so that it isn't considered the primary output.
list(APPEND outputs "${output_dir}")
add_custom_target("copy_shim_headers"
DEPENDS "${outputs}"
COMMENT "Copying SwiftShims module to ${output_dir}")
if ("${LLVM_PACKAGE_VERSION}" STREQUAL "")
message(FATAL_ERROR
"LLVM_PACKAGE_VERSION must be set before including subdirectories")
endif()
# Symlink in the Clang headers.
# First extract the "version" used for Clang's resource directory.
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
"${LLVM_PACKAGE_VERSION}")
if(NOT SWIFT_INCLUDE_TOOLS AND
(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG))
if(SWIFT_COMPILER_IS_MSVC_LIKE)
execute_process(COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource-dir
OUTPUT_VARIABLE clang_headers_location
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
else()
execute_process(COMMAND ${CMAKE_C_COMPILER} -print-resource-dir
OUTPUT_VARIABLE clang_headers_location
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
endif()
message(STATUS "Using clang Resource Directory: ${clang_headers_location}")
else()
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
set(cmake_symlink_option "copy_directory")
else()
set(cmake_symlink_option "create_symlink")
endif()
add_custom_command_target(unused_var
COMMAND
"${CMAKE_COMMAND}" "-E" "make_directory" "${SWIFTLIB_DIR}"
COMMAND
"${CMAKE_COMMAND}" "-E" "${cmake_symlink_option}"
"${clang_headers_location}"
"${SWIFTLIB_DIR}/clang"
CUSTOM_TARGET_NAME "symlink_clang_headers"
OUTPUT "${SWIFTLIB_DIR}/clang"
COMMENT "Symlinking Clang resource headers into ${SWIFTLIB_DIR}/clang")
add_dependencies(copy_shim_headers symlink_clang_headers)
if(SWIFT_BUILD_STATIC_STDLIB)
add_custom_command_target(unused_var
COMMAND
"${CMAKE_COMMAND}" "-E" "make_directory" "${SWIFTSTATICLIB_DIR}"
COMMAND
"${CMAKE_COMMAND}" "-E" "${cmake_symlink_option}"
"${clang_headers_location}"
"${SWIFTSTATICLIB_DIR}/clang"
CUSTOM_TARGET_NAME "symlink_clang_headers_static"
OUTPUT "${SWIFTSTATICLIB_DIR}/clang"
COMMENT "Symlinking Clang resource headers into ${SWIFTSTATICLIB_DIR}/clang")
add_dependencies(copy_shim_headers symlink_clang_headers_static)
endif()
if(NOT SWIFT_BUILT_STANDALONE)
if(TARGET clang-resource-headers) # LLVM > 8
set(clang_resource_headers clang-resource-headers)
elseif(TARGET clang-headers) # LLVM <= 8
set(clang_resource_headers clang-headers)
else()
message(SEND_ERROR
"Unable to determine clang resource headers target in unified build")
endif()
foreach(target
symlink_clang_headers
clang-builtin-headers
clang-resource-dir-symlink
clang-builtin-headers-in-clang-resource-dir)
add_dependencies(${target} ${clang_resource_headers})
endforeach()
endif()
swift_install_in_component(FILES ${sources}
DESTINATION "lib/swift/shims"
COMPONENT stdlib)
if(SWIFT_BUILD_STATIC_STDLIB)
swift_install_in_component(FILES ${sources}
DESTINATION "lib/swift_static/shims"
COMPONENT stdlib)
endif()
# Install Clang headers under the Swift library so that an installed Swift's
# module importer can find the compiler headers corresponding to its Clang.
swift_install_in_component(DIRECTORY "${clang_headers_location}/"
DESTINATION "lib/swift/clang"
COMPONENT clang-builtin-headers
PATTERN "*.h")
if(SWIFT_BUILD_STATIC_STDLIB)
swift_install_in_component(DIRECTORY "${clang_headers_location}/"
DESTINATION "lib/swift_static/clang"
COMPONENT clang-builtin-headers
PATTERN "*.h")
endif()
swift_install_symlink_component(clang-resource-dir-symlink
LINK_NAME clang
TARGET ../clang/${CLANG_VERSION}
DESTINATION "lib/swift")
if(SWIFT_BUILD_STATIC_STDLIB)
swift_install_symlink_component(clang-resource-dir-symlink
LINK_NAME clang
TARGET ../clang/${CLANG_VERSION}
DESTINATION "lib/swift_static")
endif()
# Possibly install Clang headers under Clang's resource directory in case we
# need to use a different version of the headers than the installed Clang. This
# should be used in conjunction with clang-resource-dir-symlink.
file(TO_CMAKE_PATH "${LLVM_LIBRARY_OUTPUT_INTDIR}"
_SWIFT_SHIMS_PATH_TO_CLANG_LIB_BUILD)
swift_install_in_component(DIRECTORY "${_SWIFT_SHIMS_PATH_TO_CLANG_LIB_BUILD}/clang"
DESTINATION "lib"
COMPONENT clang-builtin-headers-in-clang-resource-dir
PATTERN "*.h")