From 5a07776cc9be53edd1197e5fbb8d26fba4adf0b8 Mon Sep 17 00:00:00 2001 From: Owen Voorhees Date: Sat, 4 Oct 2025 20:01:42 -0700 Subject: [PATCH 1/3] Fix CMake build on macOS/BSDs --- Sources/Subprocess/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Subprocess/CMakeLists.txt b/Sources/Subprocess/CMakeLists.txt index 5c1cfd3..d85f9dc 100644 --- a/Sources/Subprocess/CMakeLists.txt +++ b/Sources/Subprocess/CMakeLists.txt @@ -40,10 +40,14 @@ elseif(APPLE) Platforms/Subprocess+BSD.swift Platforms/Subprocess+Darwin.swift Platforms/Subprocess+Unix.swift) + target_compile_options(Subprocess PRIVATE + "$<$:SHELL:-D SUBPROCESS_ASYNCIO_DISPATCH>") elseif(FREEBSD OR OPENBSD) target_sources(Subprocess PRIVATE Platforms/Subprocess+BSD.swift Platforms/Subprocess+Unix.swift) + target_compile_options(Subprocess PRIVATE + "$<$:SHELL:-D SUBPROCESS_ASYNCIO_DISPATCH>") endif() target_compile_options(Subprocess PRIVATE From 4530131822298e9d4b0970c8cd482b9879d8cc26 Mon Sep 17 00:00:00 2001 From: Owen Voorhees Date: Sat, 4 Oct 2025 20:01:49 -0700 Subject: [PATCH 2/3] Add SwiftSubprocessConfig.cmake for use by dependent CMake projects --- CMakeLists.txt | 2 ++ cmake/modules/CMakeLists.txt | 14 ++++++++++++++ cmake/modules/SwiftSubprocessConfig.cmake.in | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 cmake/modules/CMakeLists.txt create mode 100644 cmake/modules/SwiftSubprocessConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f07181f..9ffc2b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,3 +42,5 @@ add_subdirectory(Sources) export(EXPORT SwiftSubprocessTargets FILE "cmake/SwiftSubprocess/SwiftSubprocessTargets.cmake" NAMESPACE "SwiftSubprocess::") + +add_subdirectory(cmake/modules) diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt new file mode 100644 index 0000000..a482a5e --- /dev/null +++ b/cmake/modules/CMakeLists.txt @@ -0,0 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + +configure_file(SwiftSubprocessConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/SwiftSubprocessConfig.cmake) + diff --git a/cmake/modules/SwiftSubprocessConfig.cmake.in b/cmake/modules/SwiftSubprocessConfig.cmake.in new file mode 100644 index 0000000..db0053f --- /dev/null +++ b/cmake/modules/SwiftSubprocessConfig.cmake.in @@ -0,0 +1,12 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + +include(${CMAKE_CURRENT_BINARY_DIR}/../SwiftSubprocess/SwiftSubprocessTargets.cmake) From a4589d50b4837987e67a4f630c8bc27ac340b453 Mon Sep 17 00:00:00 2001 From: Owen Voorhees Date: Sun, 5 Oct 2025 09:52:36 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Saleem Abdulrasool --- Sources/Subprocess/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Subprocess/CMakeLists.txt b/Sources/Subprocess/CMakeLists.txt index d85f9dc..cb77d23 100644 --- a/Sources/Subprocess/CMakeLists.txt +++ b/Sources/Subprocess/CMakeLists.txt @@ -41,13 +41,13 @@ elseif(APPLE) Platforms/Subprocess+Darwin.swift Platforms/Subprocess+Unix.swift) target_compile_options(Subprocess PRIVATE - "$<$:SHELL:-D SUBPROCESS_ASYNCIO_DISPATCH>") + "$<$:-DSUBPROCESS_ASYNCIO_DISPATCH>") elseif(FREEBSD OR OPENBSD) target_sources(Subprocess PRIVATE Platforms/Subprocess+BSD.swift Platforms/Subprocess+Unix.swift) target_compile_options(Subprocess PRIVATE - "$<$:SHELL:-D SUBPROCESS_ASYNCIO_DISPATCH>") + "$<$:-DSUBPROCESS_ASYNCIO_DISPATCH>") endif() target_compile_options(Subprocess PRIVATE