Skip to content
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

include order can cause the wrong headers to be used #130

Closed
wjwwood opened this issue Apr 12, 2018 · 8 comments
Closed

include order can cause the wrong headers to be used #130

wjwwood opened this issue Apr 12, 2018 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@wjwwood
Copy link
Contributor

wjwwood commented Apr 12, 2018

This manifested in this pr: ros2/rviz#243

Basically, the urdf from somewhere like /usr/include (not sure exactly where from) when they should have been found in the workspace where rviz was being built.

Catkin had a way to deal with this by sorting include directories by workspace folder order, placing all include paths outside of any of the workspaces last in the order. ament_cmake should provide a function to emulate this behavior in order to better support overlaying.

@mikaelarguedas or @dirk-thomas feel free to add more details if you have them.

Also, this new function should either be used everywhere or at least where it has been a problem before, and in either case the pr linked above should be fixed with this function as well.

@wjwwood wjwwood added the enhancement New feature or request label Apr 12, 2018
@dirk-thomas dirk-thomas added this to the bouncy milestone Apr 12, 2018
@mikaelarguedas mikaelarguedas added the ready Work is about to start (Kanban column) label May 7, 2018
@mikaelarguedas
Copy link
Contributor

this will be targeted post bouncy, removing the milestone.

@mikaelarguedas mikaelarguedas removed this from the bouncy milestone Jun 18, 2018
@dirk-thomas
Copy link
Contributor

A CMake function with that functionality already exists: ament_include_directories_order

And it is already being used within ament_target_dependencies:

ament_include_directories_order(ordered_include_dirs ${include_dirs})

Since the referenced PR collects the include directories manually the package needs to call ament_include_directories_order manually.

@wjwwood Can this ticket be closed?

@dirk-thomas
Copy link
Contributor

dirk-thomas commented Feb 20, 2019

Not relevant for the reported case of this ticket but after investigating another report I created #157 which fixes ament_include_directories_order on non-Windows platforms.

@dirk-thomas dirk-thomas added bug Something isn't working in review Waiting for review (Kanban column) and removed enhancement New feature or request ready Work is about to start (Kanban column) labels Feb 20, 2019
@dirk-thomas dirk-thomas self-assigned this Feb 20, 2019
@wjwwood
Copy link
Contributor Author

wjwwood commented Feb 20, 2019

I think it could be closed if the workaround in ros2/rviz#243 were replaced with use of this function.

I think we ought to be using it everywhere, but that's a systemic issue.

@dirk-thomas
Copy link
Contributor

I think it could be closed if the workaround in ros2/rviz#243 were replaced with use of this function.

Do you want to keep this ticket open until that has been addressed in the rviz repo? (If that isn't the case in the short term I would rather suggest creating a ticket in that repo instead.)

I think we ought to be using it everywhere, but that's a systemic issue.

Afaik we already do use ament_target_dependencies in numerous places. So I don't think it is a systemic issue. If there are any cases where we don't please point them out so we can change them.

@wjwwood
Copy link
Contributor Author

wjwwood commented Feb 20, 2019

Well, my original ask for this issue was to keep it open until the necessary feature was added and deployed in rviz and elsewhere:

Also, this new function should either be used everywhere or at least where it has been a problem before, and in either case the pr linked above should be fixed with this function as well.

-- #130 (comment)


I was unaware of the function and also unaware of any place where we were using it. I didn't realize we were using it in ament_target_dependencies(), but does this work if you call it multiple times per target?

Also, searching for target_include_directories() results in 204 matches across 83 files. So discounting a few instances inside of pure cmake packages and within ament_cmake, all of those cases could introduce a problem (as they are added outside of ament_target_dependencies). include_directories is less common, but is used in our googletest integration and in some random packages like laser_geometry and qt_gui_core, so those might an issue too (as I understand it).

Is there an example of how (or do you have an idea of how) to use this correctly when you need to add the include directory manually and with ament_target_dependencies? Do we just make sure they come after (or maybe before) ament_target_dependencies to avoid the issue?

At the very least we should address it in rviz. Since you suggested the fix in rviz originally (and because it's still a bit unclear to me how to do it along side ament_target_dependencies), can you have a look at the follow up to use this method to avoid it?

@dirk-thomas
Copy link
Contributor

but does this work if you call it multiple times per target?

Each call is separate from each other. So only the dependencies from a single call are ordered relatively to each other. Separate calls are adding the information in the order of the calls.

Is there an example of how (or do you have an idea of how) to use this correctly when you need to add the include directory manually and with ament_target_dependencies?

I am not sure what kind of example you are looking for. If you need to call both functions they will add the information to the target in the order you call them. Just as if you would call target_include_directories twice in vanilla CMake.

can you have a look at the follow up to use this method to avoid it?

I am sorry, but I simply don't have the bandwidth to start looking into making rviz pull requests. The usage of the function should be really trivial: just call ament_target_dependencies for all dependencies which adhere to the CMake variable "standard" and call vanilla CMake function for everything else afterwards (assuming those will be system dependencies).

@dirk-thomas
Copy link
Contributor

my original ask for this issue was to keep it open until the necessary feature was added and deployed in rviz and elsewhere:

I created ros2/ros2#658 to track the enhancement to use ament_target_dependencies wherever possible / beneficial / necessary (just for a better scope of the items rather than having it hidden in this repo).

@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants