2

We are using Robot Operative System (ROS) in a standalone C++ application. Dependencies to ROS are linked in using

target_include_directories(${LIBRARY}
 /opt/ros/foxy/include/
)

This is probably not best practice, but ROS dependencies are on the way of being cut from the project. Now the issue is that we want to run clang-tidy over the repository, and this setup makes clang-tidy check ROS which we off course do not want.

An easy way to disable clang-tidy is by just setting an environment variable for a target empty, like so

set_target_properties(${MY_TARGET}
            PROPERTIES CXX_CLANG_TIDY ""
        )

The problem is that ROS is not a proper Cmake target. An idea would be to make a "fake" ros target, just so clang-tidy would know what files to skip. Is this feasible?

Martin
  • 151
  • 2
  • 9
  • Does this answer your question? [cmake + clang\_tidy - disable checking in directory](https://stackoverflow.com/questions/58338202/cmake-clang-tidy-disable-checking-in-directory) – pablo285 Sep 23 '21 at 09:35
  • No, the libraries I want to ignore are outside the repository and I do not have the option to put a .clang-tidy file there. – Martin Sep 23 '21 at 16:13
  • Huh, seems like a tough problem. Linking [an older SO question](https://stackoverflow.com/a/61003765/6069586) about it. Maybe it works for you? – JWCS Sep 24 '21 at 17:24
  • Yes, formulating a proper regex for header filter might be the solution here. Thanks. – Martin Sep 29 '21 at 09:17
  • The difficulty here though is that it seems that clang-tidy does not support lookahead in regular expressions (anymore?) . I have tried the approach above. Then I also found this in an LLVM mailinglist, requesting lookahead: https://lists.llvm.org/pipermail/cfe-dev/2015-November/046203.html – Martin Sep 29 '21 at 09:30
  • AFAIK clang-tidy has always used POSIX ERE which doesn't support lookahead. – pablo285 Sep 30 '21 at 12:35
  • Here and there people claim that they used lookahead and clang-tidy. But, it seems clang-tidy just ignores every header if you get `-header-filter` wrong. So people might have ignored everything, thinking they just ignored a certain selection. – Martin Oct 04 '21 at 15:28

0 Answers0