ament / ament/ament_cmake

[Windows] dllexport support for ament_cmake

Open
#201 8 comments 1 reaction 0 assignees View on GitHub
Dominant language
CMake
Stars
125
Forks
147
PR merge metrics
No merged PRs in 30d

Description

On Windows, Microsoft C/C++ compiler comes with a concept of `dllexport` and `dllimport`. In order to make a DLL library header able to be consumed by the downstream project, the function, class, or data declaration needs to be decorated with the correct attributes.

`CMake` provides [`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS`](https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/) and attempts to fix the problem less intrusive to the existing code base. However, it still comes with limitation, for example, it doesn't support `static` member, and it will bloat the size of the generated imported library because it exhaustively exposes whatever it can do.

In ROS1, I explored a way to enable `dllexport` and `dllimport` for a catkin-based project. Here is the [pull request](https://github.com/ros-visualization/rviz/pull/1335) for `rviz` to show the example. This change makes use of `generate_export_header` and with some careful steps to stage and install it to a place to be consumed within and across catkin packages.

I would like to use this ticket to discuss:
1. Any feedback on the `generate_export_header` approach?
2. Would it make sense to make it part of `ament_cmake` requirements or should it be just step-by-step guidance in the [`ament_cmake User Documentation`](https://index.ros.org/doc/ros2/Tutorials/Ament-CMake-Documentation/).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.