How to Build with Extra Warning Flags without ROS Header Warnings?

asked 2019-04-15 11:57:39 -0500

ssnover gravatar image

updated 2019-04-15 12:05:49 -0500

jayess gravatar image

I'm attempting to enable the -Wextra and -Wall flags in my packages such that potential bugs can be caught from these warnings. Enabling these flags causes a huge cascade of warnings from ROS headers which can't be changed and so I'd like to ignore these warnings. Thus far, I've achieved the following for limiting warnings to their source:

add_library(my_lib <sources>)
target_compile_options(my_lib PRIVATE -Wall -Wextra)
    PRIVATE include ${catkin_INCLUDE_DIRS}
... <link libraries>

I know that the SYSTEM keyword prevents all of the libraries following it to not raise warnings with the -Isystem flag, which achieves what I want for inter-package warnings. But I want ROS headers to not raise warnings at all. I've tried doing three sections such as: PRIVATE include SYSTEM ${catkin_INCLUDE_DIRS} SYSTEM INTERFACE include ${catkin_INCLUDE_DIRS}, but this still causes errors to appear from ROS headers.

Has anyone achieved building ROS packages with more warnings enabled on their own source, but not on packages from other authors or the ROS middleware?

edit retag flag offensive close merge delete