Hello,<br><br>I have just also written a FindOCaml and UseOCaml script. I wrote them last week, "good minds think alike" :-)<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'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'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'm pretty sure that OCaml build rules break the actual behaviour of CMake, because of mli files, which have to be compiled (it's like compiling headers in C). It'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's possible to integrate OCaml in CMake ?<br>
<br>Best regards,<br><br>J. Bedouet<br><br><br><br>---------- Forwarded message ----------<br>From: Keyan <<a href="mailto:ml@pulsschlag.net">ml@pulsschlag.net</a>><br>To: Philip Lowman <<a href="mailto:philip@yhbt.com">philip@yhbt.com</a>><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>
> On Mon, Jan 11, 2010 at 3:39 AM, Keyan <<a href="mailto:ml@pulsschlag.net">ml@pulsschlag.net</a>> wrote:<br>
>>> It looks like a couple of the macros don't have the OCAML_ name prefix<br>
>>> added to them. For example, COPY_FILE & GET_DEPENDENCIES. You should<br>
>>> add the prefix to them as well to prevent name collision when other<br>
>>> people use your code.<br>
>><br>
>> thanks. wasnt aware of this coding standard, but it makes sense :)<br>
>><br>
>>> For the INCLUDES feature, doesn't it just get turned into a list you<br>
>>> can iterate on? Couldn't you just use foreach() on it and add the<br>
>>> "-I" argument and path argument to a separate list that gets passed to<br>
>>> add_custom_command()?<br>
>>><br>
>>> foreach(path ${includelist})<br>
>>> list(APPEND myargs "-I")<br>
>>> list(APPEND myargs "${path}")<br>
>>> endforeach()<br>
>><br>
>> nice, it worked. my mistake was that i used:<br>
>> set(myargs "{$myargs} -I ${path}")<br>
>> instead.<br>
>><br>
>> i will try to write a FindOcaml.cmake script soon. when i am done, what is the best practice to make it available?<br>
><br>
> Sorry, your email got accidently buried for 3 days. :) Also please<br>
> reply to all always so the list gets a copy of the thread.<br>
><br>
> I think the best way to get it available it to have it released as<br>
> part of CMake's Modules folder. To do this you have to volunteer to<br>
> maintain the module (basically to deal with patches and bugs) and<br>
> follow the process documented in Modules/README.txt to obtain CVS<br>
> commit access.<br>
> <a href="http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/readme.txt?root=CMake&view=markup" target="_blank">http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/readme.txt?root=CMake&view=markup</a><br>
><br>
> --<br>
> Philip Lowman<br>