Skip to content

Commit bdd5169

Browse files
committed
[CF] Preliminary support for standalone builds.
This commit makes some preliminary fixes for standalone builds using cmake. The standalone and Swift builds are similar, except for: * the CoreFoundation umbrella header, * ForSwiftFoundationOnly.h, * CFXMLParser.c and CFXMLNode.c, since these have CFTypeIDs that are present in CFRuntime_Internal.h behind DEPLOYMENT_RUNTIME_SWIFT, and * CFXMLInterface, since it refers to struct _NSCFXMLBridge, and this is defined in ForSwiftFoundationOnly.h. Not present is a mechanism to refer to Block.h or dependent libraries.
1 parent b14c0df commit bdd5169

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

CoreFoundation/CMakeLists.txt

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ else()
111111
set(FRAMEWORK_LIBRARY_TYPE STATIC)
112112
endif()
113113

114+
set(CF_HEADER Base.subproj/CoreFoundation.h)
115+
if(CF_DEPLOYMENT_SWIFT)
116+
set(CF_HEADER Base.subproj/SwiftRuntime/CoreFoundation.h)
117+
set(CF_SWIFT_PRIVATE_HEADERS Base.subproj/ForSwiftFoundationOnly.h)
118+
set(CF_SWIFT_SOURCES Parsing.subproj/CFXMLNode.c Parsing.subproj/CFXMLParser.c)
119+
endif()
114120
add_framework(CoreFoundation
115121
${FRAMEWORK_LIBRARY_TYPE}
116122
FRAMEWORK_DIRECTORY
@@ -128,7 +134,6 @@ add_framework(CoreFoundation
128134
Base.subproj/CFRuntime.h
129135
Base.subproj/CFRuntime_Internal.h
130136
Base.subproj/ForFoundationOnly.h
131-
Base.subproj/ForSwiftFoundationOnly.h
132137
# Collections
133138
Collections.subproj/CFBasicHash.h
134139
Collections.subproj/CFStorage.h
@@ -184,7 +189,9 @@ add_framework(CoreFoundation
184189
URL.subproj/CFURL.inc.h
185190
URL.subproj/CFURLPriv.h
186191
URL.subproj/CFURLSessionInterface.h
192+
${CF_SWIFT_PRIVATE_HEADERS}
187193
PUBLIC_HEADERS
194+
${CF_HEADER}
188195
# FIXME: PrivateHeaders referenced by public headers
189196
Base.subproj/CFKnownLocations.h
190197
Base.subproj/CFLocking.h
@@ -217,7 +224,6 @@ add_framework(CoreFoundation
217224
Base.subproj/CFByteOrder.h
218225
Base.subproj/CFUUID.h
219226
Base.subproj/CFUtilities.h
220-
Base.subproj/SwiftRuntime/CoreFoundation.h
221227
Base.subproj/SwiftRuntime/TargetConditionals.h
222228
# Collections
223229
Collections.subproj/CFArray.h
@@ -311,8 +317,6 @@ add_framework(CoreFoundation
311317
Parsing.subproj/CFOldStylePList.c
312318
Parsing.subproj/CFPropertyList.c
313319
Parsing.subproj/CFXMLInputStream.c
314-
Parsing.subproj/CFXMLNode.c
315-
Parsing.subproj/CFXMLParser.c
316320
Parsing.subproj/CFXMLTree.c
317321
# PlugIn
318322
PlugIn.subproj/CFBundle_Binary.c
@@ -373,7 +377,8 @@ add_framework(CoreFoundation
373377
URL.subproj/CFURLAccess.c
374378
URL.subproj/CFURL.c
375379
URL.subproj/CFURLComponents.c
376-
URL.subproj/CFURLComponents_URIParser.c)
380+
URL.subproj/CFURLComponents_URIParser.c
381+
${CF_SWIFT_SOURCES})
377382
target_compile_definitions(CoreFoundation
378383
PRIVATE
379384
$<$<COMPILE_LANGUAGE:ASM>:CF_CHARACTERSET_BITMAP="CharacterSets/CFCharacterSetBitmaps.bitmap">
@@ -406,6 +411,7 @@ add_framework(CFURLSessionInterface
406411
URL.subproj/module.modulemap
407412
PRIVATE_HEADERS
408413
URL.subproj/CFURLSessionInterface.h
414+
Base.subproj/SwiftRuntime/TargetConditionals.h
409415
PUBLIC_HEADERS
410416
URL.subproj/CFURLSessionInterface.h
411417
SOURCES
@@ -421,6 +427,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
421427
CURL::libcurl)
422428
endif()
423429

430+
if(CF_DEPLOYMENT_SWIFT)
424431
add_framework(CFXMLInterface
425432
${FRAMEWORK_LIBRARY_TYPE}
426433
FRAMEWORK_DIRECTORY
@@ -438,6 +445,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
438445
target_link_libraries(CFXMLInterface PRIVATE
439446
LibXml2::LibXml2)
440447
endif()
448+
endif()
441449

442450
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
443451
add_library(CoreFoundationResources OBJECT
@@ -470,33 +478,39 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
470478
Secur32
471479
User32
472480
mincore)
481+
if(CF_DEPLOYMENT_SWIFT)
473482
target_link_libraries(CFXMLInterface
474483
PRIVATE
475484
AdvAPI32
476485
Secur32
477486
User32
478487
mincore)
479488
endif()
489+
endif()
480490
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
481491
target_link_libraries(CoreFoundation
482492
PRIVATE
483493
m)
484494
target_link_libraries(CFURLSessionInterface
485495
PRIVATE
486496
m)
497+
if(CF_DEPLOYMENT_SWIFT)
487498
target_link_libraries(CFXMLInterface
488499
PRIVATE
489500
m)
490501
endif()
502+
endif()
491503
target_link_libraries(CoreFoundation
492504
PRIVATE
493505
dispatch)
494506
target_link_libraries(CFURLSessionInterface
495507
PRIVATE
496508
dispatch)
509+
if(CF_DEPLOYMENT_SWIFT)
497510
target_link_libraries(CFXMLInterface
498511
PRIVATE
499512
dispatch)
513+
endif()
500514
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
501515
target_link_libraries(CoreFoundation
502516
PRIVATE
@@ -512,10 +526,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
512526
-Xlinker;-alias_list;-Xlinker;Base.subproj/DarwinSymbolAliases;-twolevel_namespace;-sectcreate;__UNICODE;__csbitmaps;CharacterSets/CFCharacterSetBitmaps.bitmap;-sectcreate;__UNICODE;__properties;CharacterSets/CFUniCharPropertyDatabase.data;-sectcreate;__UNICODE;__data;CharacterSets/CFUnicodeData-L.mapping;-segprot;__UNICODE;r;r)
513527
endif()
514528

529+
if(CF_DEPLOYMENT_SWIFT)
530+
set(CF_SWIFT_TARGETS CFXMLInterface)
531+
endif()
515532
install(TARGETS
516533
CoreFoundation
517534
CFURLSessionInterface
518-
CFXMLInterface
535+
${CF_SWIFT_TARGETS}
519536
DESTINATION
520537
"${CMAKE_INSTALL_FULL_LIBDIR}")
521538

0 commit comments

Comments
 (0)