@@ -20,17 +20,23 @@ endif()
20
20
21
21
set (CMAKE_POSITION_INDEPENDENT_CODE YES )
22
22
23
- set (CMAKE_THREAD_PREFER_PTHREAD TRUE )
24
- set (THREADS_PREFER_PTHREAD_FLAG OFF )
25
- find_package (Threads REQUIRED)
23
+
24
+ if (HAS_LIBDISPATCH_API)
25
+ set (CMAKE_THREAD_PREFER_PTHREAD TRUE )
26
+ set (THREADS_PREFER_PTHREAD_FLAG OFF )
27
+ find_package (Threads REQUIRED)
28
+ endif ()
26
29
27
30
if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
28
31
find_package (LibXml2 REQUIRED)
29
- find_package (CURL CONFIG)
30
- if (CURL_FOUND)
31
- set (CURL_VERSION_STRING ${CURL_VERSION} )
32
- else ()
33
- find_package (CURL REQUIRED)
32
+
33
+ if (BUILD_NETWORKING)
34
+ find_package (CURL CONFIG)
35
+ if (CURL_FOUND)
36
+ set (CURL_VERSION_STRING ${CURL_VERSION} )
37
+ else ()
38
+ find_package (CURL REQUIRED)
39
+ endif ()
34
40
endif ()
35
41
find_package (ICU COMPONENTS uc i18n REQUIRED)
36
42
endif ()
@@ -115,6 +121,38 @@ else()
115
121
set (FRAMEWORK_LIBRARY_TYPE STATIC )
116
122
endif ()
117
123
124
+ set (CF_WASI_UNAVAILABLE_SOURCES)
125
+
126
+ if (NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
127
+ list (APPEND CF_WASI_UNAVAILABLE_SOURCES
128
+ # PlugIn
129
+ PlugIn.subproj/CFBundle_Binary.c
130
+ PlugIn.subproj/CFBundle.c
131
+ PlugIn.subproj/CFBundle_DebugStrings.c
132
+ PlugIn.subproj/CFBundle_Executable.c
133
+ PlugIn.subproj/CFBundle_Grok.c
134
+ PlugIn.subproj/CFBundle_InfoPlist.c
135
+ PlugIn.subproj/CFBundle_Locale.c
136
+ PlugIn.subproj/CFBundle_Main.c
137
+ PlugIn.subproj/CFBundle_ResourceFork.c
138
+ PlugIn.subproj/CFBundle_Resources.c
139
+ PlugIn.subproj/CFBundle_SplitFileName.c
140
+ PlugIn.subproj/CFBundle_Strings.c
141
+ PlugIn.subproj/CFBundle_Tables.c
142
+ PlugIn.subproj/CFPlugIn.c
143
+ # Preferences
144
+ Preferences.subproj/CFApplicationPreferences.c
145
+ Preferences.subproj/CFPreferences.c
146
+ Preferences.subproj/CFXMLPreferencesDomain.c
147
+ # RunLoop
148
+ RunLoop.subproj/CFRunLoop.c
149
+ RunLoop.subproj/CFSocket.c
150
+ # Stream
151
+ Stream.subproj/CFConcreteStreams.c
152
+ Stream.subproj/CFSocketStream.c
153
+ Stream.subproj/CFStream.c)
154
+ endif ()
155
+
118
156
add_framework(CoreFoundation
119
157
${FRAMEWORK_LIBRARY_TYPE}
120
158
FRAMEWORK_DIRECTORY
@@ -202,7 +240,6 @@ add_framework(CoreFoundation
202
240
Locale.subproj/CFDateInterval.h
203
241
Locale.subproj/CFLocaleInternal.h
204
242
PlugIn.subproj/CFBundlePriv.h
205
- Stream.subproj/CFStreamPriv.h
206
243
String .subproj/CFCharacterSetPriv.h
207
244
String .subproj/CFRegularExpression.h
208
245
String .subproj/CFRunArray.h
@@ -257,6 +294,7 @@ add_framework(CoreFoundation
257
294
RunLoop.subproj/CFRunLoop.h
258
295
RunLoop.subproj/CFSocket.h
259
296
# Stream
297
+ Stream.subproj/CFStreamPriv.h
260
298
Stream.subproj/CFStream.h
261
299
# String
262
300
String .subproj/CFAttributedString.h
@@ -312,36 +350,11 @@ add_framework(CoreFoundation
312
350
Parsing.subproj/CFBinaryPList.c
313
351
Parsing.subproj/CFOldStylePList.c
314
352
Parsing.subproj/CFPropertyList.c
315
- # PlugIn
316
- PlugIn.subproj/CFBundle_Binary.c
317
- PlugIn.subproj/CFBundle.c
318
- PlugIn.subproj/CFBundle_DebugStrings.c
319
- PlugIn.subproj/CFBundle_Executable.c
320
- PlugIn.subproj/CFBundle_Grok.c
321
- PlugIn.subproj/CFBundle_InfoPlist.c
322
- PlugIn.subproj/CFBundle_Locale.c
323
- PlugIn.subproj/CFBundle_Main.c
324
- PlugIn.subproj/CFBundle_ResourceFork.c
325
- PlugIn.subproj/CFBundle_Resources.c
326
- PlugIn.subproj/CFBundle_SplitFileName.c
327
- PlugIn.subproj/CFBundle_Strings.c
328
- PlugIn.subproj/CFBundle_Tables.c
329
- PlugIn.subproj/CFPlugIn.c
330
- # Preferences
331
- Preferences.subproj/CFApplicationPreferences.c
332
- Preferences.subproj/CFPreferences.c
333
- Preferences.subproj/CFXMLPreferencesDomain.c
334
353
# RunLoop
335
354
# TODO(compnerd) make this empty on non-Mach targets
336
355
# RunLoop.subproj/CFMachPort.c
337
356
# RunLoop.subproj/CFMachPort_Lifetime.c
338
357
# RunLoop.subproj/CFMessagePort.c
339
- RunLoop.subproj/CFRunLoop.c
340
- RunLoop.subproj/CFSocket.c
341
- # Stream
342
- Stream.subproj/CFConcreteStreams.c
343
- Stream.subproj/CFSocketStream.c
344
- Stream.subproj/CFStream.c
345
358
# String
346
359
String .subproj/CFAttributedString.c
347
360
String .subproj/CFBurstTrie.c
@@ -369,7 +382,9 @@ add_framework(CoreFoundation
369
382
URL.subproj/CFURLAccess.c
370
383
URL.subproj/CFURL.c
371
384
URL.subproj/CFURLComponents.c
372
- URL.subproj/CFURLComponents_URIParser.c)
385
+ URL.subproj/CFURLComponents_URIParser.c
386
+
387
+ ${CF_WASI_UNAVAILABLE_SOURCES} )
373
388
target_compile_definitions (CoreFoundation
374
389
PRIVATE
375
390
$<$<COMPILE_LANGUAGE:ASM>:CF_CHARACTERSET_BITMAP="CharacterSets/CFCharacterSetBitmaps.bitmap" >
@@ -379,11 +394,27 @@ target_compile_definitions(CoreFoundation
379
394
target_include_directories (CoreFoundation
380
395
PRIVATE
381
396
${PROJECT_SOURCE_DIR} )
397
+
382
398
target_link_libraries (CoreFoundation PRIVATE
383
- Threads::Threads
384
399
${CMAKE_DL_LIBS}
385
- BlocksRuntime
386
- dispatch)
400
+ BlocksRuntime)
401
+
402
+ if (HAS_LIBDISPATCH_API)
403
+ target_link_libraries (CoreFoundation PRIVATE
404
+ Threads::Threads
405
+ dispatch)
406
+ endif ()
407
+
408
+ if (NOT BUILD_SHARED_LIBS )
409
+ set_property (TARGET CoreFoundation PROPERTY STATIC_LIBRARY_OPTIONS
410
+ $<TARGET_OBJECTS:BlocksRuntime>)
411
+ endif ()
412
+
413
+ if (CMAKE_SYSTEM_NAME STREQUAL WASI)
414
+ # Enable emulated mman and constant CFSTRINGS
415
+ target_compile_definitions (CoreFoundation PRIVATE _WASI_EMULATED_MMAN __CONSTANT_CFSTRINGS__)
416
+ endif ()
417
+
387
418
if (CMAKE_SYSTEM_NAME STREQUAL Android)
388
419
target_link_libraries (CoreFoundation PRIVATE
389
420
log )
@@ -422,7 +453,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
422
453
PRIVATE
423
454
CURL_STATICLIB)
424
455
endif ()
425
- if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
456
+ if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin AND BUILD_NETWORKING )
426
457
target_link_libraries (CFURLSessionInterface PRIVATE
427
458
CURL::libcurl)
428
459
endif ()
@@ -440,6 +471,8 @@ add_framework(CFXMLInterface
440
471
SOURCES
441
472
Parsing.subproj/CFXMLInterface.c)
442
473
add_dependencies (CFXMLInterface CoreFoundation)
474
+ target_link_libraries (CFXMLInterface PRIVATE BlocksRuntime)
475
+
443
476
if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
444
477
target_link_libraries (CFXMLInterface PRIVATE
445
478
LibXml2::LibXml2)
@@ -494,15 +527,19 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Dar
494
527
PRIVATE
495
528
m)
496
529
endif ()
497
- target_link_libraries (CoreFoundation
498
- PRIVATE
499
- dispatch)
500
- target_link_libraries (CFURLSessionInterface
501
- PRIVATE
502
- dispatch)
503
- target_link_libraries (CFXMLInterface
504
- PRIVATE
530
+
531
+ if (HAS_LIBDISPATCH_API)
532
+ target_link_libraries (CoreFoundation
533
+ PRIVATE
534
+ dispatch)
535
+ target_link_libraries (CFURLSessionInterface
536
+ PRIVATE
537
+ dispatch)
538
+ target_link_libraries (CFXMLInterface
539
+ PRIVATE
505
540
dispatch)
541
+ endif ()
542
+
506
543
if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
507
544
target_link_libraries (CoreFoundation
508
545
PRIVATE
0 commit comments