-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gtest headers as system headers #321
Conversation
add SYSTEM parameter to target_include_directories so that GTEST headers are treaded as sysetem headers, and no warnings are produced. Signed-off-by: Peter Kohout <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me. System include directories are also ignored from dependency calculations, but I wouldn't expect gtest
sources to change. @clalancette thoughts against?
If I remember properly, the main reason we don't use system includes is because overlays then don't work right. But this is based on a vague memory from a while ago, so it bears testing again. |
Can I ask what this waits for? If there is something I can help it I am willing to do it. |
Looking at this further, I actually think this is the wrong thing to do (though others might disagree with me). This PR is essentially abusing the "system" connotations of There are 2 problems with that:
So I think this is the wrong way to go, but I'm happy to hear counter-arguments. |
Those are not warnings, those are errors because I use very strict settings for my code that I do not expect external headers to follow strictly. The -Wconversion is prime example of that. Generally, just the fact that I want to enforce some compiler options in my project does not mean it makes sense for other projects. This implies that I need a way to tell the compiler to ignore my options for third-party libraries which are not valid with these options. (Does not mean the code does not work!)
Why it should not work? The manpage explicitly states order at which the libraries are searched for. gcc scans The way I understand that sentece in the manpage is: You can use -I for the overrides, but you should not do it for vendor headers and use -isystem instead to do the overriding. This in spirit of what is written on the "system headers" section of documentation, when they motivate existence of -isystem due to: "The header files declaring interfaces to the operating system and runtime libraries often cannot be written in strictly conforming C. "
Just the EDIT: As a sidenote: I managed to spin up my custom "_add_gtest" macro is copy of ament_add_gtest() with just this change applied quite easily given that ament is documented pretty well, in case somebody wants to solve this too. |
Speaking as the one assigned, I haven't had the time to validate this patch doesn't break |
I'm worried about this change because we actually used to use SYSTEM for these headers in the past, and we reverted it. See #175 and #184 for some details (also ros/catkin#428 for a ROS 1 discussion of the same). |
I think this is worth looking at again. Since ROS 2 switched to imported targets instead of CMake variables (ros2/ros2#904), all includes from different ROS packages are passed as |
Circling back. @sloretz is right but based on ros2/ros2#1150 I think include directories and overlays have to be rethought. |
@sloretz With your recent investigations and fixes for overlays, do you think we still need this PR? |
Yes. From the perspective of overriding packages, the
|
Is there still any issue preventing the PR from getting merged? |
Can it be added to gmock too? |
Is there a reason this PR hasn't been merged yet? |
Actually, we went a slightly different way here in #408, where we made this SYSTEM PRIVATE instead. So I think this is redundant and unnecessary now, I'm going to close this out. |
Hi,
during building our ros2 code we noticed that the GTEST headers are not included as system headers but as normal include directory. This caues g++ to generate compiler warning caused by code in the include files from GTEST. Adding the SYSTEM argument to targent_include_directory see docs cmake does this.
Here is our concrete example.
With the non system include we get the following compile command, which causes the compile error below (interesting part is the
-I/opt/ros/foxy/src/gtest_vendor/include
):With the system include we get the follwoing compile command (which works). Now the headers are set via
-isystem /opt/ros/foxy/src/gtest_vendor/include
, preventing the compiler from generating the-Wsuggest-override
warningsIf there is a reason why the SYSTEM arg is not used, please let me know, right now I don't see any. Then I will have to find another solution to get it working.
All the best,
Peter