@@ -24,17 +24,73 @@ Hint Variables
24
24
This only affects Linux and Windows builds.
25
25
Apple builds always use the library provided by the SDK.
26
26
27
+ ``SwiftCore_USE_STATIC_LIBS``
28
+ Set to boolean true to find static libraries. If not
29
+ set explicitly this is inferred from the value of
30
+ `BUILD_SHARED_LIBS` and the current platform.
31
+
32
+ ``SwiftCore_INCLUDE_DIR_HINTS``
33
+ Additional paths to search the swiftmodules into. These
34
+ are prepended to the ones searched by this find module
35
+
36
+ ``SwiftCore_LIBRARY_HINTS``
37
+ Additional paths to search the libraries into. These
38
+ are prepended to the ones searched by this find module
39
+
40
+ ``SwiftShims_INCLUDE_DIR_HINTS``
41
+ Additional paths to search the shims into. These
42
+ are prepended to the ones searched by this find module
43
+
44
+ ``SwiftCore_NAMES``
45
+ Additional names for the Core library
46
+
47
+ ``SwiftOnoneSupport_NAMES``
48
+ Additional names for the SwiftOnoneSupport library
49
+
50
+ ``SwiftConcurrency_NAMES``
51
+ Additional names for the Swift_Concurrency library
52
+
53
+ Result targets
54
+ ^^^^^^^^^^^^^^
55
+
56
+ If no error is generated, the following targets are available to the users
57
+
58
+ * ``swiftCore``
59
+ * ``swiftSwiftOnoneSupport``
60
+ * ``swift_Concurrency``
61
+ * ``swiftShims``
62
+
27
63
Result Variables
28
64
^^^^^^^^^^^^^^^^
29
65
30
66
The module may set the following variables if `SwiftCore_DIR` is not set.
67
+ (although we suggest relying on the targets above instead)
31
68
32
69
``SwiftCore_FOUND``
33
70
true if core was found
34
71
35
72
``SwiftCore_INCLUDE_DIR``
36
73
the directory containing the Swift.swiftmodule folder
37
74
75
+ ``SwiftCore_LIBRARY``
76
+ path to the swiftCore library
77
+
78
+ ``SwiftOnoneSupport_INCLUDE_DIR``
79
+ the directory containing the SwiftOnoneSupport.swiftmodule folder
80
+
81
+ ``SwiftOnoneSupport_LIBRARY``
82
+ path to the SwiftOnoneSupport library
83
+
84
+ ``SwiftConcurrency_INCLUDE_DIR``
85
+ the directory containing the _Concurrency.swiftmodule folder
86
+
87
+ ``SwiftConcurrency_LIBRARY``
88
+ path to the swift_Concurrency library
89
+
90
+ ``SwiftShims_INCLUDE_DIR``
91
+ the directory containing the Swift shims directory
92
+ (i.e. .../usr/lib/swift, not .../usr/lib/swift/shims)
93
+
38
94
#]=======================================================================]
39
95
40
96
include_guard (GLOBAL )
@@ -72,22 +128,35 @@ if(APPLE)
72
128
"${CMAKE_OSX_SYSROOT} /usr/lib/swift" )
73
129
list (APPEND SwiftCore_LIBRARY_HINTS
74
130
"${CMAKE_OSX_SYSROOT} /usr/lib/swift" )
131
+ list (APPEND SwiftShims_INCLUDE_DIR_HINTS
132
+ "${CMAKE_OSX_SYSROOT} /usr/lib/swift" )
75
133
# When building for Apple platforms, SwiftCore always comes from within the
76
134
# SDK as a tbd for a shared library in the shared cache.
77
135
list (APPEND SwiftCore_NAMES libswiftCore.tbd )
136
+ list (APPEND SwiftOnoneSupport_NAMES libswiftSwiftOnoneSupport.tbd )
137
+ list (APPEND SwiftConcurrency_NAMES libswift_Concurrency.tbd )
78
138
elseif (LINUX )
79
139
if (SwiftCore_USE_STATIC_LIBS )
80
140
list (APPEND SwiftCore_INCLUDE_DIR_HINTS
81
141
"${Swift_SDKROOT} /usr/lib/swift_static/linux-static" )
82
142
list (APPEND SwiftCore_LIBRARY_HINTS
83
143
"${Swift_SDKROOT} /usr/lib/swift_static/linux-static" )
144
+ list (APPEND SwiftShims_INCLUDE_DIR_HINTS
145
+ "${Swift_SDKROOT} /usr/lib/swift_static"
146
+ "${Swift_SDKROOT} /usr/lib/swift" )
84
147
list (APPEND SwiftCore_NAMES libswiftCore.a )
148
+ list (APPEND SwiftOnoneSupport_NAMES libswiftSwiftOnoneSupport.a )
149
+ list (APPEND SwiftConcurrency_NAMES libswift_Concurrency.a )
85
150
else ()
86
151
list (APPEND SwiftCore_INCLUDE_DIR_HINTS
87
152
"${Swift_SDKROOT} /usr/lib/swift/linux" )
88
153
list (APPEND SwiftCore_LIBRARY_HINTS
89
154
"${Swift_SDKROOT} /usr/lib/swift/linux" )
155
+ list (APPEND SwiftShims_INCLUDE_DIR_HINTS
156
+ "${Swift_SDKROOT} /usr/lib/swift" )
90
157
list (APPEND SwiftCore_NAMES libswiftCore.so )
158
+ list (APPEND SwiftOnoneSupport_NAMES libswiftSwiftOnoneSupport.so )
159
+ list (APPEND SwiftConcurrency_NAMES libswift_Concurrency.so )
91
160
endif ()
92
161
elseif (WIN32 )
93
162
list (APPEND SwiftCore_INCLUDE_DIR_HINTS
@@ -98,10 +167,17 @@ elseif(WIN32)
98
167
"${Swift_SDKROOT} /usr/lib/swift"
99
168
"$ENV{SDKROOT} /usr/lib/swift/${${PROJECT_NAME} _PLATFORM_SUBDIR}/${${PROJECT_NAME} _ARCH_SUBDIR}"
100
169
"$ENV{SDKROOT} /usr/lib/swift" )
170
+ list (APPEND SwiftShims_INCLUDE_DIR_HINTS
171
+ "${Swift_SDKROOT} /usr/lib/swift"
172
+ "$ENV{SDKROOT} /usr/lib/swift" )
101
173
if (SwiftCore_USE_STATIC_LIBS )
102
174
list (APPEND SwiftCore_NAMES libswiftCore.lib )
175
+ list (APPEND SwiftOnoneSupport_NAMES libswiftSwiftOnoneSupport.lib )
176
+ list (APPEND SwiftConcurrency_NAMES libswift_Concurrency.lib )
103
177
else ()
104
178
list (APPEND SwiftCore_NAMES swiftCore.lib )
179
+ list (APPEND SwiftOnoneSupport_NAMES swiftSwiftOnoneSupport.lib )
180
+ list (APPEND SwiftConcurrency_NAMES swift_Concurrency.lib )
105
181
endif ()
106
182
elseif (ANDROID )
107
183
if (SwiftCore_USE_STATIC_LIBS )
@@ -113,7 +189,11 @@ elseif(ANDROID)
113
189
"${Swift_SDKROOT} /usr/lib/swift_static"
114
190
"$ENV{SDKROOT} /usr/lib/swift_static/android/${${PROJECT_NAME} _ARCH_SUBDIR}"
115
191
"$ENV{SDKROOT} /usr/lib/swift_static" )
192
+ list (APPEND SwiftShims_INCLUDE_DIR_HINTS
193
+ "${Swift_SDKROOT} /usr/lib/swift_static" )
116
194
list (APPEND SwiftCore_NAMES libswiftCore.a )
195
+ list (APPEND SwiftOnoneSupport_NAMES libswiftSwiftOnoneSupport.a )
196
+ list (APPEND SwiftConcurrency_NAMES libswift_Concurrency.a )
117
197
else ()
118
198
list (APPEND SwiftCore_INCLUDE_DIR_HINTS
119
199
"${Swift_SDKROOT} /usr/lib/swift/android"
@@ -123,7 +203,11 @@ elseif(ANDROID)
123
203
"${Swift_SDKROOT} /usr/lib/swift"
124
204
"$ENV{SDKROOT} /usr/lib/swift/android/${${PROJECT_NAME} _ARCH_SUBDIR}"
125
205
"$ENV{SDKROOT} /usr/lib/swift" )
206
+ list (APPEND SwiftShims_INCLUDE_DIR_HINTS
207
+ "${Swift_SDKROOT} /usr/lib/swift" )
126
208
list (APPEND SwiftCore_NAMES libswiftCore.so )
209
+ list (APPEND SwiftOnoneSupport_NAMES libswiftSwiftOnoneSupport.so )
210
+ list (APPEND SwiftConcurrency_NAMES libswift_Concurrency.so )
127
211
endif ()
128
212
else ()
129
213
message (FATAL_ERROR "FindSwiftCore.cmake module search not implemented for targeted platform\n "
@@ -143,22 +227,71 @@ find_library(SwiftCore_LIBRARY
143
227
HINTS
144
228
${SwiftCore_LIBRARY_HINTS} )
145
229
230
+ find_path (SwiftOnoneSupport_INCLUDE_DIR
231
+ "SwiftOnoneSupport.swiftmodule"
232
+ NO_CMAKE_FIND_ROOT_PATH
233
+ HINTS
234
+ ${SwiftCore_INCLUDE_DIR_HINTS} )
235
+ find_library (SwiftOnoneSupport_LIBRARY
236
+ NAMES
237
+ ${SwiftOnoneSupport_NAMES}
238
+ NO_CMAKE_FIND_ROOT_PATH
239
+ HINTS
240
+ ${SwiftCore_LIBRARY_HINTS} )
241
+
242
+ find_path (SwiftConcurrency_INCLUDE_DIR
243
+ "_Concurrency.swiftmodule"
244
+ NO_CMAKE_FIND_ROOT_PATH
245
+ HINTS
246
+ ${SwiftCore_INCLUDE_DIR_HINTS} )
247
+ find_library (SwiftConcurrency_LIBRARY
248
+ NAMES
249
+ ${SwiftConcurrency_NAMES}
250
+ NO_CMAKE_FIND_ROOT_PATH
251
+ HINTS
252
+ ${SwiftCore_LIBRARY_HINTS} )
253
+
146
254
if (SwiftCore_USE_STATIC_LIBS )
147
255
add_library (swiftCore STATIC IMPORTED GLOBAL )
256
+ add_library (swiftSwiftOnoneSupport STATIC IMPORTED GLOBAL )
257
+ add_library (swift_Concurrency STATIC IMPORTED GLOBAL )
148
258
else ()
149
259
add_library (swiftCore SHARED IMPORTED GLOBAL )
260
+ add_library (swiftSwiftOnoneSupport SHARED IMPORTED GLOBAL )
261
+ add_library (swift_Concurrency SHARED IMPORTED GLOBAL )
150
262
endif ()
151
263
152
264
set_target_properties (swiftCore PROPERTIES
153
265
INTERFACE_INCLUDE_DIRECTORIES "${SwiftCore_INCLUDE_DIR} " )
266
+ set_target_properties (swiftSwiftOnoneSupport PROPERTIES
267
+ INTERFACE_INCLUDE_DIRECTORIES "${SwiftOnoneSupport_INCLUDE_DIR} " )
268
+ set_target_properties (swift_Concurrency PROPERTIES
269
+ INTERFACE_INCLUDE_DIRECTORIES "${SwiftConcurrency_INCLUDE_DIR} " )
154
270
155
271
if (LINUX OR ANDROID )
156
272
set_target_properties (swiftCore PROPERTIES
157
273
IMPORTED_LOCATION "${SwiftCore_LIBRARY} " )
274
+ set_target_properties (swiftSwiftOnoneSupport PROPERTIES
275
+ IMPORTED_LOCATION "${SwiftOnoneSupport_LIBRARY} " )
276
+ set_target_properties (swift_Concurrency PROPERTIES
277
+ IMPORTED_LOCATION "${SwiftConcurrency_LIBRARY} " )
158
278
else ()
159
279
set_target_properties (swiftCore PROPERTIES
160
280
IMPORTED_IMPLIB "${SwiftCore_LIBRARY} " )
281
+ set_target_properties (swiftSwiftOnoneSupport PROPERTIES
282
+ IMPORTED_IMPLIB "${SwiftOnoneSupport_LIBRARY} " )
283
+ set_target_properties (swift_Concurrency PROPERTIES
284
+ IMPORTED_IMPLIB "${SwiftConcurrency_LIBRARY} " )
161
285
endif ()
162
286
287
+ find_path (SwiftShims_INCLUDE_DIR "shims/module.modulemap" HINTS
288
+ ${SwiftShims_INCLUDE_DIR_HINTS} )
289
+ add_library (swiftShims INTERFACE IMPORTED GLOBAL )
290
+ set_target_properties (swiftShims PROPERTIES
291
+ INTERFACE_INCLUDE_DIRECTORIES "${SwiftShims_INCLUDE_DIR} /shims" )
292
+
163
293
find_package_handle_standard_args (SwiftCore DEFAULT_MSG
164
- SwiftCore_LIBRARY SwiftCore_INCLUDE_DIR )
294
+ SwiftCore_LIBRARY SwiftCore_INCLUDE_DIR
295
+ SwiftShims_INCLUDE_DIR
296
+ SwiftOnoneSupport_LIBRARY SwiftOnoneSupport_INCLUDE_DIR
297
+ SwiftConcurrency_LIBRARY SwiftConcurrency_INCLUDE_DIR )
0 commit comments