Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable selection of static vs shared builds #595

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kino-dome
Copy link

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.

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 kino-dome mentioned this pull request Apr 25, 2020
@AdamLaurie
Copy link
Member

@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.

@kino-dome
Copy link
Author

kino-dome commented May 5, 2020

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?

@AdamLaurie
Copy link
Member

I believe the current default is to build both.

@kino-dome
Copy link
Author

kino-dome commented May 11, 2020

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!

@nh2
Copy link

nh2 commented Jul 13, 2023

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.

MauAbata added a commit to MauAbata/libnfc that referenced this pull request Oct 5, 2023
@ikspress ikspress mentioned this pull request Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants