Skip to content
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

Add C++ version for bazel #2525

Closed

Conversation

dnmiller
Copy link

Description

When adding Catch2 to the bazel workspace, the bazel build of the static libraries will fail if the C++ version of the project is less than C++14 due to use of std::enable_if_t. This calls out the C++ version explicitly in the compilation.

GitHub Issues

Sort of related to #2462 if you're using bazel to manage dependencies instead of a package manager.

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #2525 (fbf8a65) into devel (359542d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##            devel    #2525   +/-   ##
=======================================
  Coverage   91.54%   91.54%           
=======================================
  Files         183      183           
  Lines        7562     7562           
=======================================
  Hits         6922     6922           
  Misses        640      640           

@horenmar horenmar added the Building and Packaging Issues affecting build/packaging scripts and utilities label Sep 16, 2022
@horenmar
Copy link
Member

How does Bazel handle it if the user wants to use C++17?

@dnmiller
Copy link
Author

How does Bazel handle it if the user wants to use C++17?

This actually only applies to the library binaries - the user can still use C++17 for their own targets.

@Vertexwahn
Copy link
Contributor

Vertexwahn commented Sep 18, 2022

Adding copts = ["-std=c++14"] does not make sense. Since GCC and Visual Studio handle it in a different way, we have configs for this. See .bazelrc.

bazel build --config=gcc9 //... will add -std=c++2a - if you need -std=c++14 than add a config to bazel.rc e.g. build:my_config --cxxopt=-std=c++14. You can then use bazel build --config=my_config //.... copts = ["-std=c++14"] will lead to compiler warnings on Visual Studio.

@horenmar
Copy link
Member

horenmar commented Oct 4, 2022

This should be no longer needed.

@horenmar horenmar closed this Oct 4, 2022
@dnmiller
Copy link
Author

dnmiller commented Oct 4, 2022

So I have a use case where the bazel config strategy doesn't work - an old embedded compiler that doesn't know -std=c++14, but unit tests that run on a PC with gcc-10.

Maybe this is more of a bazel deficiency. In the meanwhile I can patch BUILD.bazel in my WORKSPACE file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Building and Packaging Issues affecting build/packaging scripts and utilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants