Run clang-tidy only?

I have Jenkins running cmake with -DCMAKE_C_CLANG_TIDY=clang-tidy -DCMAKE_CXX_CLANG_TIDY=clang-tidy but, since the warnings format of clang-tidy is basically the same than the one from gcc/clang, the Jenkins Warnings NG plugin can’t differentiate between them.

We use incremental builds and, since clang-tidy can be quite time consuming, is really nice that cmake will run it only on the files that have changed. I don’t want to lose that, but I would like Jenkins to show me the clang-tidy warnings as a different category to the compiler warnings. So I would like to be able to do something similar to:

  • cmake --build . --target clang-tidy 2>&1 | tee clang-tidy.warnings
  • cmake --build . 2>&1 | tee compiler.warnings

i.e. first run clang-tidy only. Is it possible?

In general, no. Cases where it definitely doesn’t work:

  • running on generated sources if the generation of those sources requires compilation of other parts
  • generated headers made available through the dependency tree

CMake doesn’t have the logic to convince itself that the above are not true in any given case, so coupling with the only way it does it today.

Aren’t there trailer notes on the warning messages indicating where they come from (e.g., [-Wformat=security] or [some-clang-tidy-checker-name])? Can’t that be used to differentiate the warning messages? Perhaps an enhancement for that plugin?

I’m quite sure they can be reliably differentiated, yes. I wanted a fix for “now”, not for “report plus wait for next plugin release”, but I will indeed see if I can get that fixed.