【发布时间】:2022-11-20 10:14:16
【问题描述】:
Take glm as an example. I currently have
new_local_repository(
name = "glm",
build_file = "third_party/glm/BUILD",
path = "third_party/glm/local",
)
in my WORKSPACE file. Here is third_party/glm/BUILD
cc_library(
name = "glm",
srcs = ["local/glm/detail/glm.cpp"] + glob([
"local/glm/**/*.hpp",
"local/glm/**/*.h",
"local/glm/**/*.inl",
]),
includes = ["local"],
visibility = ["//visibility:public"],
)
My goal is to make the details of providing of glm transparent. With the current setup I can
#include "glm/glm.hpp"
from some other file, keeping the include site oblivious to whatever I'm doing with bazel.
Is this a good idea? With this setup if -isystem /usr/include is part of the compile commands, which would be the case unless I'm building with a fully standalone toolchain, "glm/glm.hpp" will silently be found in that directory if something goes wrong with my bazel config. I would personally prefer #include "third_party/glm/glm.hpp", but that would require me to use this name as the top level directory of glm, so that I can then pass
includes = ["."],
in glm's cc_library. Is there a middle ground here which would let me decide on my directory structure independently and allow me to map it such that the contents of the directory can be resolved through third_party/glm/glm.hpp?
【问题讨论】:
标签: c++ include bazel bazel-rules bazel-cpp