Is it possible to pass custom flags for specific modes? For example, dune file below works for dune build main.exe but fails for dune build main.exe.o because ocamlopt does not expect -lfoo. Is there a way to set -lfoo only for exe mode and not for object mode?
Problematic example:
(executable
(name main)
(libraries base core ctypes ctypes.foreign ctypes.stubs)
(link_flags (-cclib -lfoo))
(modes object exe))
Thanks!
It is not possible, but the feature makes sense. I'll tag as an enhancement in case someone would like to create a proposal for how to support this.
Thanks.
Is there any (cumbersome) hack around this limitation? I tried adding two executable stanzas but dune was not happy about two stanzas sharing same modules.
You can do what you did and simply copy the module. There's a (copy# ..) action for this purpose.
A cleaner approach depending on your situation may be to define a library with the modules that depend on -lfoo, passing -cclib -lfoo in the library_flags field. Then there should be no need to pass this flag when creating the executable.