title: What is the preferred way to structure and build OCaml projects?
body: <p>It is unclear to newcomers to the ecosystem what is the canonically preferred way to structure and manage building small to medium sized OCaml projects. I understand the basics of <code>ocamlc</code>, &amp;c.--they mirror conventional UNIX C compilers enough to seem straightforward. But, above the level of one-off compilation of individual files, it is unclear how best to manage compilation simply and cleanly. The issue is not searching for potential tools, but seeing one or a few Right (enough) Ways--as validated by the experience of the community--for structuring and building standard OCaml projects.</p>
  <p>My model use case is a modest but nontrivial project, of pure OCaml or OCaml plus a C dependency. Such a project:</p>
  <ol>
  <li>contains a number of source files</li>
  <li>links to a number of standard libraries</li>
  <li>links to one or more 3rd party libraries</li>
  <li>optionally includes a C library and OCaml wrapper as a subproject (though this could also be managed separately and included as a 3rd party library, as in (3))</li>
  </ol>
  <p>Several alternative tools stand out:</p>
  <ul>
  <li>Custom Makefiles seem to be the common standard in most open source OCaml packages, but appear frustratingly verbose and complex--even more so than for modest C/C++ projects. Worse, many even seemingly simple OCaml libraries layer autoconf/automake on top for even greater complexity.</li>
  <li><a href="https://ocaml.org/learn/tutorials/ocamlbuild/" rel="nofollow noreferrer">ocamlbuild</a> appears to offer a modern, streamlined mechanism for automating builds with minimal configuration, but it is not well documented for newcomers, nor represented by example in the introductory materials in the OCaml ecosystem, nor visibly used by any of the various published OCaml projects which I have browsed for inspiration.</li>
  <li><a href="http://oasis.forge.ocamlcore.org/" rel="nofollow noreferrer">OASIS</a> seems to be a layer of convention and library code atop other build systems to support building a package manager and library, like Cabal.</li>
  </ul>
  <p>(I have also seen <a href="http://omake.metaprl.org/" rel="nofollow noreferrer">OMake</a>, which appears to be a self-styled &quot;<code>make++</code>&quot; which also includes a suite of standard rules for common languages, including OCaml, and <a href="http://ocaml.info/home/ocaml_sources.html" rel="nofollow noreferrer">ocaml-make</a> née OCamlMakefile, providing a template of standard rules for GNU <code>make</code>.)</p>
  <p>Are any of these a preferred, modern way of managing OCaml builds?</p>
  <p>How are project files best structured?</p>
  <p>How are 3rd party library dependencies included and managed? Is it preferred to install them at the system level, or is there a standard and straightforward way of managing them locally to a project? I would much prefer a model in which projects remain as self-contained as possible.</p>