0

I have a library like the following in my bazel build file for C++:

cc_library(
    name = "mylib",
    srcs = [
        "main.cpp",
        "file1.cpp",
        "file2.cpp",
        ...
    ],
    hdrs = [
        "main.h",
        "file1.h",
        "file2.h",
        ...
    ],
    features = [
        "treat_warnings_as_errors",
        "strict_warnings",
        "additional_warnings",
    ],
    deps = [
        "my_dependency1",
        "my_dependency2",
        "third_party_dependency",
        ...
    ],
)

I need the constraints specified in features to be applied to all source files, except to third_party_dependency which is used by file1.

What I tried was removing file1 from mylib, putting it in a new library (i.e. mylib2) and then adding that lib to mylib as a dependency. The only problem is that I don't want the whole file1 to scape from the constraints, only third_party_dependency.

Is there any way to do that?

Maf
  • 696
  • 1
  • 8
  • 23
  • I woder if I can try this approach: https://stackoverflow.com/questions/3308523/how-to-eliminate-external-lib-third-party-warnings-in-gcc – Maf Feb 16 '22 at 10:20

1 Answers1

0

My solution for this was creating a new library as a wrapper for third_party_dependency not to mess up with third party code and on that second library I just had to add #pragma GCC system_header on the header file so that my gcc compiler ignores that file.

redits for How to eliminate external lib/third party warnings in GCC

Maf
  • 696
  • 1
  • 8
  • 23