How can I restrict a library to be only included under a certain OS?

ryuukk_ ryuukk.dev at gmail.com
Tue Mar 28 21:51:31 UTC 2023


On Tuesday, 28 March 2023 at 21:10:08 UTC, solidstate1991 wrote:
> I added this line to my SDLang formatted dub build file:
>
> ```
> dependency "libx11" version="0.0.1" platform="posix"
> ```
>
> Yet it's included even on Windows, even if I change it to 
> "linux".
>
> Since there's a fatal bug in the library that disallows it to 
> be built, I'll be leaving it out for now, and instead move onto 
> something else, or try to issue a correction.

I think the way to go is with configuration

``dub build`` // will default to config "posix" since it's the 
1st one
``dub build -c windows`` // will use "windows" config, without 
the dependency

https://dub.pm/package-format-sdl.html#configurations

```
configuration "posix" {
         dependency "libx11" version="0.0.1"
}
configuration "windows" {
	platforms "windows"
}
```

My dub knowledge is pretty limited, maybe there is a better way?


More information about the Digitalmars-d-learn mailing list