Skip to content

[CF] Preliminary support for standalone builds. #2646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 55 additions & 31 deletions CoreFoundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ else()
set(FRAMEWORK_LIBRARY_TYPE STATIC)
endif()

set(CF_HEADER Base.subproj/CoreFoundation.h)
if(CF_DEPLOYMENT_SWIFT)
set(CF_HEADER Base.subproj/SwiftRuntime/CoreFoundation.h)
set(CF_SWIFT_PRIVATE_HEADERS Base.subproj/ForSwiftFoundationOnly.h)
endif()
add_framework(CoreFoundation
${FRAMEWORK_LIBRARY_TYPE}
FRAMEWORK_DIRECTORY
Expand All @@ -130,7 +135,6 @@ add_framework(CoreFoundation
Base.subproj/CFRuntime.h
Base.subproj/CFRuntime_Internal.h
Base.subproj/ForFoundationOnly.h
Base.subproj/ForSwiftFoundationOnly.h
# Collections
Collections.subproj/CFBasicHash.h
Collections.subproj/CFStorage.h
Expand Down Expand Up @@ -186,7 +190,9 @@ add_framework(CoreFoundation
URL.subproj/CFURL.inc.h
URL.subproj/CFURLPriv.h
URL.subproj/CFURLSessionInterface.h
${CF_SWIFT_PRIVATE_HEADERS}
PUBLIC_HEADERS
${CF_HEADER}
# FIXME: PrivateHeaders referenced by public headers
Base.subproj/CFKnownLocations.h
Base.subproj/CFLocking.h
Expand Down Expand Up @@ -219,7 +225,6 @@ add_framework(CoreFoundation
Base.subproj/CFByteOrder.h
Base.subproj/CFUUID.h
Base.subproj/CFUtilities.h
Base.subproj/SwiftRuntime/CoreFoundation.h
Base.subproj/SwiftRuntime/TargetConditionals.h
# Collections
Collections.subproj/CFArray.h
Expand Down Expand Up @@ -368,6 +373,12 @@ add_framework(CoreFoundation
URL.subproj/CFURL.c
URL.subproj/CFURLComponents.c
URL.subproj/CFURLComponents_URIParser.c)
if(CF_DEPLOYMENT_SWIFT)
target_sources(CoreFoundation
PRIVATE
Parsing.subproj/CFXMLNode.c
Parsing.subproj/CFXMLParser.c)
endif()
target_compile_definitions(CoreFoundation
PRIVATE
$<$<COMPILE_LANGUAGE:ASM>:CF_CHARACTERSET_BITMAP="CharacterSets/CFCharacterSetBitmaps.bitmap">
Expand Down Expand Up @@ -425,22 +436,24 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
CURL::libcurl)
endif()

add_framework(CFXMLInterface
${FRAMEWORK_LIBRARY_TYPE}
FRAMEWORK_DIRECTORY
CFXMLInterface_FRAMEWORK_DIRECTORY
MODULE_MAP
Parsing.subproj/module.modulemap
PRIVATE_HEADERS
Parsing.subproj/CFXMLInterface.h
PUBLIC_HEADERS
Parsing.subproj/CFXMLInterface.h
SOURCES
Parsing.subproj/CFXMLInterface.c)
add_dependencies(CFXMLInterface CoreFoundation)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_link_libraries(CFXMLInterface PRIVATE
LibXml2::LibXml2)
if(CF_DEPLOYMENT_SWIFT)
add_framework(CFXMLInterface
${FRAMEWORK_LIBRARY_TYPE}
FRAMEWORK_DIRECTORY
CFXMLInterface_FRAMEWORK_DIRECTORY
MODULE_MAP
Parsing.subproj/module.modulemap
PRIVATE_HEADERS
Parsing.subproj/CFXMLInterface.h
PUBLIC_HEADERS
Parsing.subproj/CFXMLInterface.h
SOURCES
Parsing.subproj/CFXMLInterface.c)
add_dependencies(CFXMLInterface CoreFoundation)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_link_libraries(CFXMLInterface PRIVATE
LibXml2::LibXml2)
endif()
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
Expand Down Expand Up @@ -474,12 +487,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
Secur32
User32
mincore)
target_link_libraries(CFXMLInterface
PRIVATE
AdvAPI32
Secur32
User32
mincore)
if(CF_DEPLOYMENT_SWIFT)
target_link_libraries(CFXMLInterface
PRIVATE
AdvAPI32
Secur32
User32
mincore)
endif()
endif()
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_link_libraries(CoreFoundation
Expand All @@ -488,19 +503,23 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Dar
target_link_libraries(CFURLSessionInterface
PRIVATE
m)
target_link_libraries(CFXMLInterface
PRIVATE
m)
if(CF_DEPLOYMENT_SWIFT)
target_link_libraries(CFXMLInterface
PRIVATE
m)
endif()
endif()
target_link_libraries(CoreFoundation
PRIVATE
dispatch)
target_link_libraries(CFURLSessionInterface
PRIVATE
dispatch)
target_link_libraries(CFXMLInterface
PRIVATE
dispatch)
if(CF_DEPLOYMENT_SWIFT)
target_link_libraries(CFXMLInterface
PRIVATE
dispatch)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_link_libraries(CoreFoundation
PRIVATE
Expand All @@ -519,9 +538,14 @@ endif()
install(TARGETS
CoreFoundation
CFURLSessionInterface
CFXMLInterface
DESTINATION
"${CMAKE_INSTALL_FULL_LIBDIR}")
if(CF_DEPLOYMENT_SWIFT)
install(TARGETS
CFXMLInterface
DESTINATION
"${CMAKE_INSTALL_FULL_LIBDIR}")
endif()

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