Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Building SFML with some features disabled?  (Read 1744 times)

0 Members and 1 Guest are viewing this topic.

bananaboy

  • Newbie
  • *
  • Posts: 3
    • View Profile
Building SFML with some features disabled?
« on: May 19, 2016, 07:17:50 am »
Hi,

I've been searching around and I couldn't find anything. Is there any way to build SFML with FLAC and the audio encoders disabled? I don't want nor need them, and I don't want to have to distribute them with my game (especially on Linux - it's one less dependency to have to worry about). I couldn't see any CMake variables or #defines to turn them off though.

Thanks,
Sam

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Building SFML with some features disabled?
« Reply #1 on: May 19, 2016, 07:23:43 am »
SFML was indeed not designed to "turn off" some parts of its implementation. But you could fork it and remove manually those parts -- unless a significant number of people ask for that, then it might be done upstream but I wouldn't count on that.  ;)
SFML / OS X developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Building SFML with some features disabled?
« Reply #2 on: May 19, 2016, 07:38:06 am »
I don't see why this can't become a "feature" at some point. Certain implementations can become more problematic than we anticipated (look at Windows joystick stories) and instead of sending the users into the source, they should be able to temporarily disable stuff via CMake as a temporary (or permanent) workaround, or simply as a way to customize the SFML they statically link into their executable. Many other libraries already offer this option.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Building SFML with some features disabled?
« Reply #3 on: May 19, 2016, 07:41:09 am »
@binary1248: not sure whether your comment was addressed primarily to me or not, but for the record I do agree with you. What I meant was that we usually do things because there's a significant demand for it (well, you already know that, don't you. ;-)).
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Building SFML with some features disabled?
« Reply #4 on: May 19, 2016, 08:02:15 am »
Linux is usually the system where dependencies are the easiest to manage. You don't have to distribute anything, users just have to "apt install libflac" or equivalent (which will most likely already been done, since flac is such a common dependency for anything that deals with audio).

Personally I'm not against making things optional, but they have to be worth it. And don't forget about the drawbacks: it introduces clutter at configuration time (I'm currently working with a library with tons of CMake options and I'm still trying to figure out which ones I should enable or disable), and most of all, all the SFML libraries built with custom options will generally be incompatible with each others, making the distribution process even harder.

Regarding audio back-ends, since the current system is quite modular, maybe we could think of runtime solutions rather than configuration options -- something like plugins.
Laurent Gomila - SFML developer

bananaboy

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Building SFML with some features disabled?
« Reply #5 on: May 19, 2016, 08:12:16 am »
Ok thanks. I'll probably fork it and do it myself then. I'll issue some pull requests and you can take the changes if you like!

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Building SFML with some features disabled?
« Reply #6 on: May 19, 2016, 12:40:22 pm »
I also work with libraries where there are seemingly endless options to enable/disable stuff. Almost every source tarball you get on Linux lets you ./configure some stuff in or out. Sure, mixing options will make the library you build incompatible with libraries that others build if the options don't match, but I really don't see why that is our problem. If someone builds a custom version of the library, then we simply have to assume that they know what they are doing. We really shouldn't try to protect users from their own stupidity to the disadvantage of the users who actually know how to make use of such a feature. If they don't understand an option, either read the documentation, ask on the forum or just don't touch it. I don't have any problem following this procedure, and neither should any serious developer.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
AW: Building SFML with some features disabled?
« Reply #7 on: May 19, 2016, 01:29:00 pm »
Wouldn't such options quickly add tons and tons of #ifdef into all sorts of places in the code?
Plus we'd have to manually keep track of all the possible dependencies a feature might have.
Unless we refactor the whole code base and extract dependency code even more...

While a good idea I'm not sure if the additional maintenance is worth the effort. Then again, maybe there are some options that really require a small amount of changes.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

bananaboy

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Building SFML with some features disabled?
« Reply #8 on: June 07, 2016, 07:43:53 am »
I just issued two pull requests for this (I also added a flag to disable networking).

 

anything