Is there any way to define flags for cabal dependencies?
Newer versions of Cabal let you specify constraints in your cabal.project.local
or cabal.project
file. For example:
constraints: hmatrix +openblas
Is there any way to indicate in my application's .cabal file that I depend on a library so that it is built with the specific build flag?
No, but in your case this is not actually a problem in the solver and is rather and uninformative error (caused by someone's less than judicious uses of flags).
I also struggled for a long time to find a solution to this problem. I just found one! You have to modify the global cabal configuration file at ~/.cabal/config
. Add a constraints line like this to the initial section of the file:
constraints: hmatrix +openblas
This enables the openblas
flag for the hmatrix
package. It will be used automatically the next time the package is installed. If there is a way to set such a flag locally for a sandbox, I could not find it.
Looks like it's not possible to specify such a dependency via the build-depends
field in your .cabal
file. buildDepends
is defined as [Dependency]
, where data Dependency = Dependency PackageName VersionRange
. You can use cabal install --constraint="transformers-compat +transformers3"
, though.
Looking at the transformers-compat.cabal
file, I think that the solver should be able to figure out the correct flag assignment if you constrain your dependency on transformers
appropriately. E.g. build-depends: transformers >= 0.3 && < 0.4
should force the solver to choose transformers-compat +transformers3
. If this doesn't work, it may be a bug in the solver.