Skip to content

Add CMake build #73

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

Merged
merged 5 commits into from
Jun 12, 2025
Merged

Add CMake build #73

merged 5 commits into from
Jun 12, 2025

Conversation

etcwilde
Copy link
Member

Adding a CMake build so that projects that use CMake to bootstrap, like SwiftPM and swift-build, can use this library.
This is an initial pass. Future work should include a mechanism to use a pre-built Swift-System and an installation story that generates a SwiftSubprocessConfig.cmake file. Changes are necessary in the Swift-System CMake files in order to have a proper installation story here though because the SwiftSystem library is not properly exported.

Unlike SwiftPM, CMake does not automatically generate modulemaps for C headers, so we need to include one.

I'm not sure how the mach/vm_page_size.h header was getting included, but I was getting errors about the vm_page_size variable not being declared. If the header exists, include it so that variable is defined.

Also added a workflow to verify that the CMake build continues to work.

The `vm_page_size` variable declared in `mach/vm_page_size.h` is used
when the header is available for inclusion. This header does not appear
to be included anywhere directly resulting in build failures due to the
missing `vm_page_size` declaration.
@etcwilde etcwilde requested a review from iCharlesHu as a code owner June 12, 2025 05:56

FetchContent_Declare(SwiftSystem
GIT_REPOSITORY https://github.com/apple/swift-system.git
GIT_TAG a34201439c74b53f0fd71ef11741af7e7caf01e1 # 1.4.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shahmishal @owenv FYI since we're currently trying to get this to 1.5.0.

Copy link
Contributor

@jakepetroules jakepetroules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@iCharlesHu iCharlesHu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @etcwilde!!

etcwilde added 4 commits June 12, 2025 13:23
Adding an initial CMake build for the Swift-subprocess library.
At this time, it will build its own swift-system library, although we
should allow it to search for one if one is available.

CMake does not automatically generate modulemaps like SwiftPM does. As a
result, we need to add one for Swift to import the C shims.

There is one library target emitted from this build, Subprocess.
Adding steps to test that the CMake build works as expected.
Adding license header to the CMake files
Tell SwiftPM to ignore the CMake files to quiet the build warnings.
@etcwilde etcwilde force-pushed the ewilde/cmake-build branch from 8989bec to 8121674 Compare June 12, 2025 20:25
@etcwilde etcwilde merged commit 25f4791 into swiftlang:main Jun 12, 2025
21 checks passed
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.

3 participants