cieslarmichal / faker-cxx

C++ Faker library for generating fake (but realistic) data.
https://cieslarmichal.github.io/faker-cxx/
MIT License
251 stars 102 forks source link

Add support for shared library on Windows (Visual Studio) #753

Closed uilianries closed 4 days ago

uilianries commented 5 days ago

Is your feature request related to a problem? Please describe.

It would be great if the project could provide shared libraries (.dll) and expose symbols via .lib files when build on Visual Studio.

Describe the solution you'd like

The CMake offers the feature WINDOWS_EXPORT_ALL_SYMBOLS, which exposes all symbols to a .lib file, but it's considered a bad practice.

On the other hand, it's possible to use GenerateExportHeader to manage __declspec and only add the keyword to those methods that should be exported. Much safer.

As third alternative, would be possible adding a .def file to CMake, listing only those symbols that should be exported. It's harder to maintain, because devs should not forget to update both sources and .def file.

Describe alternatives you've considered

Not support shared libraries on Windows and making it explicit in the project.

Additional context

So far, the CI only builds static libraries, so we didn't detect this limitation before.

cieslarmichal commented 5 days ago

Very good idea, let's do that.