简体   繁体   中英

How to disable clang warnings for protobuf generation in CMakeList.txt

I am new to Cmake/protobuf domain

In my CMakeList.txt I have set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=google-*,cppcoreguidelines-*") for linter warnings.

Also I include Catkinized gRPC Package for protobuf

find_package(catkin REQUIRED COMPONENTS grpc)

generate_proto(......)

When I compile this project, I am seeing a lot of warnings for file_name.pb.cc files

Is there any way to disable clang linter for an auto-generated files or specific targets?

It is relatively difficult to exclude specific source files from clang-tidy, because cmake generates a list of all source files of each clang-tidy activated target and passes that to clang-tidys command line.

If you enable clang-tidy only for one or more specific targets and generate your own protobuf files you can separate your protobuf stuff into a static library and not enable clang-tidy for that target. With ROS, I would advise you to only run clang-tidy on your own targets:

set_target_properties( myAwesomeTarget
    PROPERTIES CXX_CLANG_TIDY "clang-tidy;-checks=google-*,cppcoreguidelines-"
)

If you want to keep the global clang-tidy, you can disable clang-tidy for single targets in the same manner:

set_target_properties( myAwesomeTarget
    PROPERTIES CXX_CLANG_TIDY ""
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM