Fix -isystem
in favor of -I
flag for imported targets
#489
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem tackled
The compiler flag
-isystem
is used instead of-I
independently if the user specifies or not theSYSTEM
flag. The current behavior treats all targets asSYSTEM
targets, even when no one specified thisProposed solution
Set the NO_SYSTEM_FROM_IMPORTED to the given target. NOTE: This could be replaced by IMPORTED_NO_SYSTEM
By using
NO_SYSTEM_FROM_IMPORTED
thenwill be different (not the case right now) from:
Example workspace to use as a test bench
isystem_example.zip
This workspace can be used to play around with the change and actually see the difference on the build, and on the
Wall
outputWhere
-isystem
is populatedThe problem I found is by using this function in
CMakeLists.txt
ament_target_dependencies(header_only_consumer "header_only_library")
Is injecting the keyword
SYSTEM
to thetarget_include_directories
. This produces (on the example attached) a building line that includes a user-library as a system one-isystem
. Most modern compilers, use this flag to ignore all sorts of warnings, etc:Downstream behavior on consumer libraries
See the workspace attached, but basically, my humble header-only library has a very silly error that should be caught by the
-Wall
we instruct in theCMakeLists.txt
, but it's completely ignored since it's being treated as a system header (such asiostream
,vector
, etc). I know, if I have unit tests on the library the errors would be seen when compiling those tests, but this doesn't mean thatament
is still masking out these errorsIf you build the example workspace, no warnings (or errors) are reported, which for this case is wrong, since I haven't specified the flag
SYSTEM
in the build scriptWhere this "bug" was introduced
It's unclear to me, this seems like a change in CMake. There was some action about the
SYSTEM
flag some years ago, but this is not the problem:Warning
Although I'm convinced that the current behavior of
ament_target_dependencies
is not adequate (in terms ofCMake
usage) this change should be treated carefully, since it will probably make most builds out there at least start producing some warning