Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0887ea6

Browse files
committedAug 23, 2024
Make curl an optional dependency when not building FoundationNetworking
When building for WASI, FoundationNetworking is not supported, so we should not require curl to be present. This change makes curl an optional dependency when FoundationNetworking is not being built.
1 parent 3e6c3b7 commit 0887ea6

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
 

‎CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ if(BUILD_SHARED_LIBS)
6363
option(FOUNDATION_BUILD_TOOLS "build tools" ON)
6464
endif()
6565

66+
set(FOUNDATION_BUILD_NETWORKING_default ON)
67+
if(CMAKE_SYSTEM_NAME STREQUAL WASI)
68+
# Networking is not supported on WASI
69+
set(FOUNDATION_BUILD_NETWORKING_default OFF)
70+
endif()
71+
option(FOUNDATION_BUILD_NETWORKING "build FoundationNetworking"
72+
${FOUNDATION_BUILD_NETWORKING_default})
73+
6674
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
6775

6876
# Fetchable dependcies
@@ -121,7 +129,9 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
121129
endif()
122130
endif()
123131
find_package(LibXml2 REQUIRED)
124-
find_package(CURL REQUIRED)
132+
if(FOUNDATION_BUILD_NETWORKING)
133+
find_package(CURL REQUIRED)
134+
endif()
125135

126136
# Common build flags (_CFURLSessionInterface, _CFXMLInterface, CoreFoundation)
127137
list(APPEND _Foundation_common_build_flags

‎Sources/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
add_subdirectory(CoreFoundation)
1616
add_subdirectory(_CFXMLInterface)
17-
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
17+
if(FOUNDATION_BUILD_NETWORKING)
1818
add_subdirectory(_CFURLSessionInterface)
1919
endif()
2020
add_subdirectory(Foundation)
2121
add_subdirectory(FoundationXML)
22-
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
22+
if(FOUNDATION_BUILD_NETWORKING)
2323
add_subdirectory(FoundationNetworking)
2424
endif()
2525
if(FOUNDATION_BUILD_TOOLS)

0 commit comments

Comments
 (0)
Please sign in to comment.