Skip to content

Commit 4ee6004

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 4ee6004

File tree

1 file changed

+55
-33
lines changed

1 file changed

+55
-33
lines changed

CoreFoundation/CMakeLists.txt

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ 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+
endif()
114119
add_framework(CoreFoundation
115120
${FRAMEWORK_LIBRARY_TYPE}
116121
FRAMEWORK_DIRECTORY
@@ -128,7 +133,6 @@ add_framework(CoreFoundation
128133
Base.subproj/CFRuntime.h
129134
Base.subproj/CFRuntime_Internal.h
130135
Base.subproj/ForFoundationOnly.h
131-
Base.subproj/ForSwiftFoundationOnly.h
132136
# Collections
133137
Collections.subproj/CFBasicHash.h
134138
Collections.subproj/CFStorage.h
@@ -184,7 +188,9 @@ add_framework(CoreFoundation
184188
URL.subproj/CFURL.inc.h
185189
URL.subproj/CFURLPriv.h
186190
URL.subproj/CFURLSessionInterface.h
191+
${CF_SWIFT_PRIVATE_HEADERS}
187192
PUBLIC_HEADERS
193+
${CF_HEADER}
188194
# FIXME: PrivateHeaders referenced by public headers
189195
Base.subproj/CFKnownLocations.h
190196
Base.subproj/CFLocking.h
@@ -217,7 +223,6 @@ add_framework(CoreFoundation
217223
Base.subproj/CFByteOrder.h
218224
Base.subproj/CFUUID.h
219225
Base.subproj/CFUtilities.h
220-
Base.subproj/SwiftRuntime/CoreFoundation.h
221226
Base.subproj/SwiftRuntime/TargetConditionals.h
222227
# Collections
223228
Collections.subproj/CFArray.h
@@ -311,8 +316,6 @@ add_framework(CoreFoundation
311316
Parsing.subproj/CFOldStylePList.c
312317
Parsing.subproj/CFPropertyList.c
313318
Parsing.subproj/CFXMLInputStream.c
314-
Parsing.subproj/CFXMLNode.c
315-
Parsing.subproj/CFXMLParser.c
316319
Parsing.subproj/CFXMLTree.c
317320
# PlugIn
318321
PlugIn.subproj/CFBundle_Binary.c
@@ -374,6 +377,12 @@ add_framework(CoreFoundation
374377
URL.subproj/CFURL.c
375378
URL.subproj/CFURLComponents.c
376379
URL.subproj/CFURLComponents_URIParser.c)
380+
if(CF_DEPLOYMENT_SWIFT)
381+
target_sources(CoreFoundation
382+
PRIVATE
383+
Parsing.subproj/CFXMLNode.c
384+
Parsing.subproj/CFXMLParser.c)
385+
endif()
377386
target_compile_definitions(CoreFoundation
378387
PRIVATE
379388
$<$<COMPILE_LANGUAGE:ASM>:CF_CHARACTERSET_BITMAP="CharacterSets/CFCharacterSetBitmaps.bitmap">
@@ -421,22 +430,24 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
421430
CURL::libcurl)
422431
endif()
423432

424-
add_framework(CFXMLInterface
425-
${FRAMEWORK_LIBRARY_TYPE}
426-
FRAMEWORK_DIRECTORY
427-
CFXMLInterface_FRAMEWORK_DIRECTORY
428-
MODULE_MAP
429-
Parsing.subproj/module.modulemap
430-
PRIVATE_HEADERS
431-
Parsing.subproj/CFXMLInterface.h
432-
PUBLIC_HEADERS
433-
Parsing.subproj/CFXMLInterface.h
434-
SOURCES
435-
Parsing.subproj/CFXMLInterface.c)
436-
add_dependencies(CFXMLInterface CoreFoundation)
437-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
438-
target_link_libraries(CFXMLInterface PRIVATE
439-
LibXml2::LibXml2)
433+
if(CF_DEPLOYMENT_SWIFT)
434+
add_framework(CFXMLInterface
435+
${FRAMEWORK_LIBRARY_TYPE}
436+
FRAMEWORK_DIRECTORY
437+
CFXMLInterface_FRAMEWORK_DIRECTORY
438+
MODULE_MAP
439+
Parsing.subproj/module.modulemap
440+
PRIVATE_HEADERS
441+
Parsing.subproj/CFXMLInterface.h
442+
PUBLIC_HEADERS
443+
Parsing.subproj/CFXMLInterface.h
444+
SOURCES
445+
Parsing.subproj/CFXMLInterface.c)
446+
add_dependencies(CFXMLInterface CoreFoundation)
447+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
448+
target_link_libraries(CFXMLInterface PRIVATE
449+
LibXml2::LibXml2)
450+
endif()
440451
endif()
441452

442453
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
@@ -470,12 +481,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
470481
Secur32
471482
User32
472483
mincore)
473-
target_link_libraries(CFXMLInterface
474-
PRIVATE
475-
AdvAPI32
476-
Secur32
477-
User32
478-
mincore)
484+
if(CF_DEPLOYMENT_SWIFT)
485+
target_link_libraries(CFXMLInterface
486+
PRIVATE
487+
AdvAPI32
488+
Secur32
489+
User32
490+
mincore)
491+
endif()
479492
endif()
480493
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
481494
target_link_libraries(CoreFoundation
@@ -484,19 +497,23 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Dar
484497
target_link_libraries(CFURLSessionInterface
485498
PRIVATE
486499
m)
487-
target_link_libraries(CFXMLInterface
488-
PRIVATE
489-
m)
500+
if(CF_DEPLOYMENT_SWIFT)
501+
target_link_libraries(CFXMLInterface
502+
PRIVATE
503+
m)
504+
endif()
490505
endif()
491506
target_link_libraries(CoreFoundation
492507
PRIVATE
493508
dispatch)
494509
target_link_libraries(CFURLSessionInterface
495510
PRIVATE
496511
dispatch)
497-
target_link_libraries(CFXMLInterface
498-
PRIVATE
499-
dispatch)
512+
if(CF_DEPLOYMENT_SWIFT)
513+
target_link_libraries(CFXMLInterface
514+
PRIVATE
515+
dispatch)
516+
endif()
500517
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
501518
target_link_libraries(CoreFoundation
502519
PRIVATE
@@ -515,9 +532,14 @@ endif()
515532
install(TARGETS
516533
CoreFoundation
517534
CFURLSessionInterface
518-
CFXMLInterface
519535
DESTINATION
520536
"${CMAKE_INSTALL_FULL_LIBDIR}")
537+
if(CF_DEPLOYMENT_SWIFT)
538+
install(TARGETS
539+
CFXMLInterface
540+
DESTINATION
541+
"${CMAKE_INSTALL_FULL_LIBDIR}")
542+
endif()
521543

522544
# Needed to avoid double slash "//" when CMAKE_INSTALL_PREFIX set to "/" and DESTDIR used to relocate whole installation.
523545
# Double slash raise CMake error "file called with network path DESTINATION //System/Library/Frameworks".

0 commit comments

Comments
 (0)