Skip to content

Commit

Permalink
Make curl an optional dependency when not building FoundationNetworking
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kateinoigakukun committed Aug 10, 2024
1 parent 0d18916 commit 4127e85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ if(BUILD_SHARED_LIBS)
option(FOUNDATION_BUILD_TOOLS "build tools" ON)
endif()

set(FOUNDATION_BUILD_NETWORKING_default ON)
if(CMAKE_SYSTEM_NAME STREQUAL WASI)
# Networking is not supported on WASI
set(FOUNDATION_BUILD_NETWORKING_default OFF)
endif()
option(FOUNDATION_BUILD_NETWORKING "build FoundationNetworking"
${FOUNDATION_BUILD_NETWORKING_default})

set(CMAKE_POSITION_INDEPENDENT_CODE YES)

# Fetchable dependcies
Expand Down Expand Up @@ -121,7 +129,9 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
endif()
endif()
find_package(LibXml2 REQUIRED)
find_package(CURL REQUIRED)
if(FOUNDATION_BUILD_NETWORKING)
find_package(CURL REQUIRED)
endif()

# Common build flags (_CFURLSessionInterface, _CFXMLInterface, CoreFoundation)
list(APPEND _Foundation_common_build_flags
Expand Down
4 changes: 2 additions & 2 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

add_subdirectory(CoreFoundation)
add_subdirectory(_CFXMLInterface)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
if(FOUNDATION_BUILD_NETWORKING)
add_subdirectory(_CFURLSessionInterface)
endif()
add_subdirectory(Foundation)
add_subdirectory(FoundationXML)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
if(FOUNDATION_BUILD_NETWORKING)
add_subdirectory(FoundationNetworking)
endif()
if(FOUNDATION_BUILD_TOOLS)
Expand Down

0 comments on commit 4127e85

Please sign in to comment.