4

My project is transitioning to Bazel from CMake and I am including a snapshot of Abseil by checking it into a third_party/ top-level directory within our repository. I need to support both build systems during the transition, so I created CMakeLists.txt files and noticed that quite a lot of warnings need to be disabled for the Abseil headers to compile.

For CMake, this okay because I can include the headers where I use them by using the #include <absl/strings/str_cat.h> syntax. This tells my compiler that it's a system header and to ignore the warnings so I don't have to disable them globally.

For Bazel, though, I get this error:

error: 'absl/strings/str_cat.h' file not found with include; use "quotes" instead

Is there a way to tell Bazel to allow the <>-style includes? Is there another way to disable warnings just for these headers without also disabling them for the whole project?

Sydius
  • 13,567
  • 17
  • 59
  • 76
  • Can't you add the include directory in Bazel? It talks about certain flags to add here: https://docs.bazel.build/versions/master/bazel-and-cpp.html#include-paths. – user2205930 Sep 30 '17 at 18:17
  • Could you add a symbolic link in the system include path to point to your needed directory? Perhaps Bazel will see this as the same as . – user2205930 Sep 30 '17 at 18:18
  • Could you share what those warnings are? Abseil has a goal of being warning free, even for Visual Studio. (Google internally has a lot of warnings enabled, with warnings-as-errors turned on, so we're sympathetic to wanting those compiler warnings not to be triggered.) – jorgbrown Oct 02 '17 at 21:12

1 Answers1

0

By default bazel doesn't emit any cc-library-specific include (-I) directory flags for compile actions. Since include lookup is not free we rely on a single rooted header hierarchy. But you can tell bazel to add custom include directories by using includes on a given cc_library. Or, preferably, use strip_include_prefix and include_prefix.

hlopko
  • 3,100
  • 22
  • 27