Weak pointers in dune

In the virt-top project, the author used some sort of “weak pointers”. If an external library like csv is available at build time, it will be used also at runtime (ocamlfind ocamlopt [-package csv opt_csv.cmo] -o main main.cmo).

I tried to implement the same logic with a dune file. But the optional library is not considered by dune, even if opt_csv.ml is added to the modules list.

How would this be done with dune? I adjusted my copy of the code to require the formerly optional packages unconditionally, which would be good enough for my use case.

Have you looked into specifying your dependencies using select?