Skip to content

Commit a63cfba

Browse files
[wasm][build] Disable networking targets from CMake build
This is a follow-up to 5e7281b, which introduced `BUILD_NETWORKING` option but didn't update the CMake build to respect it. This patch renames the option to follow CMake conventions and updates the build to respect it.
1 parent c890a55 commit a63cfba

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
3939

4040
option(BUILD_SHARED_LIBS "build shared libraries" ON)
4141
option(HAS_LIBDISPATCH_API "has libdispatch API" ON)
42-
option(BUILD_NETWORKING "build FoundationNetworking module" ON)
42+
option(FOUNDATION_ENABLE_FOUNDATION_NETWORKING "build FoundationNetworking module" ON)
4343
option(FOUNDATION_BUILD_TOOLS "build tools" ON)
4444
option(NS_CURL_ASSUME_FEATURES_MISSING "Assume that optional libcurl features are missing rather than test the library's version, for build debugging" NO)
4545

@@ -103,7 +103,7 @@ if(NOT BUILD_SHARED_LIBS)
103103
install(TARGETS CoreFoundation CFXMLInterface
104104
DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
105105

106-
if(BUILD_NETWORKING)
106+
if(FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
107107
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
108108
CFURLSessionInterface)
109109
install(TARGETS CFURLSessionInterface

CoreFoundation/CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ endif()
2828

2929
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
3030
find_package(LibXml2 REQUIRED)
31-
find_package(CURL CONFIG)
32-
if(CURL_FOUND)
33-
set(CURL_VERSION_STRING ${CURL_VERSION})
34-
else()
35-
find_package(CURL REQUIRED)
31+
32+
if(FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
33+
find_package(CURL CONFIG)
34+
if(CURL_FOUND)
35+
set(CURL_VERSION_STRING ${CURL_VERSION})
36+
else()
37+
find_package(CURL REQUIRED)
38+
endif()
3639
endif()
3740
endif()
3841

@@ -438,7 +441,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
438441
PRIVATE
439442
CURL_STATICLIB)
440443
endif()
441-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
444+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin AND FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
442445
target_link_libraries(CFURLSessionInterface PRIVATE
443446
CURL::libcurl)
444447
endif()
@@ -540,10 +543,16 @@ endif()
540543

541544
install(TARGETS
542545
CoreFoundation
543-
CFURLSessionInterface
544546
CFXMLInterface
545547
DESTINATION
546-
"${CMAKE_INSTALL_FULL_LIBDIR}")
548+
"${CMAKE_INSTALL_FULL_LIBDIR}/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
549+
550+
if(FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
551+
install(TARGETS
552+
CFURLSessionInterface
553+
DESTINATION
554+
"${CMAKE_INSTALL_FULL_LIBDIR}/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
555+
endif()
547556

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

Sources/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
add_subdirectory(UUID)
22
add_subdirectory(Foundation)
3-
add_subdirectory(FoundationNetworking)
3+
if(FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
4+
add_subdirectory(FoundationNetworking)
5+
endif()
46
add_subdirectory(FoundationXML)
57
if(FOUNDATION_BUILD_TOOLS)
68
add_subdirectory(Tools)

0 commit comments

Comments
 (0)