silnrsi / graphite

Graphite is a "smart font" system developed specifically to handle the complexities of lesser-known languages of the world.
http://graphite.sil.org/
Other
147 stars 44 forks source link

Build both shared and static library #12

Closed jeroen closed 7 years ago

jeroen commented 7 years ago

This enabled building a static library, in addition to a shared one. Windows has a different linking system so this is only enabled for unix. References:

I need this myself for building standalone applications, but I think it is generally useful.

Thank you for your review!

jeroen commented 7 years ago

@tim-eves could you have a quick look? Thanks!

jeroen commented 7 years ago

Anyone please? This is a very small fix that would be super helpful.

tim-eves commented 7 years ago

Hi jeroen,

Sorry for the delay this, slipped under my radar. There's no problem with adding a static lib output, though I'll want to take a quick look as we already build a static version (in pieces) for testing and I want to check if that will suffice, if not i'll merge yours in tomorrow (my time, so probably more like 24 hours)

jeroen commented 7 years ago

Hi @tim-eves,

Thanks for your reply. I mostly use graphite via homebrew and the recipe uses the standard steps (cmake, make install) which does not seem to produce static libs by default. I am hoping that this would fix that. I'm not a cmake expert though, perhaps there is an alternate way.

tim-eves commented 7 years ago

I'd like to try an alternaive way first: I've added support in branch switchable-static-shared-library-build, to have cmake build libgraphite2 as static instead of shared, rather than produce both (which can be done using this approach but with two build directories one configured each way). This is controlled by the BUILD_SHARED_LIBS:BOOL option by using ccmake or passing it to the cmake invocation, like so cmake .. -DBUILD_SHARED_LIBS:BOOL=OFF. This defaults to ON so as to not change current expectations for a default build for existing packaging e.g. on Debian or Fedora. As this allows an easy way to make a static version I hope this will meet your need. I don't know enough about homebrew to know how you'd pass build options (of which graphite already has several) to cmake without editing the formula (which I notice is a supported operation with brew edit <formula name>). I'm reluctant to just build a static version and produce both forms, as that requires building a 2nd copy, doubling build times, without having tried this option first and even then I'd be inclined to make building both an option rather than the default, and lastly by doing some more significant modifications to the build system it might be possible avoid the duplicate build cost but before doing that and testing etc I'd like to give this idea a try. I'm going to close this pull request and ask if this doesn't work for you please open an issue so we can continue the discussion there since I'm unlikely to use this code as is.