Issue |
129254
|
Summary |
[CMake] `llvm_add_library` does not preserve `SYSTEM` property for headers in `OBJECT` mode
|
Labels |
new issue
|
Assignees |
|
Reporter |
ingomueller-net
|
If a `LINK_LIB` dependency is passed to `llvm_add_library` together with the `OBJECT` keyword (or with, both, the `STATIC` and `SHARED` keywords), then the include directories from that library use their `SYSTEM` marker.
As a consequence, these directories will be linked to with `-I` instead of `-isystem`, such that warnings will be reported, making it impossible to use `-Werror` if there are any warnings. I, thus, think that the `SYSTEM` property should be preserved.
I believe that this is due to some manual construction of dependencies and/or include directories for the `obj.XXX` target that is created in that case, which doesn't seem to preserve the `SYSTEM` property. I have tried a few ways to set that or related properties but failed and exhausted my CMake knowledge.
https://github.com/ingomueller-net/llvm-project/tree/llvm-add-library-system-headers contains a reproducer that adds the `Protobuf` library to a new target `MLIREmitCDialect2`. If CMake is configure with XXX, we can see the following output (note the `-I` flag):
```
$ grep MLIREmitCDialect2 build/compile_commands.json | grep protobuf
"command": "/usr/bin/clang++ ... -I/.../git/llvm-project/build-Debug/_deps/protobuf-src/src ... -o tools/mlir/lib/Dialect/EmitC/IR/CMakeFiles/obj.MLIREmitCDialect2.dir/EmitC.cpp.o -c .../git/llvm-project/mlir/lib/Dialect/EmitC/IR/EmitC.cpp"
```
If we remove the `OBJECT` keyword in the call to `llvm_add_library` as the comment indicates, then the library is included with `-isystem` instead of `-I`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs