Skip to content

[EXPERIMENTAL] Add support for vcpkg #3145

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 1 commit into
base: main
Choose a base branch
from

Conversation

stevapple
Copy link
Contributor

@stevapple stevapple commented Feb 26, 2022

Windows developers have a relatively difficult experience for pulling in dependencies. This patch adds support for vcpkg's manifest mode, which can seamlessly integrate with CMake.

@stevapple
Copy link
Contributor Author

Anyone to review?

@millenomi
Copy link
Contributor

Pulling the brake on this one because I'd like an explanation of benefits. How does this benefit the Visual Studio story at all? Are you building a VS build solution for Swift itself?

CMake is an internal build detail of Swift itself and I would prefer people do not attempt to maintain their own CMake-based build setups for end user software. (swift build should be used for that.)

@millenomi
Copy link
Contributor

(Yes, it is clear that SPM has Windows issues aplenty, but the focus should be if possible on those rather than exposing build details of a module that should be picked up with the redistributable instead.)

@stevapple
Copy link
Contributor Author

@millenomi This adds a manifest file of vcpkg, allowing developers to have:

-DCMAKE_TOOLCHAIN_FILE=[vcpkg-root]/scripts/buildsystems/vcpkg.cmake

flag passed on CMake, to let vcpkg provide the CMake packages, without having to install them in the system.

vcpkg will build everything from source and cache the artifacts across builds. This is not related to Visual Studio — if you wish, you can use it on macOS and Linux too.

Like we’re using CMake as an alternative to SwiftPM somewhere, vcpkg support is much of an alternative to pkgconfig. It is not meant to be used on official builds, but can largely speed up local development process.

@millenomi
Copy link
Contributor

I'm not super willing to add support for something we don't have a CI test rig for, sorry. Is it something you can maintain in your fork?

@millenomi
Copy link
Contributor

And whoops I shouldn't have assumed this was VS-related, my bad.

@millenomi
Copy link
Contributor

Do you have a use case that works with CMake, but not SPM? Is there anything blocking you from using SPM instead?

@stevapple
Copy link
Contributor Author

Do you have a use case that works with CMake, but not SPM? Is there anything blocking you from using SPM instead?

I don’t think any of the core libraries can be built with SwiftPM from ever since. We’re either using CMake or custom build.py script.

The main purpose of introducing vcpkg support is related to missing of pkgconfig on Windows, where CMake (and any other build system, including SwiftPM) cannot discover external libraries easily, and users can neither install system-wide dependencies easily. For using vcpkg with CMake, check out the documentation: https://github.com/microsoft/vcpkg/blob/master/docs/users/integration.md#cmake-integration

@stevapple
Copy link
Contributor Author

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.

2 participants