Repository navigation
Replies: 1 comment
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm using bazel with bzlmod build my c++ project. I found that bazel add
-iquote external/xxx-lib~versionfor all my deps.From some [discussion](RobotLocomotion/drake#8197), I found that if the lib use hdrs to publish headers, then bazel will add a
-iquoteto the libs root path.This seems a bit redundant to me, the other headers in the libs root path should be invisible to the outside world.
I have write an example to explain this
For my lib
For my bin
The output of my binary is
It is not difficult to find the reason from the compilation command given by bazel.
-iquote external/bazel_remote_test~20231204.1-test-iquoteis before than-Isrc.so compiler will find the
util/util.hin the external folder.But from the https://bazel.build/reference/be/c-cpp#hdrs
(To be honest, it seems to me that Headers in
srcsshould only be directly included by files in srcs.)Of course I could use
#include "src/util/util.h"to circumvent this problem in this example.But when the number of my dependencies increases rapidly, I still need to care about file path conflicts between this repo and other dependencies, which is obviously not elegant enough.
I don’t know if I missed some key documents. Is there any way to solve this problem?
All reactions