Cabal build depends and if cpp-options

Gracjan Polak gracjanpolak at
Wed Feb 10 04:51:13 EST 2010

Malcolm Wallace <malcolm.wallace <at>> writes:
> Flag foo
> Library
>    if foo
>        build-depends: base >=4 && <=5
>        cpp-options:   -DUSE_BASE_4
>    else
>        build-depends: base >=3 && <4
>        cpp-options:   -DUSE_BASE_3

This seems to be classic solution.

I have a library that could accommodate to whatever base it compiles with. But
that base version number depends on the requirements of the program or of all
the other libraries involved.

Therefore I imagine that:
1. dependency solver will pick base version that satisfies all of the constraints
2. tells my library which one has been chosen for this particular build
3. my lib happily compiles

Look ma! No flags!

How to do 

cabal install MyProg 

where MyProg depends on MyLib but with particular MyFlag set?


More information about the Libraries mailing list