[CMake] ANN: UseOcaml.cmake

Judicaël Bedouet j.bedouet at infonie.fr
Thu Jan 14 16:14:06 EST 2010


Hello,

I have just also written a FindOCaml and UseOCaml script. I wrote them last
week, "good minds think alike" :-)

Are you interested in it ?

FindOCaml script looks for ocaml, ocamlc, ocamlopt, ocamllex, ocamlyacc and
ocamldep.

UseOCaml script provides some macros to

   - compile native or bytecode executables and libraries
   - install CMI files, ocaml targets and export files, which could be
   integrated into other OCaml projects
   - generate OCaml lexers and parsers

It works like this on your example


include_directories (/opt/local/lib/ocaml/site-lib/extlib)

add_ocaml_library (libloc BYTECODE
  file_node.mli
  file_node.ml
  files.mli
  files.ml
  io.mli
  io.ml
  file_statistics.mli
  file_statistics.ml
  message_node.mli
  message_node.ml
)

target_link_ocaml_libraries (libloc unix str extLib)

add_executable (loc BYTECODE loc.ml)

target_link_ocaml_libraries (loc libloc)

install_ocaml_executables (loc DESTINATION bin)

install_ocaml_exports (loc DESTINATION lib/cmake FILE loc.ocaml.cmake)


Dependencies are generated at configuration time and updated, if needed,
after each compilation.

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.

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 ?

Best regards,

J. Bedouet



---------- Forwarded message ----------
From: Keyan <ml at pulsschlag.net>
To: Philip Lowman <philip at yhbt.com>
Date: Thu, 14 Jan 2010 11:11:56 +0100
Subject: Re: [CMake] ANN: UseOcaml.cmake
hi,

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.

cheers,
keyan


On 14 Jan 2010, at 03:46, Philip Lowman wrote:

> On Mon, Jan 11, 2010 at 3:39 AM, Keyan <ml at pulsschlag.net> wrote:
>>> It looks like a couple of the macros don't have the OCAML_ name prefix
>>> added to them.  For example, COPY_FILE & GET_DEPENDENCIES.  You should
>>> add the prefix to them as well to prevent name collision when other
>>> people use your code.
>>
>> thanks. wasnt aware of this coding standard, but it makes sense :)
>>
>>> For the INCLUDES feature, doesn't it just get turned into a list you
>>> can iterate on?  Couldn't you just use foreach() on it and add the
>>> "-I" argument and path argument to a separate list that gets passed to
>>> add_custom_command()?
>>>
>>> foreach(path ${includelist})
>>>   list(APPEND myargs "-I")
>>>   list(APPEND myargs "${path}")
>>> endforeach()
>>
>> nice, it worked. my mistake was that i used:
>> set(myargs "{$myargs} -I ${path}")
>> instead.
>>
>> i will try to write a FindOcaml.cmake script soon. when i am done, what
is the best practice to make it available?
>
> Sorry, your email got accidently buried for 3 days.  :)  Also please
> reply to all always so the list gets a copy of the thread.
>
> I think the best way to get it available it to have it released as
> part of CMake's Modules folder.  To do this you have to volunteer to
> maintain the module (basically to deal with patches and bugs) and
> follow the process documented in Modules/README.txt to obtain CVS
> commit access.
>
http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/readme.txt?root=CMake&view=markup
>
> --
> Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100114/0285b0b2/attachment.htm>


More information about the CMake mailing list