1

We have a project that includes protobuf files that get pre-compiled into C++ files. Unfortunately, those files (like the other source files in the project) get checked by clang-tidy and generate a large number of warnings.

The relevant top-level CMakeLists.txt statements are:

# For all targets
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE}; --header-filter=.)

# Generated protobufs
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/grpc_interface)

target_link_libraries(${PROJECT_NAME}
    # ...
    grpc_services
)

And the grpc_interface/CMakeLists.txt contains:

project(grpc_services)

set(PROTO_IMPORT_DIRS
    ${CMAKE_SOURCE_DIR}/protocols/protobuf/
)

set(PROTOS
    ${CMAKE_SOURCE_DIR}/protocols/protobuf/test_message.proto
)

add_library(${PROJECT_NAME} STATIC ${PROTOS})

target_link_libraries(${PROJECT_NAME}
    PUBLIC
        protobuf::libprotobuf
        gRPC::grpc++
)

get_target_property(GRPC_CPP_PLUGIN gRPC::grpc_cpp_plugin LOCATION)

protobuf_generate(
    TARGET ${PROJECT_NAME}
    IMPORT_DIRS ${PROTO_IMPORT_DIRS}
    LANGUAGE cpp
)

protobuf_generate(
    TARGET ${PROJECT_NAME}
    IMPORT_DIRS ${PROTO_IMPORT_DIRS}
    LANGUAGE grpc
    GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
    PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN}"
)

One option is to copy a .clang-tidy file that disables all warnings into the ${CMAKE_BINARY_DIR}/grpc_interface directory, but I think that that would still incur the time penalty of clang-tidy parsing those files.

The "grpc_services" target only contains generated files.

Is there a better way of disabling clang-tidy processing in just that folder?

0

1 Answer 1

1

Since the "grpc_services" target only contains generated files, you can just set the CXX_CLANG_TIDY target property on that target to be nothing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.