On 30 January 2012 18:11, bls <bizprac@orange.fr> wrote:
On 01/30/2012 07:18 AM, Adam D. Ruppe wrote:
On Monday, 30 January 2012 at 14:24:32 UTC, Manu wrote:
I want to know if a library is present, and automatically disable
non-vital features if it isn't.

I'd like it too... here's what I tried. It doesn't
work, though.

I am afraid I miss the point but shouldn't module ctors help.. f.i.

module m;
import std.file;
static this()  // module ctor
{
       if ("/usr/share/include/my.lib".isDir)
               import my;
       else
               import other;
               
}

Not tested!

That looks like a runtime test, and would still require both libs being present to link. I'm talking about detection at compile time.

For example, I have a sound API here atm, the it supports mp3, vorbis, flac, wma, etc, but not all of those libraries are available for all platforms I build for.
What I need to do is know in advance what platforms have which libs available, and then do a bunch of platform checks to decide which should or shouldn't be present.
Further more, if a lib is *available* for a given platform, but I don't want to use it, or don't want to install/build the lib, I need to edit the code... If I could detect presence of the lib, I can just gracefully remove the feature.