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

Get Bazel build working again #2405

Closed
wants to merge 1 commit into from
Closed

Get Bazel build working again #2405

wants to merge 1 commit into from

Conversation

Vertexwahn
Copy link
Contributor

@Vertexwahn Vertexwahn commented Apr 1, 2022

This PR enables the Bazel build again.

Including generated headers using <...> instead of "..." does unfortunately not work using Bazel.

I am not 100% sure but I think including via "..." should be preferred in cpp files since this guarantees that not a system installed catch header file is included. I would suggest to change everything to "..."

@horenmar
Copy link
Member

horenmar commented Apr 2, 2022

I am not 100% sure but I think including via "..." should be preferred in cpp files since this guarantees that not a system installed catch header file is included. I would suggest to change everything to "..."

No.

The difference in the two include styles is that for #include "foo" the compiler first attempts to find foo in some implementation specific manner, and if that fails, it rewrites it into #include <foo> and then attempts to resolve that (in some implementation specific manner). This can lead to some fun.

This also means that #include "catch2/catch_user_config.hpp" is strictly looser than #include <catch2/catch_user_config.hpp>, and if it works, then the issue likely is that the catch_user_config.hpp file is created in a relative directory, because in practice, the difference for GCC is that "" include paths first check relative to the file being compiled, while <> include paths check compared to -Idir paths and built-in system paths.

The other option is that Bazel provides -iquoteDir, in which case it really shouldn't. (-iquote appends path to search locations for "" style includes, but not to <> style includes)

@Vertexwahn
Copy link
Contributor Author

Vertexwahn commented Apr 2, 2022

@horenmar I have seen some libs that prefer "quote" includes over includes (Eigen, GoogleTest, {fmt} which makes things easier for Bazel - but I think changing the code because of Bazel is not a good option.

I try to figure out if there is a way that works with keeping #include <catch2/catch_user_config.hpp>.

I initially tested this on Windows 10/11 and Visual Studio 2022 and it works there with #include <catch2/catch_user_config.hpp>.
But it does not work on Ubuntu 20.04 using GCC 9.

@Vertexwahn
Copy link
Contributor Author

#2399 will fix all issues

@Vertexwahn Vertexwahn closed this Apr 6, 2022
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.

None yet

2 participants