ament / ament/ament_cmake

[Windows] dllexport support for ament_cmake

Aperta
#201 8 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
CMake
Stelle
125
Fork
147
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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/).

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.