Hello,<br><br>I have just also written a FindOCaml and UseOCaml script. I wrote them last week, &quot;good minds think alike&quot; :-)<br><br>Are you interested in it ?<br><br>FindOCaml script looks for ocaml, ocamlc, ocamlopt, ocamllex, ocamlyacc and ocamldep.<br>
<br>UseOCaml script provides some macros to<br><ul><li>compile native or bytecode executables and libraries</li><li>install CMI files, ocaml targets and export files, which could be integrated into other OCaml projects<br>
</li><li>generate OCaml lexers and parsers</li></ul>It works like this on your example<br><br><br>include_directories (/opt/local/lib/ocaml/site-lib/extlib)<br><br>add_ocaml_library (libloc BYTECODE<br>  file_node.mli<br>
  <a href="http://file_node.ml">file_node.ml</a><br>  files.mli<br>  <a href="http://files.ml">files.ml</a><br>  io.mli<br>  <a href="http://io.ml">io.ml</a><br>  file_statistics.mli<br>  <a href="http://file_statistics.ml">file_statistics.ml</a><br>
  message_node.mli<br>  <a href="http://message_node.ml">message_node.ml</a><br>)<br><br>target_link_ocaml_libraries (libloc unix str extLib)<br><br>add_executable (loc BYTECODE <a href="http://loc.ml">loc.ml</a>)<br><br>
target_link_ocaml_libraries (loc libloc)<br><br>install_ocaml_executables (loc DESTINATION bin)<br><br>install_ocaml_exports (loc DESTINATION lib/cmake FILE loc.ocaml.cmake)<br><br><br>Dependencies are generated at configuration time and updated, if needed, after each compilation.<br>
<br>It&#39;s pretty hard to generate OCaml lexers and parsers at compile time because of dependencies. Unlike C, C++ or Fortran languages in CMake, we can&#39;t compute dependencies before compiling source files. I have to generate dependencies at configuration time and so on generate OCaml lexers and parsers at configuration time to have correct dependencies.<br>
<br>The best way should be to integrate OCaml in CMake, but I&#39;m pretty sure that OCaml build rules break the actual behaviour of CMake, because of mli files, which have to be compiled (it&#39;s like compiling headers in C). It&#39;s the third thread I see about OCaml this month, maybe it would be interesting to integrate it in CMake. Do you need some explanations to see if it&#39;s possible to integrate OCaml in CMake ?<br>
<br>Best regards,<br><br>J. Bedouet<br><br><br><br>---------- Forwarded message ----------<br>From: Keyan &lt;<a href="mailto:ml@pulsschlag.net">ml@pulsschlag.net</a>&gt;<br>To: Philip Lowman &lt;<a href="mailto:philip@yhbt.com">philip@yhbt.com</a>&gt;<br>
Date: Thu, 14 Jan 2010 11:11:56 +0100<br>Subject: Re: [CMake] ANN: UseOcaml.cmake<br>hi,<br>
<br>
ups ... i thought i replied to the list. thanks for the link. i will
adapt my find-script to the requirements and maintain the package.<br>
<br>
cheers,<br>
keyan<br>
<br>
<br>
On 14 Jan 2010, at 03:46, Philip Lowman wrote:<br>
<br>
&gt; On Mon, Jan 11, 2010 at 3:39 AM, Keyan &lt;<a href="mailto:ml@pulsschlag.net">ml@pulsschlag.net</a>&gt; wrote:<br>
&gt;&gt;&gt; It looks like a couple of the macros don&#39;t have the OCAML_ name prefix<br>
&gt;&gt;&gt; added to them.  For example, COPY_FILE &amp; GET_DEPENDENCIES.  You should<br>
&gt;&gt;&gt; add the prefix to them as well to prevent name collision when other<br>
&gt;&gt;&gt; people use your code.<br>
&gt;&gt;<br>
&gt;&gt; thanks. wasnt aware of this coding standard, but it makes sense :)<br>
&gt;&gt;<br>
&gt;&gt;&gt; For the INCLUDES feature, doesn&#39;t it just get turned into a list you<br>
&gt;&gt;&gt; can iterate on?  Couldn&#39;t you just use foreach() on it and add the<br>
&gt;&gt;&gt; &quot;-I&quot; argument and path argument to a separate list that gets passed to<br>
&gt;&gt;&gt; add_custom_command()?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; foreach(path ${includelist})<br>
&gt;&gt;&gt;   list(APPEND myargs &quot;-I&quot;)<br>
&gt;&gt;&gt;   list(APPEND myargs &quot;${path}&quot;)<br>
&gt;&gt;&gt; endforeach()<br>
&gt;&gt;<br>
&gt;&gt; nice, it worked. my mistake was that i used:<br>
&gt;&gt; set(myargs &quot;{$myargs} -I ${path}&quot;)<br>
&gt;&gt; instead.<br>
&gt;&gt;<br>
&gt;&gt; i will try to write a FindOcaml.cmake script soon. when i am done, what is the best practice to make it available?<br>
&gt;<br>
&gt; Sorry, your email got accidently buried for 3 days.  :)  Also please<br>
&gt; reply to all always so the list gets a copy of the thread.<br>
&gt;<br>
&gt; I think the best way to get it available it to have it released as<br>
&gt; part of CMake&#39;s Modules folder.  To do this you have to volunteer to<br>
&gt; maintain the module (basically to deal with patches and bugs) and<br>
&gt; follow the process documented in Modules/README.txt to obtain CVS<br>
&gt; commit access.<br>
&gt; <a href="http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/readme.txt?root=CMake&amp;view=markup" target="_blank">http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/readme.txt?root=CMake&amp;view=markup</a><br>

&gt;<br>
&gt; --<br>
&gt; Philip Lowman<br>