Skip to content

Add CMake build of SwiftPM dependencies #5233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jmschonfeld
Copy link
Contributor

@jmschonfeld jmschonfeld commented Jul 3, 2025

Building this project as a SwiftPM package on Windows requires first building a few dependencies as CMake projects (zlib, libxml, and curl). On Linux this is not required because these projects ship with the OS, but on Windows they don't ship with the OS or the toolchain. Normally, you must build each project manually with CMake and point the SwiftPM build at the build products via environment variables. This adds a new CMake option to the swift-corelibs-foundation project that, instead of building SCL-F itself via CMake, it checks out and builds these 3 dependencies via CMake and outputs the commands to run to set the appropriate environment variables. This CMake option can be triggered via a slightly modified version of the normal CMake build command:

cmake -G Ninja -B <build folder>
cmake --build <build folder> --target WindowsSwiftPMDependencies

At the end, the command will print and output like the following:

[0/1] Install the project...
[16/16] Running utility command for WindowsSwiftPMDependencies
Please set the following environment variables for the SwiftPM build:

LIBXML_INCLUDE_PATH=C:/Users/jmschonfeld/Documents/Repos/swift-corelibs-foundation/.build-cmake/windows-deps/libxml/include/libxml2
LIBXML_LIBRARY_PATH=C:/Users/jmschonfeld/Documents/Repos/swift-corelibs-foundation/.build-cmake/windows-deps/libxml/lib
CURL_INCLUDE_PATH=C:/Users/jmschonfeld/Documents/Repos/swift-corelibs-foundation/.build-cmake/windows-deps/curl/include
CURL_LIBRARY_PATH=C:/Users/jmschonfeld/Documents/Repos/swift-corelibs-foundation/.build-cmake/windows-deps/curl/lib
ZLIB_LIBRARY_PATH=C:/Users/jmschonfeld/Documents/Repos/swift-corelibs-foundation/.build-cmake/windows-deps/zlib/lib

After running the set commands, you can run swift test in this repo on Windows and it will build successfully.

@jmschonfeld jmschonfeld force-pushed the cmake-swiftpm-dependencies branch from 5aee920 to 42e13bc Compare July 3, 2025 18:59
@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test Windows platform

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test Windows platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant