how to set extra-lib-dirs for a dependency in a stack project?

Dear Cafe, is it possible to specify include-dirs and extra-lib-dirs for a dependency? I have * top-level project A, depends on: * project B, depends on: * C: external library (written in C) I am building A with stack. I don't want to put fixed locations (include/lib) for C in B.cabal, because it depends on the (top-level) build environment of A (e.g., my machine, or CI). Concrete example: C = kissat SAT solver, B = Haskell API for C. I know that, e.g., https://hackage.haskell.org/package/minisat works around this problem by vendoring (is this the word?) the solver's code (into B). I don't want this. With cabal.project, I could set options for (all?) dependencies? https://cabal.readthedocs.io/en/3.4/cabal-project.html#foreign-function-inte... Would stack use this setting (will it read that file at all)? Will I have to copy all extra-deps source repo locations to cabal.project? - J.

On Sun, 30 Jan 2022, Johannes Waldmann wrote:
is it possible to specify include-dirs and extra-lib-dirs for a dependency?
I have
* top-level project A, depends on: * project B, depends on: * C: external library (written in C)
I am building A with stack. I don't want to put fixed locations (include/lib) for C in B.cabal, because it depends on the (top-level) build environment of A (e.g., my machine, or CI).
Concrete example: C = kissat SAT solver, B = Haskell API for C.
Are B and C part of Stackage? It sounds as if they are not. If so, then why would you want to build with 'stack', at all?
With cabal.project, I could set options for (all?) dependencies? https://cabal.readthedocs.io/en/3.4/cabal-project.html#foreign-function-inte... Would stack use this setting (will it read that file at all)?
stack ignores cabal.project.
Will I have to copy all extra-deps source repo locations to cabal.project?
In cabal.project you can add: package C extra-include-dirs: /usr/local/C/include extra-lib-dirs: /usr/local/C/lib

Hi.
In cabal.project you can add:
package C extra-include-dirs: /usr/local/C/include extra-lib-dirs: /usr/local/C/lib
yes. That way I can build with cabal only (not stack) and I need to copy all my extra source repo locations from stack.yaml to cabal.project (and then need to maintain both files)OK, it's an option that I will consider.
Are B and C part of Stackage?
It sounds as if they are not.
If so, then why would you want to build with 'stack', at all?
A has lots of other dependencies. For specifying their versions, I'd like to rely on stackage's resolver. - J.

On Sun, 30 Jan 2022, Johannes Waldmann wrote:
In cabal.project you can add:
package C extra-include-dirs: /usr/local/C/include extra-lib-dirs: /usr/local/C/lib
yes. That way I can build with cabal only (not stack) and I need to copy all my extra source repo locations from stack.yaml to cabal.project (and then need to maintain both files)OK, it's an option that I will consider.
You may consider putting extra-lib-dirs paths in your .cabal/config .
participants (2)
-
Henning Thielemann
-
Johannes Waldmann