Skip to content

Commit d097302

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 d097302

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

CoreFoundation/CMakeLists.txt

Lines changed: 22 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">
@@ -421,6 +426,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
421426
CURL::libcurl)
422427
endif()
423428

429+
if(CF_DEPLOYMENT_SWIFT)
424430
add_framework(CFXMLInterface
425431
${FRAMEWORK_LIBRARY_TYPE}
426432
FRAMEWORK_DIRECTORY
@@ -438,6 +444,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
438444
target_link_libraries(CFXMLInterface PRIVATE
439445
LibXml2::LibXml2)
440446
endif()
447+
endif()
441448

442449
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
443450
add_library(CoreFoundationResources OBJECT
@@ -470,33 +477,39 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
470477
Secur32
471478
User32
472479
mincore)
480+
if(CF_DEPLOYMENT_SWIFT)
473481
target_link_libraries(CFXMLInterface
474482
PRIVATE
475483
AdvAPI32
476484
Secur32
477485
User32
478486
mincore)
479487
endif()
488+
endif()
480489
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
481490
target_link_libraries(CoreFoundation
482491
PRIVATE
483492
m)
484493
target_link_libraries(CFURLSessionInterface
485494
PRIVATE
486495
m)
496+
if(CF_DEPLOYMENT_SWIFT)
487497
target_link_libraries(CFXMLInterface
488498
PRIVATE
489499
m)
490500
endif()
501+
endif()
491502
target_link_libraries(CoreFoundation
492503
PRIVATE
493504
dispatch)
494505
target_link_libraries(CFURLSessionInterface
495506
PRIVATE
496507
dispatch)
508+
if(CF_DEPLOYMENT_SWIFT)
497509
target_link_libraries(CFXMLInterface
498510
PRIVATE
499511
dispatch)
512+
endif()
500513
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
501514
target_link_libraries(CoreFoundation
502515
PRIVATE
@@ -512,10 +525,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
512525
-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)
513526
endif()
514527

528+
if(CF_DEPLOYMENT_SWIFT)
529+
set(CF_SWIFT_TARGETS CFXMLInterface)
530+
endif()
515531
install(TARGETS
516532
CoreFoundation
517533
CFURLSessionInterface
518-
CFXMLInterface
534+
${CF_SWIFT_TARGETS}
519535
DESTINATION
520536
"${CMAKE_INSTALL_FULL_LIBDIR}")
521537

0 commit comments

Comments
 (0)