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

Remove visibility macros #539

Merged
merged 2 commits into from
Jul 26, 2024
Merged

Conversation

christophfroehlich
Copy link
Contributor

@christophfroehlich christophfroehlich commented Jul 21, 2024

As a consequence of ros-controls/ros2_control#1627 there is an include for HARWARE_INTERFACE_PUBLIC missing, causing the build of example_7 to fail.

As we've discussed and decided in ros-controls/ros2_controllers#1053, we wanted to remove all the visibility macros and use set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) instead. I took the chance to do so here.

Fixes #538 and also resolves #73

@christophfroehlich
Copy link
Contributor Author

👀 @traversaro

@henrygerardmoore
Copy link

Fixes build for me locally, but shouldn't lines such as

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME} PRIVATE "ROS2_CONTROL_DEMO_EXAMPLE_1_BUILDING_DLL")

be removed? This is lines 39-41 of example 1's CMakeLists but every example has similar lines

@christophfroehlich
Copy link
Contributor Author

christophfroehlich commented Jul 21, 2024

Ah, thanks for the review. I missed that

saikishor
saikishor previously approved these changes Jul 21, 2024
Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine as per my knowledge.

Thank you!

@christophfroehlich
Copy link
Contributor Author

@traversaro do you know if we need target_compile_definitions or similar for windows builds?

@traversaro
Copy link

@traversaro do you know if we need target_compile_definitions or similar for windows builds?

If you do not have any visibility macro, it is ok not to add any target_compile_definitions. As a general comment (in case someone reads this) also if you have the visibility macro it is not ideal to have code like:

target_compile_definitions(${PROJECT_NAME} PRIVATE "ROS2_CONTROL_DEMO_EXAMPLE_1_BUILDING_DLL")

as this will define the macro even if the target ${PROJECT_NAME} is a static library. The correct property to set is the DEFINE_SYMBOL (https://cmake.org/cmake/help/latest/prop_tgt/DEFINE_SYMBOL.html) of the target, or even better just use the default DEFINE_SYMBOL value that is <targetName>_EXPORTS .

Copy link

@traversaro traversaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes seems ok to me, thanks! As raised in the PR review, you can also remove the target_compile_definitions(${PROJECT_NAME} PRIVATE "ROS2_CONTROL_DEMO_EXAMPLE_7_BUILDING_DLL") code, but if there are no visibility headers that code is basically ignored.

@christophfroehlich
Copy link
Contributor Author

Changes seems ok to me, thanks! As raised in the PR review, you can also remove the target_compile_definitions(${PROJECT_NAME} PRIVATE "ROS2_CONTROL_DEMO_EXAMPLE_7_BUILDING_DLL") code, but if there are no visibility headers that code is basically ignored.

Thanks a lot for the review, I'll remove that dead code then ;)

@christophfroehlich christophfroehlich merged commit f92cc21 into master Jul 26, 2024
11 of 13 checks passed
@christophfroehlich christophfroehlich deleted the remove_visibility_macros branch July 26, 2024 12:10
mergify bot pushed a commit that referenced this pull request Jul 26, 2024
* Remove visibility macros

* Remove dead target_compile_definitions

(cherry picked from commit f92cc21)
mergify bot pushed a commit that referenced this pull request Jul 26, 2024
* Remove visibility macros

* Remove dead target_compile_definitions

(cherry picked from commit f92cc21)
christophfroehlich added a commit that referenced this pull request Jul 26, 2024
* Remove visibility macros

* Remove dead target_compile_definitions

(cherry picked from commit f92cc21)

Co-authored-by: Christoph Fröhlich <[email protected]>
christophfroehlich added a commit that referenced this pull request Jul 26, 2024
* Remove visibility macros

* Remove dead target_compile_definitions

(cherry picked from commit f92cc21)

Co-authored-by: Christoph Fröhlich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove visibiltiy macros Explain meaning of ROS2_CONTROL_DEMO_HARDWARE_PUBLIC in example headers
4 participants