Skip to content

Commit 17b8520

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 dbca8c7 commit 17b8520

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(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

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

104-
if(BUILD_NETWORKING)
104+
if(FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
105105
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
106106
CFURLSessionInterface)
107107
install(TARGETS CFURLSessionInterface

CoreFoundation/CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ find_package(Threads REQUIRED)
2626

2727
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
2828
find_package(LibXml2 REQUIRED)
29-
find_package(CURL CONFIG)
30-
if(CURL_FOUND)
31-
set(CURL_VERSION_STRING ${CURL_VERSION})
32-
else()
33-
find_package(CURL REQUIRED)
29+
30+
if(FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
31+
find_package(CURL CONFIG)
32+
if(CURL_FOUND)
33+
set(CURL_VERSION_STRING ${CURL_VERSION})
34+
else()
35+
find_package(CURL REQUIRED)
36+
endif()
3437
endif()
3538
endif()
3639

@@ -431,7 +434,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
431434
PRIVATE
432435
CURL_STATICLIB)
433436
endif()
434-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
437+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin AND FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
435438
target_link_libraries(CFURLSessionInterface PRIVATE
436439
CURL::libcurl)
437440
endif()
@@ -530,10 +533,16 @@ endif()
530533

531534
install(TARGETS
532535
CoreFoundation
533-
CFURLSessionInterface
534536
CFXMLInterface
535537
DESTINATION
536-
"${CMAKE_INSTALL_FULL_LIBDIR}")
538+
"${CMAKE_INSTALL_FULL_LIBDIR}/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
539+
540+
if(FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
541+
install(TARGETS
542+
CFURLSessionInterface
543+
DESTINATION
544+
"${CMAKE_INSTALL_FULL_LIBDIR}/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
545+
endif()
537546

538547
# Needed to avoid double slash "//" when CMAKE_INSTALL_PREFIX set to "/" and DESTDIR used to relocate whole installation.
539548
# 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,5 +1,7 @@
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
add_subdirectory(Tools)

0 commit comments

Comments
 (0)