Enable selection of static vs shared builds
By removing the hard-coded SHARED flag in ADD_LIBRARY and setting the ARCHIVE DESTINATION to the library install path, you can choose which type of build you want by passing a BUILD_SHARED_LIBS flag when configuring.
@kino-dome thanks for the contribution but we'd need some documentation added to README.md to cover this option as we as confirmation that default build hasn't changed if no action is taken.
I can add that to the docs, no problem. Also if you want to force a default type, we can do it using cmake's option() method and say for instance option( BUILD_SHARED_LIBS "Build libnfc as a shared library. " ON ). May I ask what should the default type be for libnfc, shared or static?
I believe the current default is to build both.
The default was to build .so libs for libnfc and .a for nfc-tools I believe. I'm sure that at least for libnfc itself, it only built shared libs and I couldn't make it to build static libs, hence this PR.
@AdamLaurie Let me know if I should add the mentioned option() parameter and add documentation. Thanks!
This would be very useful to have for static building of executables.
The proposed change looks good to me, this is how many CMake projects do it.
@kino-dome I propose to also improve libnfc.pc.in such that Libs.private is generated to include e.g. the libusb dependency, so that static linking will work out-of-the-box for projects that use pkg-config to discover libnfc's dependencies.