Skip to content

Allow disabling Dispatch and Networking in CMakeLists.txt #3029

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

Merged
merged 1 commit into from
Aug 10, 2021
Merged
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
30 changes: 27 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

option(BUILD_SHARED_LIBS "build shared libraries" ON)
option(HAS_LIBDISPATCH_API "has libdispatch API" ON)
option(BUILD_NETWORKING "build FoundationNetworking module" ON)
option(BUILD_TOOLS "build tools" ON)
option(NS_CURL_ASSUME_FEATURES_MISSING "Assume that optional libcurl features are missing rather than test the library's version, for build debugging" NO)

find_package(dispatch CONFIG REQUIRED)
if(HAS_LIBDISPATCH_API)
find_package(dispatch CONFIG REQUIRED)
endif()

include(SwiftSupport)
include(GNUInstallDirs)
Expand All @@ -53,6 +58,12 @@ set(BUILD_SHARED_LIBS NO)
add_subdirectory(CoreFoundation EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS ${SAVED_BUILD_SHARED_LIBS})

# BlocksRuntime is already in libdispatch so it is only needed if libdispatch is
# NOT being used
if(NOT HAS_LIBDISPATCH_API)
add_subdirectory(Sources/BlocksRuntime)
endif()

# Setup include paths for uuid/uuid.h
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/uuid-headers/uuid/uuid.h
COMMAND
Expand All @@ -74,9 +85,22 @@ endif()

if(NOT BUILD_SHARED_LIBS)
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
CoreFoundation CFXMLInterface CFURLSessionInterface)
install(TARGETS CoreFoundation CFXMLInterface CFURLSessionInterface
CoreFoundation CFXMLInterface)

if(NOT HAS_LIBDISPATCH_API)
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
BlocksRuntime)
endif()

install(TARGETS CoreFoundation CFXMLInterface
DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)

if(BUILD_NETWORKING)
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
CFURLSessionInterface)
install(TARGETS CFURLSessionInterface
DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
endif()
endif()

set(swift_lib_dir "lib/swift")
Expand Down