Skip to content

Conversation

@BewareMyPower
Copy link
Contributor

Motivation

Currently we manage dependencies by ourselves:

  • When running unit tests in CI, dependencies are installed from the Debian package management tool apt
  • When verifying macOS build, dependencies are installed from the Homebrew package manager
  • When verifying Windows build, dependencies are installed via vcpkg but no versions are specified
  • When building pre-built binaries to release, dependencies are installed by scripts under pkg/ directories. These scripts download the source code according to dependencies.yaml and build

It makes the pre-built binaries never tested except for the simple manual tests when voting for a new release. As a result, regression like #363 could happen.

This patch aims at integrating vcpkg to manage dependencies for all platforms, not only for Windows.

Modifications

Integrate the CMakeLists.txt with vcpkg by:

  1. Introduce vcpkg as a submodule of this project
  2. Update vcpkg.json to specify dependency versions.
  3. Set CMAKE_TOOLCHAIN_FILE with the vcpkg.cmake in the submodule.

Then, we can simply use find_package to find all dependencies and depend on them via a target like CURL::libcurl to have all include directores and link libraries.

Update the unit-tests workflow to verify building the binaries via vcpkg to test. The README is also updated to show how much simpler to build with vcpkg now.

TODO

There are still some tasks that cannot be done by vcpkg:

  1. The static library (e.g. libpulsarwithdeps.a) that bundles all 3rd-party dependencies.
  2. The pre-built binaries are still built by scripts under ./pkg directory. Specifically, vcpkg does not work with GCC 4.8 so on CentOS 7 we still need to build dependencies manually.

So the previous CMakeLists.txt are retained and will be used if INTEGRATE_VCPKG is OFF (by default). They will be removed until the task above can be done by vcpkg in future.

@BewareMyPower BewareMyPower added this to the 3.5.0 milestone Dec 12, 2023
@BewareMyPower BewareMyPower self-assigned this Dec 12, 2023
@BewareMyPower BewareMyPower marked this pull request as draft December 12, 2023 06:56
@BewareMyPower BewareMyPower marked this pull request as ready for review December 12, 2023 07:05
@BewareMyPower BewareMyPower marked this pull request as draft December 12, 2023 07:07
@BewareMyPower BewareMyPower force-pushed the bewaremypower/vcpkg-integration branch 2 times, most recently from 2824d10 to a005a6b Compare December 12, 2023 07:41
@BewareMyPower BewareMyPower marked this pull request as ready for review December 12, 2023 07:41
@BewareMyPower BewareMyPower marked this pull request as draft December 12, 2023 07:42
@BewareMyPower BewareMyPower force-pushed the bewaremypower/vcpkg-integration branch from a005a6b to 29b857b Compare December 12, 2023 07:50
@BewareMyPower BewareMyPower marked this pull request as ready for review December 12, 2023 07:50
@BewareMyPower BewareMyPower marked this pull request as draft December 12, 2023 08:48
@BewareMyPower BewareMyPower marked this pull request as ready for review December 12, 2023 09:05
…nux, macOS)

### Motivation

Currently we manage dependencies by ourselves:
- When running unit tests in CI, dependencies are installed from the
  Debian package management tool `apt`
- When verifying macOS build, dependencies are installed from the
  Homebrew package manager
- When verifying Windows build, dependencies are installed via vcpkg but
  no versions are specified
- When building pre-built binaries to release, dependencies are
  installed by scripts under `pkg/` directories. These scripts download
  the source code according to `dependencies.yaml` and build

It makes the pre-built binaries never tested except for the simple
manual tests when voting for a new release. As a result, regression like
apache#363 could happen.

This patch aims at integrating vcpkg to manage dependencies for all
platforms, not only for Windows.

### Modifications

Integrate the CMakeLists.txt with vcpkg by:
1. Introduce vcpkg as a submodule of this project
2. Update `vcpkg.json` to specify dependency versions.
3. Set `CMAKE_TOOLCHAIN_FILE` with the `vcpkg.cmake` in the submodule.

Then, we can simply use `find_package` to find all dependencies and
depend on them via a target like `CURL::libcurl` to have all include
directores and link libraries.

