Build of unittests fails due to warnings treated as errors on gcc 13 and clang-tidy 17
Summary
Building the unit tests fails with 6 warnings treated as errors:
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:29:24: error: no header providing "caosdb::utility::base64_encode" is directly included [misc-include-cleaner,-warnings-as-errors]
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:30:13: error: no header providing "grpc::AuthContext" is directly included [misc-include-cleaner,-warnings-as-errors]
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:32:13: error: no header providing "grpc::Status" is directly included [misc-include-cleaner,-warnings-as-errors]
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:33:13: error: no header providing "grpc::string_ref" is directly included [misc-include-cleaner,-warnings-as-errors]
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:41:69: error: no header providing "grpc::string" is directly included [misc-include-cleaner,-warnings-as-errors]
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:41:83: error: no header providing "grpc::string" is directly included [misc-include-cleaner,-warnings-as-errors]
(.env) joscha@XXX:~/caosdb/src/caosdb-cpplib/build$ cmake --build .
[ 1%] Generating include/caosdb/info/v1/main.pb.cc, include/caosdb/info/v1/main.grpc.pb.cc, include/caosdb/entity/v1/main.pb.cc, include/caosdb/entity/v1/main.grpc.pb.cc, include/caosdb/info/v1/main.pb.h, include/caosdb/info/v1/main.grpc.pb.h, include/caosdb/entity/v1/main.pb.h, include/caosdb/entity/v1/main.grpc.pb.h
[ 3%] Building CXX object CMakeFiles/caosdb_grpc.dir/include/caosdb/info/v1/main.pb.cc.o
[ 5%] Building CXX object CMakeFiles/caosdb_grpc.dir/include/caosdb/info/v1/main.grpc.pb.cc.o
[ 7%] Building CXX object CMakeFiles/caosdb_grpc.dir/include/caosdb/entity/v1/main.pb.cc.o
[ 9%] Building CXX object CMakeFiles/caosdb_grpc.dir/include/caosdb/entity/v1/main.grpc.pb.cc.o
[ 11%] Linking CXX shared library lib/libcaosdb_grpc.so
[ 11%] Built target caosdb_grpc
[ 13%] Building CXX object CMakeFiles/caosdb.dir/src/caosdb/authentication.cpp.o
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:29:24: error: no header providing "caosdb::utility::base64_encode" is directly included [misc-include-cleaner,-warnings-as-errors]
22 | #include <grpcpp/security/credentials.h> // for MetadataCredentialsPlugin
23 | #include <map> // for multimap
24 | #include <memory> // for allocator, shared_ptr
25 | #include <string> // for basic_string, operator+
26 | #include <utility> // for pair, move, make_pair
27 |
28 | namespace caosdb::authentication {
29 | using caosdb::utility::base64_encode;
| ^
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:30:13: error: no header providing "grpc::AuthContext" is directly included [misc-include-cleaner,-warnings-as-errors]
22 | #include <grpcpp/security/credentials.h> // for MetadataCredentialsPlugin
23 | #include <map> // for multimap
24 | #include <memory> // for allocator, shared_ptr
25 | #include <string> // for basic_string, operator+
26 | #include <utility> // for pair, move, make_pair
27 |
28 | namespace caosdb::authentication {
29 | using caosdb::utility::base64_encode;
30 | using grpc::AuthContext;
| ^
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:32:13: error: no header providing "grpc::Status" is directly included [misc-include-cleaner,-warnings-as-errors]
23 | #include <map> // for multimap
24 | #include <memory> // for allocator, shared_ptr
25 | #include <string> // for basic_string, operator+
26 | #include <utility> // for pair, move, make_pair
27 |
28 | namespace caosdb::authentication {
29 | using caosdb::utility::base64_encode;
30 | using grpc::AuthContext;
31 | using grpc::MetadataCredentialsPlugin;
32 | using grpc::Status;
| ^
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:33:13: error: no header providing "grpc::string_ref" is directly included [misc-include-cleaner,-warnings-as-errors]
23 | #include <map> // for multimap
24 | #include <memory> // for allocator, shared_ptr
25 | #include <string> // for basic_string, operator+
26 | #include <utility> // for pair, move, make_pair
27 |
28 | namespace caosdb::authentication {
29 | using caosdb::utility::base64_encode;
30 | using grpc::AuthContext;
31 | using grpc::MetadataCredentialsPlugin;
32 | using grpc::Status;
33 | using grpc::string_ref;
| ^
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:41:69: error: no header providing "grpc::string" is directly included [misc-include-cleaner,-warnings-as-errors]
23 | std::multimap<grpc::string, grpc::string> *metadata)
| ^
/home/joscha/caosdb/src/caosdb-cpplib/src/caosdb/authentication.cpp:41:83: error: no header providing "grpc::string" is directly included [misc-include-cleaner,-warnings-as-errors]
23 | std::multimap<grpc::string, grpc::string> *metadata)
| ^
126234 warnings generated.
Suppressed 126239 warnings (126228 in non-user code, 11 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings treated as errors
gmake[2]: *** [CMakeFiles/caosdb.dir/build.make:76: CMakeFiles/caosdb.dir/src/caosdb/authentication.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:211: CMakeFiles/caosdb.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
Expected Behavior
Building the unit tests should not fail.
Actual Behavior
See above
Steps to Reproduce the Problem
- Follow build instructions for building the unittests
cmake -B . -D CMAKE_BUILD_TYPE=Debug ..
- Observe compilation error
Specifications
- Version: 0.2.2
- Platform: Fedora 39
- gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7)
- cmake version 3.27.7
- LLVM version 17.0.6 (clang-tidy --version)
Possible fixes
Find and use direct includes for the types.
Additional context
This issue is due to the misc-include-cleaner
present in clang-tidy since version 17.
Edited by Joscha Schmiedt