Skip to content

Support specifying the C++ standard for some higher dependencies #269

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 3 commits into from
May 16, 2023

Conversation

BewareMyPower
Copy link
Contributor

Fixes #268

Motivation

When users build from source with a dependency that requires a higher C++ version than 11, it will fail because currently the C++ standard is pinned to 11. For example, the latest GTest requires C++14 now. So currently there is no way to build the tests except modifying the CMakeLists.txt file.

Modifications

Make CMAKE_CXX_STANDARD configurable and test it for the macOS workflow because the gtest dependency installed from brew requires C++14. Add the description into the README for it.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

Fixes apache#268

### Motivation

When users build from source with a dependency that requires a higher
C++ version than 11, it will fail because currently the C++ standard is
pinned to 11. For example, the latest GTest requires C++14 now. So
currently there is no way to build the tests except modifying the
CMakeLists.txt file.

### Modifications

Make `CMAKE_CXX_STANDARD` configurable and test it for the macOS
workflow because the `gtest` dependency installed from `brew` requires
C++14. Add the description into the README for it.
@tisonkun
Copy link
Member

For reference - another way is pinning the version of gtest, like gtest.cmake in Kvrocks.

@BewareMyPower
Copy link
Contributor Author

another way is pinning the version of gtest

Yes. But for most C++ developers, it's still much easier to install the binary dependencies via the default package manager on Linux and macOS

The FetchContent feature of CMake just downloads the source code. It still needs to build and install the dependencies. And as you can see we still need to pay some extra efforts to it: https://github.com/apache/incubator-kvrocks/blob/75db3e42df8a715339abaf02d640f3c62d43304a/cmake/utils.cmake

Actually, we can achieve this goal via Vcpkg as well. Vcpkg can specify dependency versions. See example here: https://github.com/apache/pulsar-client-python/pull/23/files#diff-e62a7794d36dac6a2bbd197522dfe4d80d8d77f2e54e4772271e14e0103829e1

But still, for development, installing binaries directly will be much easier unless the dependencies are depended by source.

@BewareMyPower BewareMyPower merged commit 191a6b4 into apache:main May 16, 2023
@BewareMyPower BewareMyPower deleted the bewaremypower/cxx-standard branch May 16, 2023 02:59
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Jun 4, 2023
### Motivation

We don't need to install `boost-python3`, which was required for the
Python wrapper that is independent now. And the latest `googletest`
dependency requires the C++14 support so that we need to pass an extra
CMake option for it. See apache#269
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.

[Bug] C++ versions less than C++14 are not supported.
3 participants