Update the `unit-tests` workflow to verify building the binaries via
vcpkg to test. The README is also updated to show how much simpler to
build with vcpkg now.

### TODO

There are still some tasks that cannot be done by vcpkg:
1. The static library (e.g. `libpulsarwithdeps.a`) that bundles all
   3rd-party dependencies.
2. The pre-built binaries are still built by scripts under `./pkg`
   directory. Specifically, vcpkg does not work with GCC 4.8 so on
   CentOS 7 we still need to build dependencies manually.

So the previous CMakeLists.txt are retained and will be used if
`INTEGRATE_VCPKG` is OFF (by default). They will be removed until the
task above can be done by vcpkg in future.

We also need to update `dependencies.yaml` to be consistent with
`vcpkg.json` if all tasks above cannot be replaced by vcpkg.
@BewareMyPower BewareMyPower force-pushed the bewaremypower/vcpkg-integration branch from f5223e0 to 5244eed Compare December 12, 2023 11:21
Copy link
Member

@Demogorgon314 Demogorgon314 left a comment

Choose a reason for hiding this comment

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

I tested it on M1 macOS, it works well. Great work!

@shibd
Copy link
Member

shibd commented Dec 13, 2023

I will review it today.

- [libcurl](https://curl.se/libcurl/)
- [openssl](https://github.com/openssl/openssl)
Since it's integrated with vcpkg, see [vcpkg#README](https://github.com/microsoft/vcpkg#readme) for the requirements. See [LEGACY_BUILD](./LEGACY_BUILD.md) if you want to manage dependencies by yourself or you cannot install vcpkg in your own environment.

Copy link
Member

Choose a reason for hiding this comment

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

We need to add a link to vcpkg.json to explain what version of is dependency

@BewareMyPower BewareMyPower merged commit 7baa312 into apache:main Dec 15, 2023
@BewareMyPower BewareMyPower deleted the bewaremypower/vcpkg-integration branch December 15, 2023 08:44
BewareMyPower added a commit to streamnative/pulsar-client-cpp that referenced this pull request Jul 4, 2024
### Motivation

Currently we manage dependencies by ourselves:
- When running unit tests in CI, dependencies are installed from the
  Debian package management tool `apt`
- When verifying macOS build, dependencies are installed from the
  Homebrew package manager
- When verifying Windows build, dependencies are installed via vcpkg but
  no versions are specified
- When building pre-built binaries to release, dependencies are
  installed by scripts under `pkg/` directories. These scripts download
  the source code according to `dependencies.yaml` and build

It makes the pre-built binaries never tested except for the simple
manual tests when voting for a new release. As a result, regression like
apache#363 could happen.

This patch aims at integrating vcpkg to manage dependencies for all
platforms, not only for Windows.

### Modifications

Integrate the CMakeLists.txt with vcpkg by:
1. Introduce vcpkg as a submodule of this project
2. Update `vcpkg.json` to specify dependency versions.
3. Set `CMAKE_TOOLCHAIN_FILE` with the `vcpkg.cmake` in the submodule.

Then, we can simply use `find_package` to find all dependencies and
depend on them via a target like `CURL::libcurl` to have all include
directores and link libraries.

Update the `unit-tests` workflow to verify building the binaries via
vcpkg to test. The README is also updated to show how much simpler to
build with vcpkg now.

### TODO

There are still some tasks that cannot be done by vcpkg:
1. The static library (e.g. `libpulsarwithdeps.a`) that bundles all
   3rd-party dependencies.
2. The pre-built binaries are still built by scripts under `./pkg`
   directory. Specifically, vcpkg does not work with GCC 4.8 so on
   CentOS 7 we still need to build dependencies manually.

So the previous CMakeLists.txt are retained and will be used if
`INTEGRATE_VCPKG` is OFF (by default). They will be removed until the
task above can be done by vcpkg in future.

We also need to update `dependencies.yaml` to be consistent with
`vcpkg.json` if all tasks above cannot be replaced by vcpkg.

(cherry picked from commit 7baa312)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants