bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.04k stars 1.95k forks source link

Support building against system libraries #934

Closed jmallach closed 2 years ago

jmallach commented 8 years ago

Hi Branimir,

My MAME package in Debian just got this bug report:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=838052

It is common in Debian and Fedora to build against system libraries if possible, and I'd be glad to be able to do so with the embedded copy of bgfx. Is there any way this can be done currently, or if not, could you consider adding the possibility for at least the ones present in the usual Linux distributions.

At least, freetype, libsquish would be nice to support.

Thanks!

bkaradzic commented 8 years ago

I have some modifications in libsquish. The problem with libsquish is that it's not supported at all by original author, so there is no way to push changes upstream so it sometime get to Debian repo.

FT2 is simpler, I just need to remove amalgamated version of library.

Anyhow bgfx has to build on platforms that don't have sane package systems, and I'll still distribute those libraries inside 3rdparty dir.

jmallach commented 8 years ago

Oh, you haven't heard the news. While getting libsquish packaged, Wookey looked at all the forks of the library already present in unrelated packages like MAME, looked at the differences and fed patches upstream. The result is the new upstream release that recently got published.

In particular, I believe your changes are here: https://sourceforge.net/p/libsquish/code/69/

Sure, distributing the lib in 3rdparty is very fine, I just want a way to tell the build system to not build that and link against the available shared library from the system instead.

jmallach commented 8 years ago

Other relevant links:

bkaradzic commented 8 years ago

Where is main repository?

jmallach commented 8 years ago

What do you mean with main repo? You can download libsquish here:

http://debian.mirror.constant.com/pool/main/libs/libsquish/

This directory includes .debs and the source tar.gz: http://debian.mirror.constant.com/pool/main/libs/libsquish/libsquish_1.14.orig.tar.gz

jimon commented 8 years ago

@jmallach On a side node, why it's important to be able to build against system libraries in a first place? Because usually in gamedev all 3rdparty code is bundled in.

jmallach commented 8 years ago

On the principle that we are distributing bgfx via MAME, and that in turns distributes a copy of libsquish (and freetype). If a security issue arises on any of these libs, the security team not only needs to patch and create advisories for say freetype, but for all the unrelated packages that embed a copy.

Fedora, Debian and other distros have a policy of using the system libraries when possible. So the default would be to still use the included bundles, but having some way to tell the build system to use system libraries would be nice for downstream distros.

bkaradzic commented 8 years ago

I could add option --with-syslibs that would in those cases prefer using system libraries, but in case I fix some bug in for example libsquish how that's going to get to system library?

Also these things are non-issue for MAME, since they are just using library itself, not examples and utilities.

jmallach commented 8 years ago

Honestly, what we do in those cases is send patches upstream.

Do you add functionality to libsquish often? Or, now that the changes are merged , do you envision needing changes to libsquish in the near future? It seems that the upstream maintainer is now quite open to adding bits, as he merged all the forks in one go.

jazzbre commented 8 years ago

The problem I had was that I wanted to use a different version of freetype.h, but couldn't because 3rdparty directory is included by default (so bgfx/3rdparty was used instead of the new one). Freetype is used only in examples, so I guess there should be a 3rdparty/examples/ include where all example (and non run-time) includes etc would be.