In this question I asked how to have a conditional dependency in a package in dune-package. The answer is
(package
(name foo)
(depends
(linenoise (and (>= 1.1.0) (<> :os "windows")))))
That works, but now I need to
a) conditionally link to that library in an executable, and
b) conditionally compile code to use that library (or fallback code if it isn’t used)
Here is the executable:
(executable
(name sail)
(package sail)
(link_flags -linkall)
(libraries other_stuff linenoise))
And here is some code that uses it:
let mode_clear istate =
match istate.mode with
| Normal -> ()
| Evaluation _ -> if istate.display_options.clear then LNoise.clear_screen () else ()
And if linenoise isn’t being used I want it instead to compile
let mode_clear _istate = ()
How do I achieve both of those?