nimbuscontrols / EIPScanner

Free implementation of EtherNet/IP in C++
https://eipscanner.readthedocs.io/en/latest/
MIT License
224 stars 90 forks source link

Avoid building both a shared and static library #85

Open JohannesKauffmann opened 1 year ago

JohannesKauffmann commented 1 year ago

There is no reason to unconditionally build both variants. It increases compile times, and consumers already know whether or not they want a static or shared artifact. Instead, use a standard CMake construct to build either one of them.

To allow users to override static vs shared for EIPScanner only, use a new variable called EIPScanner_SHARED_LIBS: If set, our add_library() will create a shared library, if not, a static library is created. Building a static library by default also matches the default behaviour of add_library().

This still allows users to specify BUILD_SHARED_LIBS on the command line as an ultimate override, but at the same time avoids having BUILD_SHARED_LIBS be the only option for building static vs shared.